diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..422596d --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,46 @@ +name: Test IM-Client + +on: + push: + branches: ["master"] + pull_request: + branches: ["master"] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Check out the codebase. + uses: actions/checkout@v4 + + - name: Set up Python 3. + uses: actions/setup-python@v5 + with: + python-version: '3.10' + + - name: Install dependencies + run: python -m pip install coverage mock radl netaddr requests pycodestyle + + - name: Prepare auth.dat + run: | + cat <> oidc-token + #!/bin/sh + echo "token" + EOT + chmod a+x oidc-token + sed -i '/oidc-token/c\type = InfrastructureManager; bearer_token_command = '${GITHUB_WORKSPACE}'/oidc-token OIDC_ACCOUNT' auth.dat + + - name: Check code style + run: pycodestyle --max-line-length=120 --ignore=E402,W605 . --exclude=doc + + - name: Unit tests + run: python -m coverage run --source=. -m unittest discover -s test/unit -p '*.py' + + - name: Generate XML coverage report + run: python -m coverage xml + + - name: Report coverage + uses: codacy/codacy-coverage-reporter-action@v1 + with: + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} + coverage-reports: coverage.xml \ No newline at end of file diff --git a/README.md b/README.md index 91d537d..c3bd306 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # IM - Infrastructure Manager client [![PyPI](https://img.shields.io/pypi/v/im-client.svg)](https://pypi.org/project/im-client) -[![Build Status](http://jenkins.i3m.upv.es/buildStatus/icon?job=grycap/im-client-unit-py3)](http://jenkins.i3m.upv.es:8080/job/grycap/job/im-client-unit-py3/) +[![Tests](https://github.com/grycap/im-client/actions/workflows/main.yaml/badge.svg)](https://github.com/grycap/im-client/actions/workflows/main.yaml) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/c74628a2fc134c2683d3fc57b571ce09)](https://www.codacy.com/gh/grycap/im-client/dashboard?utm_source=github.com&utm_medium=referral&utm_content=grycap/im-client&utm_campaign=Badge_Grade) [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/c74628a2fc134c2683d3fc57b571ce09)](https://www.codacy.com/app/micafer/im-client?utm_source=github.com&utm_medium=referral&utm_content=grycap/im-client&utm_campaign=Badge_Coverage) [![License](https://img.shields.io/badge/license-GPL%20v3.0-brightgreen.svg)](LICENSE) diff --git a/test/unit/test_client.py b/test/unit/test_client.py index fe81100..a9abd18 100755 --- a/test/unit/test_client.py +++ b/test/unit/test_client.py @@ -1149,7 +1149,7 @@ def test_parser_help(self, option_parser_exit): sys.stdout = out parser.parse_args(["--help"]) output = out.getvalue().strip() - self.assertEqual(output[:16], "Usage: nosetests") + self.assertEqual(output[:7], "Usage: ") self.assertIn("[-u|--xmlrpc-url ] [-r|--restapi-url ] [-v|--verify-ssl] " "[-a|--auth_file ] operation op_parameters", output) sys.stdout = oldstdout