From 727e0049c1eda6949c9075ae2590c5de98f961bd Mon Sep 17 00:00:00 2001 From: Pierre Equoy <pierre.equoy@canonical.com> Date: Wed, 24 Jan 2024 16:34:15 +0800 Subject: [PATCH] Add contrib provider ce-oem GitHub workflows (Infra) (#938) * Remove old ce-oem workflow This workflow comes from the original Git repository and is no longer needed. * Add workflow for the ce-oem provider This workflow is adapted from existing workflows used for the generic providers. * Update contrib ce-oem tox config - Point to the correct version of Python using {envpython} - Remove the "develop installation" step for the ce-oem provider - Convert the test step into a test coverage one to generate an XML report to be used later by Codecov * Point to the right directory for generic providers * Install ce-oem provider prior to run validation on it * Add codecov config for ce-oem contrib provider Following Codecov documentation on flags[1], use the `contrib-provider-ce-oem` flag defined in the GitHub workflow[2] to mark Codecov status checks as non-blocking[3]. [1] https://docs.codecov.com/docs/flags [2] .github/workflows/tox-contrib-provider-ce-oem.yaml [3] https://docs.codecov.com/docs/common-recipe-list#set-non-blocking-status-checks * Fix tox configuration for ce-oem provider * Add coverage requirement to ce-oem tox config * Add coverage config to ce-oem provider * Update codecov config to make project status non-blocking for ce-oem provider * Change job id and add a name to it for easier reference --- .../tox-contrib-provider-ce-oem.yaml | 47 +++++++++++++++++++ codecov.yml | 11 +++++ contrib/.github/workflows/tox.yaml | 35 -------------- contrib/checkbox-provider-ce-oem/.coveragerc | 17 +++++++ contrib/checkbox-provider-ce-oem/tox.ini | 32 ++++++++----- 5 files changed, 94 insertions(+), 48 deletions(-) create mode 100644 .github/workflows/tox-contrib-provider-ce-oem.yaml delete mode 100644 contrib/.github/workflows/tox.yaml create mode 100644 contrib/checkbox-provider-ce-oem/.coveragerc diff --git a/.github/workflows/tox-contrib-provider-ce-oem.yaml b/.github/workflows/tox-contrib-provider-ce-oem.yaml new file mode 100644 index 0000000000..673bd4540f --- /dev/null +++ b/.github/workflows/tox-contrib-provider-ce-oem.yaml @@ -0,0 +1,47 @@ +name: Test provider-ce-oem (from contrib area) with tox + +on: + push: + branches: [ main ] + paths: + - contrib/checkbox-provider-ce-oem/** + pull_request: + branches: [ main ] + paths: + - contrib/checkbox-provider-ce-oem/** + workflow_dispatch: + +jobs: + tox_test_contrib_ce_oem_provider: + name: Test ce-oem provider (from contrib area) with tox + defaults: + run: + working-directory: contrib/checkbox-provider-ce-oem + runs-on: ubuntu-20.04 + strategy: + matrix: + python: ["3.5", "3.6", "3.8", "3.10"] + include: + - python: "3.5" + tox_env_name: "py35" + - python: "3.6" + tox_env_name: "py36" + - python: "3.8" + tox_env_name: "py38" + - python: "3.10" + tox_env_name: "py310" + steps: + - uses: actions/checkout@v3 + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + - name: Install tox + run: pip install tox + - name: Run tox + run: tox -e${{ matrix.tox_env_name }} + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + flags: contrib-provider-ce-oem diff --git a/codecov.yml b/codecov.yml index 2181d8cc80..01a2911c76 100644 --- a/codecov.yml +++ b/codecov.yml @@ -8,3 +8,14 @@ flag_management: # carryforward means if a test was not run again, use the previous # coverage result for the current flag (part) carryforward: true + individual_flags: + # non-blocking status check for ce-oem provider in contrib area + - name: contrib-provider-ce-oem + paths: + - contrib/checkbox-provider-ce-oem + carryforward: true + statuses: + - type: patch + informational: true + - type: project + informational: true diff --git a/contrib/.github/workflows/tox.yaml b/contrib/.github/workflows/tox.yaml deleted file mode 100644 index d453966604..0000000000 --- a/contrib/.github/workflows/tox.yaml +++ /dev/null @@ -1,35 +0,0 @@ -name: Test checkbox-provider-ce-oem with tox - -on: - push: - pull_request: - branches: [ main ] - paths: - - checkbox-provider-ce-oem/** - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-20.04 - strategy: - matrix: - python: ["3.5", "3.6", "3.8", "3.10"] - steps: - - uses: actions/checkout@v3 - - name: install stable checkbox and checkbox-provider-ce-oem - run: | - cd ~ - git clone --depth=1 https://github.com/canonical/checkbox.git - cd - - cp -r checkbox-provider-ce-oem ~/checkbox/providers - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - - name: Install tox and otehr dependencies - run: | - python3 -m pip install --upgrade pip - pip3 install tox - - name: Run tox - working-directory: /home/runner/checkbox/providers/checkbox-provider-ce-oem/ - run: tox -e py${{ matrix.python }} diff --git a/contrib/checkbox-provider-ce-oem/.coveragerc b/contrib/checkbox-provider-ce-oem/.coveragerc new file mode 100644 index 0000000000..8dfe971275 --- /dev/null +++ b/contrib/checkbox-provider-ce-oem/.coveragerc @@ -0,0 +1,17 @@ +[run] +branch = True +source = bin,manage +omit = + tests/* + +[report] +exclude_lines = + @abc.abstractmethod + @abc.abstractproperty + @abstractmethod + @abstractproperty + @public + pragma: no cover + raise NotImplementedError + if __name__ == .__main__.: +show_missing = True diff --git a/contrib/checkbox-provider-ce-oem/tox.ini b/contrib/checkbox-provider-ce-oem/tox.ini index 6028600aad..2090b30207 100644 --- a/contrib/checkbox-provider-ce-oem/tox.ini +++ b/contrib/checkbox-provider-ce-oem/tox.ini @@ -6,26 +6,29 @@ skipsdist=True [testenv] allowlist_externals = rm commands = - pip -q install ../../checkbox-ng + {envpython} -m pip -q install ../../checkbox-ng # Required because this provider depends on checkbox-support parsers & scripts - pip -q install ../../checkbox-support + {envpython} -m pip -q install ../../checkbox-support rm -f /var/tmp/checkbox-providers-develop/checkbox-provider-resource.provider rm -f /var/tmp/checkbox-providers-develop/checkbox-provider-base.provider rm -f /var/tmp/checkbox-providers-develop/checkbox-provider-certification-client.provider rm -f /var/tmp/checkbox-providers-develop/checkbox-provider-certification-server.provider rm -f /var/tmp/checkbox-providers-develop/checkbox-provider-ce-oem.provider # Install all providers in develop mode to make sure everything works fine - {envbindir}/python3 ../resource/manage.py develop - {envbindir}/python3 ../base/manage.py develop - {envbindir}/python3 ../certification-client/manage.py develop - {envbindir}/python3 ../certification-server/manage.py develop - {envbindir}/python3 manage.py develop - {envbindir}/python3 manage.py validate - {envbindir}/python3 manage.py test + {envpython} ../../providers/resource/manage.py develop + {envpython} ../../providers/base/manage.py develop + {envpython} ../../providers/certification-client/manage.py develop + {envpython} ../../providers/certification-server/manage.py develop + {envpython} manage.py develop + {envpython} manage.py validate + {envpython} -m coverage run manage.py test + {envpython} -m coverage report + {envpython} -m coverage xml -[testenv:py3.5] +[testenv:py35] deps = flake8 + coverage == 5.5 pyserial natsort == 4.0.3 requests == 2.9.1 @@ -42,9 +45,10 @@ setenv= # but it breaks some old python3.5 builds SETUPTOOLS_SCM_PRETEND_VERSION=0.0 -[testenv:py3.6] +[testenv:py36] deps = flake8 + coverage == 5.5 pyserial natsort == 4.0.3 requests == 2.18.4 @@ -57,9 +61,10 @@ deps = distro == 1.0.1 PyYAML == 3.12 -[testenv:py3.8] +[testenv:py38] deps = flake8 + coverage == 7.3.0 pep8-naming pyserial natsort == 7.0.1 @@ -73,9 +78,10 @@ deps = distro == 1.4.0 PyYAML == 5.3.1 -[testenv:py3.10] +[testenv:py310] deps = flake8 + coverage == 7.3.0 pep8-naming pyserial natsort == 8.0.2