From cc2ee61ed5cd94f4c59f211367c41ffc2a465a4c Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Thu, 18 Jan 2024 14:26:45 -0500 Subject: [PATCH] CI: fix installation of Python and setuptools for different OS images The "version" and "egg" tasks use official container images for a number of operating systems that may use either DNF or APT as a package manager, and may or may not have Python or setuptools. The existing checks and installation is broken, and was not detected because they were always running on the base GitHub actions image. A number of GitHub Actions run as part of the CI checks are not effectively setting the container image that should be used. This effectively means that instead of covering a number of different platforms, it's re-running the same checks on the base OS. This applies the directive that effective makes GitHub action set up the container where the job will be run. Signed-off-by: Cleber Rosa --- .github/workflows/ci.yml | 426 ++++++--------------------------------- 1 file changed, 66 insertions(+), 360 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c40311f99..c123b531dd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,340 +5,60 @@ on: workflow_dispatch: jobs: - static-checks: + egg_task_fedora_37: - name: Static checks + name: Egg task fedora:37 runs-on: ubuntu-20.04 container: - image: quay.io/avocado-framework/avocado-ci-fedora-38 - - steps: - - run: echo "Job triggered by a ${{ github.event_name }} event on branch is ${{ github.ref }} in repository is ${{ github.repository }}, runner on ${{ runner.os }}" - - name: Check out repository code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.sha }} - - name: Allow git to operate on directory checked out by GH Actions - run: git config --global --add safe.directory `pwd` - - name: Installing Avocado development dependencies - run: make requirements-dev - - name: Installing Avocado in develop mode - run: python3 setup.py develop --user - - name: Run static checks - env: - COMMIT_COUNT: ${{ github.event.pull_request.commits }} - run: python3 setup.py test --select=static-checks - - name: Archive failed tests logs - if: failure() - uses: actions/upload-artifact@v3 - with: - name: static-checks-logs - path: /home/runner/avocado/job-results/ - retention-days: 1 - - run: echo "🥑 This job's status is ${{ job.status }}." - - smokecheck-linux: - - name: Smokecheck on Linux with Python ${{ matrix.python-version }} - runs-on: ubuntu-20.04 - - strategy: - matrix: - python-version: [3.7, 3.8, 3.9, 3.10.0, 3.11, 3.12.0] - fail-fast: false - - steps: - - run: echo "Job triggered by a ${{ github.event_name }} event on branch is ${{ github.ref }} in repository is ${{ github.repository }}, runner on ${{ runner.os }}" - - name: Check out repository code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install setuptools on Python 3.12 - run: python3 -c 'import setuptools' || python3 -m pip install setuptools - - name: Avocado smokecheck - run: make smokecheck - - check-linux: - - name: Linux with Python ${{ matrix.python-version }} - runs-on: ubuntu-20.04 - needs: smokecheck-linux - - strategy: - matrix: - python-version: [3.7, 3.8, 3.9, 3.10.0, 3.11, 3.12.0] - fail-fast: false - - steps: - - run: echo "Job triggered by a ${{ github.event_name }} event on branch is ${{ github.ref }} in repository is ${{ github.repository }}, runner on ${{ runner.os }}" - - name: Check out repository code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Display Python version - run: python -V --version - - name: Install dependencies - run: pip install -r requirements-dev.txt - - name: Install setuptools on Python 3.12 - run: python3 -c 'import setuptools' || python3 -m pip install setuptools - - name: Installing Avocado in develop mode - run: python3 setup.py develop --user - - name: Avocado version - run: avocado --version - - name: Unittests and fast functional tests - run: python3 setup.py test --skip=static-checks - - name: Archive failed tests logs - if: failure() - uses: actions/upload-artifact@v3 - with: - name: linux-logs-${{ matrix.python-version }} - path: /home/runner/avocado/job-results/ - retention-days: 1 - - run: echo "🥑 This job's status is ${{ job.status }}." - - code-coverage: - - name: Code Coverage - runs-on: ubuntu-20.04 - - strategy: - matrix: - python-version: [3.11] - env: - CC_TEST_REPORTER_ID: "387887b88a76f31c2c376219fc749689ea5975c8fe7fcd9609f1dcc139e053a6" - - steps: - - run: echo "Job triggered by a ${{ github.event_name }} event on branch is ${{ github.ref }} in repository is ${{ github.repository }}, runner on ${{ runner.os }}" - - name: Check out repository code - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install - run: | - pip install -r requirements-dev.txt - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - chmod +x ./cc-test-reporter - - name: Run pre script - run: ./cc-test-reporter before-build - - name: Run script - run: make develop && ./selftests/run_coverage - - name: Run post script - run: ./cc-test-reporter after-build - - run: echo "🥑 This job's status is ${{ job.status }}." - - -# macOS check on latest Python - - check-macos: - - name: macOS with Python ${{ matrix.python-version }} - runs-on: macos-12 - - strategy: - matrix: - python-version: [3.11.1] - + image: fedora:37 steps: - - run: echo "Job triggered by a ${{ github.event_name }} event on branch is ${{ github.ref }} in repository is ${{ github.repository }}, runner on ${{ runner.os }}" + - name: Install Python dependencies + run: dnf -y install python3 python3-setuptools - name: Check out repository code uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Display Python version - run: python -V --version - - name: Install avocado + - name: Test running avocado from eggs run: | - python3 -m pip install -r requirements-dev.txt - python setup.py develop --user - - name: Show avocado help - run: python -m avocado --help - - name: Example test - run: python -m avocado run examples/tests/passtest.py - - name: List test - run: python -m avocado --verbose list selftests/unit/* selftests/functional/* selftests/*sh - - name: Run a subset of avocado's selftests - run: PATH=~/Library/Python/3.11/bin:$PATH ./selftests/check.py --skip=static-checks - - run: echo "🥑 This job's status is ${{ job.status }}." - - -# Windows checks on latest Python - - smokecheck-windows: - - name: Windows with Python ${{ matrix.python-version }} - runs-on: windows-2019 - - strategy: - matrix: - python-version: [3.9, 3.10.0, 3.11, 3.12.0] - - steps: - - run: echo "Job triggered by a ${{ github.event_name }} event on branch is ${{ github.ref }} in repository is ${{ github.repository }}, runner on ${{ runner.os }}" - - name: Check out repository code - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Display Python version - run: python -V --version - - name: Install setuptools on Python 3.12 - run: python -c 'import setuptools' || python -m pip install setuptools - - name: Install avocado - run: python setup.py develop --user - - name: Show avocado help - run: python -m avocado --help - - name: Example test - run: python -m avocado run examples\tests\passtest.py - - run: echo "🥑 This job's status is ${{ job.status }}." - - -# Checks that Python packages builds succeeds - - package-build: - name: Build Package (wheel/tarball) for Python ${{ matrix.python-version }} - runs-on: ubuntu-20.04 - - strategy: - matrix: - python-version: [3.7, 3.8, 3.9, 3.10.0, 3.11, 3.12.0] - fail-fast: false - - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install setuptools on Python 3.12 - run: python3 -c 'import setuptools' || python3 -m pip install setuptools - - name: Build tarballs and wheels - run: make -f Makefile.gh build-wheel check-wheel - - name: Save tarballs and wheels as artifacts - uses: actions/upload-artifact@v3 - with: - name: tarballs_and_wheels-${{ matrix.python-version }} - path: ${{github.workspace}}/PYPI_UPLOAD/ - retention-days: 1 - - run: echo "🥑 This job's status is ${{ job.status }}." - - egg-build: - name: Build Egg for Python ${{ matrix.python-version }} - runs-on: ubuntu-20.04 - - strategy: - matrix: - python-version: [3.7, 3.8, 3.9, 3.10.0, 3.11, 3.12.0] - fail-fast: false - - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install setuptools on Python 3.12 - run: python3 -c 'import setuptools' || python3 -m pip install setuptools - - name: Build eggs - run: make -f Makefile.gh build-egg - - name: Save eggs as artifacts - uses: actions/upload-artifact@v3 - with: - name: eggs-${{ matrix.python-version }} - path: ${{github.workspace}}/EGG_UPLOAD/ - retention-days: 1 - - run: echo "🥑 This job's status is ${{ job.status }}." - - experimental-checks: - name: Experimental checks - runs-on: ubuntu-20.04 - steps: - - run: echo "Job triggered by a ${{ github.event_name }} event on branch is ${{ github.ref }} in repository is ${{ github.repository }}, runner on ${{ runner.os }}" - - name: Check out repository code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Run Codespell Check - run: make -f Makefile.gh codespell - - name: Run bandit check - run: make -f Makefile.gh bandit - continue-on-error: True - - name: Save bandit output as artifacts - uses: actions/upload-artifact@v3 - with: - name: bandit-results - path: /home/runner/work/avocado/avocado/bandit-output.txt - retention-days: 1 - - run: echo "🥑 This job's status is ${{ job.status }}." + python3 setup.py bdist_egg + mv dist/avocado_framework-*egg /tmp + python3 setup.py clean --all + python3 -c 'import sys; import glob; sys.path.insert(0, glob.glob("/tmp/avocado_framework-*.egg")[0]); from avocado.core.main import main; sys.exit(main())' run /bin/true + cd /tmp + python3 -c 'import sys; from pkg_resources import require; require("avocado-framework"); from avocado.core.main import main; sys.exit(main())' run /bin/true - version_task: + egg_task_fedora_38: - name: Version task (${{ matrix.container }}) + name: Egg task fedora:38 runs-on: ubuntu-20.04 - strategy: - matrix: - container: ["fedora:37", - "fedora:38", - "registry.access.redhat.com/ubi8/ubi:8.8", - "registry.access.redhat.com/ubi9/ubi:9.2", - "debian:10.10", - "debian:11.0", - "ubuntu:21.10", - "ubuntu:20.04"] + container: + image: fedora:38 steps: + - name: Install Python dependencies + run: dnf -y install python3-setuptools - name: Check out repository code uses: actions/checkout@v3 - - name: Install and run avocado --version + - name: Test running avocado from eggs run: | - if ! command -v dnf &> /dev/null - then - python3 -c 'import setuptools' || dnf -y install python3 python3-setuptools - else - python3 --version || (apt update && apt -y install python3 python3-setuptools ca-certificates) - fi - python3 setup.py develop --user - python3 -m avocado --version - + python3 setup.py bdist_egg + mv dist/avocado_framework-*egg /tmp + python3 setup.py clean --all + python3 -c 'import sys; import glob; sys.path.insert(0, glob.glob("/tmp/avocado_framework-*.egg")[0]); from avocado.core.main import main; sys.exit(main())' run /bin/true + cd /tmp + python3 -c 'import sys; from pkg_resources import require; require("avocado-framework"); from avocado.core.main import main; sys.exit(main())' run /bin/true - egg_task: + egg_task_ubi_8: - name: Egg task (${{ matrix.container }}) + name: Egg task ubi:8.8 runs-on: ubuntu-20.04 - strategy: - matrix: - container: ["fedora:37", - "fedora:38", - "registry.access.redhat.com/ubi8/ubi:8.8", - "registry.access.redhat.com/ubi9/ubi:9.2", - "debian:10.10", - "debian:11.0", - "ubuntu:21.10", - "ubuntu:20.04"] + container: + image: registry.access.redhat.com/ubi8/ubi:8.8 steps: + - name: Install Python dependencies + run: dnf -y install python38 python38-setuptools - name: Check out repository code uses: actions/checkout@v3 - name: Test running avocado from eggs run: | - if ! command -v dnf &> /dev/null - then - python3 -c 'import setuptools' || dnf -y install python3 python3-setuptools - else - python3 --version || (apt update && apt -y install python3 python3-setuptools) - fi python3 setup.py bdist_egg mv dist/avocado_framework-*egg /tmp python3 setup.py clean --all @@ -346,74 +66,60 @@ jobs: cd /tmp python3 -c 'import sys; from pkg_resources import require; require("avocado-framework"); from avocado.core.main import main; sys.exit(main())' run /bin/true + egg_task_ubi_9: - podman_egg_task: - - name: Podman Egg task - runs-on: ubuntu-22.04 + name: Egg task ubi:9.2 + runs-on: ubuntu-20.04 + container: + image: registry.access.redhat.com/ubi9/ubi:9.2 steps: - name: Check out repository code uses: actions/checkout@v3 - - name: Test running avocado from eggs under Podman spawner + - name: Test running avocado from eggs run: | - apt update && apt -y install python3 python3-setuptools python3 setup.py bdist_egg - mv dist/avocado_framework-*egg /tmp/avocado_framework.egg + mv dist/avocado_framework-*egg /tmp python3 setup.py clean --all - python3 -c 'import sys; sys.path.insert(0, "/tmp/avocado_framework.egg"); from avocado.core.main import main; sys.exit(main())' run --spawner=podman --spawner-podman-image=fedora:38 --spawner-podman-avocado-egg=file:///tmp/avocado_framework.egg -- /bin/true - - podman_external_runner_task: + python3 -c 'import sys; import glob; sys.path.insert(0, glob.glob("/tmp/avocado_framework-*.egg")[0]); from avocado.core.main import main; sys.exit(main())' run /bin/true + cd /tmp + python3 -c 'import sys; from pkg_resources import require; require("avocado-framework"); from avocado.core.main import main; sys.exit(main())' run /bin/true - name: Podman spawner with 3rd party runner plugin - runs-on: ubuntu-22.04 - steps: - - name: Check out repository code - uses: actions/checkout@v3 - - name: Test running avocado from released eggs under Podman spawner with 3rd party plugins - run: | - apt update && apt -y install python3 python3-setuptools - python3 setup.py develop --user - cd examples/plugins/tests/magic - python3 setup.py develop --user - cd ../../../../ - python3 -m avocado -V list -- magic:pass magic:fail | grep "magic: 2" - podman pull quay.io/avocado-framework/avocado-ci-magic - python3 -m avocado run --spawner=podman --spawner-podman-image=quay.io/avocado-framework/avocado-ci-magic -- magic:pass - tail -n1 ~/avocado/job-results/latest/results.tap | grep "ok 1 magic:pass" - python3 -m avocado run --spawner=podman --spawner-podman-image=quay.io/avocado-framework/avocado-ci-magic -- magic:fail || true - tail -n1 ~/avocado/job-results/latest/results.tap | grep "not ok 1 magic:fail" + egg_task_debian_10: - fedora_develop_install_uninstall_task: - name: Fedora develop install/uninstall task - runs-on: ubuntu-latest + name: Egg task debian:10.10 + runs-on: ubuntu-20.04 container: - image: fedora:38 + image: debian:10.10 steps: + - name: Install Python dependencies + run: apt update && apt -y install python3 python3-setuptools - name: Check out repository code uses: actions/checkout@v3 - - name: Test avocado install/uninstall + - name: Test running avocado from eggs run: | - python3 -c 'import setuptools' || dnf -y install python3 python3-setuptools - python3 setup.py develop --user - test `python3 -m avocado plugins | grep ^html | wc -l` -eq "3" - test `python3 -m avocado plugins | grep ^robot | wc -l` -eq "2" - python3 setup.py develop --user --uninstall + python3 setup.py bdist_egg + mv dist/avocado_framework-*egg /tmp python3 setup.py clean --all - python3 setup.py develop --user --skip-optional-plugins - python3 -m avocado --version - test `python3 -m avocado plugins | grep ^html | wc -l` -eq "0" - test `python3 -m avocado plugins | grep ^robot | wc -l` -eq "0" + python3 -c 'import sys; import glob; sys.path.insert(0, glob.glob("/tmp/avocado_framework-*.egg")[0]); from avocado.core.main import main; sys.exit(main())' run /bin/true + cd /tmp + python3 -c 'import sys; from pkg_resources import require; require("avocado-framework"); from avocado.core.main import main; sys.exit(main())' run /bin/true + egg_task_debian_11: - fedora_selftests_task: - name: Fedora selftests - runs-on: ubuntu-latest + name: Egg task debian:11.0 + runs-on: ubuntu-20.04 container: - image: quay.io/avocado-framework/avocado-ci-fedora-36 + image: debian:11.0 steps: + - name: Install Python dependencies + run: apt update && apt -y install python3 python3-setuptools - name: Check out repository code uses: actions/checkout@v3 - - name: Run unittests and functional tests + - name: Test running avocado from eggs run: | - make develop - PATH=$HOME/.local/bin:$PATH LANG=en_US.UTF-8 AVOCADO_CHECK_LEVEL=0 python3 selftests/check.py --skip static-checks + python3 setup.py bdist_egg + mv dist/avocado_framework-*egg /tmp + python3 setup.py clean --all + python3 -c 'import sys; import glob; sys.path.insert(0, glob.glob("/tmp/avocado_framework-*.egg")[0]); from avocado.core.main import main; sys.exit(main())' run /bin/true + cd /tmp + python3 -c 'import sys; from pkg_resources import require; require("avocado-framework"); from avocado.core.main import main; sys.exit(main())' run /bin/true