From 33bfbdfa84f194742399e1275114e3c4fa313631 Mon Sep 17 00:00:00 2001 From: chrysle Date: Fri, 19 Apr 2024 19:49:53 +0200 Subject: [PATCH] CI: Check for uncommitted table alteration Before, the checks would always indicate a failure, although the scenarios are not intended to succeed. Now, they will only fail on an unchanged `table.md` despite a different outcome in the scenario run. Co-authored-by: Anderson Bravalheri <320755+abravalheri@users.noreply.github.com> --- .github/workflows/ci.yml | 52 +++++++++++++++++++++++++++++++++++++++ .github/workflows/nox.yml | 26 -------------------- .python-versions-used | 3 +++ noxfile.py | 4 +-- 4 files changed, 57 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/nox.yml create mode 100644 .python-versions-used diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..add6951 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,52 @@ +name: CI +on: + push: + branches: ["master", "src-layout"] + pull_request: + branches: ["master", "src-layout"] + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: true + +jobs: + generate-compatibility-matrix: + name: >- + Check for any uncommitted + table alteration + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Determine Python versions + run: | + { + echo 'PYTHON_VERSIONS<> $GITHUB_ENV + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{env.PYTHON_VERSIONS}} + - name: Install dependencies + run: | + python -m pip install -r requirements.txt + - name: Generate compatibility matrix with nox + continue-on-error: true + run: | + python -m nox --report report.json + cat report.json + python report_to_table.py + - name: Verify table has not been altered + run: | + DIFF_FOR_TABLE=$(git diff table.md) + echo "::set-output name=DIFF_FOR_TABLE::$DIFF_FOR_TABLE" + id: verify-table + - name: Fail the job + if: ${{ steps.verify-table.outputs.DIFF_FOR_TABLE != '' }} + run: | + echo "::error file=table.md::Table has been altered but not committed!" + exit 1 diff --git a/.github/workflows/nox.yml b/.github/workflows/nox.yml deleted file mode 100644 index 8b6102d..0000000 --- a/.github/workflows/nox.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: nox -on: [push, pull_request] - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} - cancel-in-progress: true - -jobs: - nox: - strategy: - fail-fast: false - max-parallel: 3 - matrix: - os: [ubuntu-latest] # [macos-latest, ubuntu-latest, windows-latest] - python: ['3.8', '3.10', '3.12'] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - - run: python3 --version && python --version - - run: pip install -r requirements.txt pytest - - run: pytest . || true # See pytest's warnings - - run: nox --python ${{ matrix.python }} - # - run: nox --python ${{ matrix.python }} --report report.json && python report_to_table.py diff --git a/.python-versions-used b/.python-versions-used new file mode 100644 index 0000000..64aea5c --- /dev/null +++ b/.python-versions-used @@ -0,0 +1,3 @@ +3.8 +3.10 +3.12 diff --git a/noxfile.py b/noxfile.py index 5163b8d..8a791ed 100644 --- a/noxfile.py +++ b/noxfile.py @@ -19,10 +19,10 @@ # -- REQUIRES: nox >= 2023.04.22 # SEE: https://nox.thea.codes/en/stable/index.html -USE_PYTHON_VERSIONS_DEFAULT = ["3.8", "3.10", "3.12"] USE_PYTHON_VERSIONS = os.environ.get("NOXFILE_PYTHON_VERSIONS", "").split() if not USE_PYTHON_VERSIONS: - USE_PYTHON_VERSIONS = USE_PYTHON_VERSIONS_DEFAULT + with open(os.path.join(HERE, ".python-versions-used"), "r") as file: + USE_PYTHON_VERSIONS = [x.strip() for x in file] install_commands = (("pip", "install", "."), ("pip", "install", "-e", "."))