From 88ca8768cdbcd2bdd7d41ef60bc17e41f1e39e16 Mon Sep 17 00:00:00 2001 From: chrysle Date: Fri, 19 Apr 2024 19:49:53 +0200 Subject: [PATCH 1/7] 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 | 45 +++++++++++++++++++++++++++++++++++++++ .github/workflows/nox.yml | 26 ---------------------- .python-versions-used | 3 +++ noxfile.py | 4 ++-- 4 files changed, 50 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..b1341c1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,45 @@ +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 + run: | + python -m nox --report report.json + cat report.json + python report_to_table.py + - name: Verify table has not been altered + run: | + git diff + git log 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", ".")) From 33bfbdfa84f194742399e1275114e3c4fa313631 Mon Sep 17 00:00:00 2001 From: chrysle Date: Fri, 19 Apr 2024 19:49:53 +0200 Subject: [PATCH 2/7] 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", ".")) From 0a865db889f1e964ff5dcfffa718e1b5578f2528 Mon Sep 17 00:00:00 2001 From: chrysle Date: Sat, 20 Apr 2024 07:37:18 +0200 Subject: [PATCH 3/7] Schedule workflow to monthly and update syntax --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index add6951..88d3dd2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,6 +4,8 @@ on: branches: ["master", "src-layout"] pull_request: branches: ["master", "src-layout"] + schedule: + - cron: "0 12 1 * *" permissions: contents: read @@ -43,7 +45,7 @@ jobs: - 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" + echo "DIFF_FOR_TABLE=$DIFF_FOR_TABLE" >> $GITHUB_OUTPUT id: verify-table - name: Fail the job if: ${{ steps.verify-table.outputs.DIFF_FOR_TABLE != '' }} From 49ebd067dc6b16dac39080054a6588580d900c05 Mon Sep 17 00:00:00 2001 From: chrysle Date: Sat, 20 Apr 2024 08:20:44 +0200 Subject: [PATCH 4/7] Ensure table is generated after `nox` failure --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 88d3dd2..e36ee02 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,10 +40,11 @@ jobs: 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: | + cat report.json + python report_to_table.py + git diff table.md DIFF_FOR_TABLE=$(git diff table.md) echo "DIFF_FOR_TABLE=$DIFF_FOR_TABLE" >> $GITHUB_OUTPUT id: verify-table From 5095dcd0820421b1fef10fa915ab5df83056782d Mon Sep 17 00:00:00 2001 From: chrysle Date: Sun, 28 Apr 2024 15:07:43 +0200 Subject: [PATCH 5/7] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <578543+webknjaz@users.noreply.github.com> --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e36ee02..38097ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: ${{env.PYTHON_VERSIONS}} + python-version: ${{ env.PYTHON_VERSIONS }} - name: Install dependencies run: | python -m pip install -r requirements.txt @@ -42,14 +42,15 @@ jobs: python -m nox --report report.json - name: Verify table has not been altered run: | + set -xeEuo pipefail cat report.json python report_to_table.py git diff table.md DIFF_FOR_TABLE=$(git diff table.md) echo "DIFF_FOR_TABLE=$DIFF_FOR_TABLE" >> $GITHUB_OUTPUT id: verify-table - - name: Fail the job - if: ${{ steps.verify-table.outputs.DIFF_FOR_TABLE != '' }} + - name: Fail the job if the committed table differs from the calculated one + if: steps.verify-table.outputs.DIFF_FOR_TABLE != '' run: | echo "::error file=table.md::Table has been altered but not committed!" exit 1 From eef52afe26ce299396cc5c6ce9bbf8088e85db40 Mon Sep 17 00:00:00 2001 From: chrysle Date: Mon, 29 Apr 2024 08:34:39 +0200 Subject: [PATCH 6/7] Make table diff GH output multiline --- .github/workflows/ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 38097ad..ed0c5f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,8 +46,11 @@ jobs: cat report.json python report_to_table.py git diff table.md - DIFF_FOR_TABLE=$(git diff table.md) - echo "DIFF_FOR_TABLE=$DIFF_FOR_TABLE" >> $GITHUB_OUTPUT + { + echo 'DIFF_FOR_TABLE<> $GITHUB_OUTPUT id: verify-table - name: Fail the job if the committed table differs from the calculated one if: steps.verify-table.outputs.DIFF_FOR_TABLE != '' From cfda9c94e4816c23d376ad76fcaf478e6730ff1d Mon Sep 17 00:00:00 2001 From: chrysle Date: Mon, 29 Apr 2024 17:03:08 +0200 Subject: [PATCH 7/7] Remove superfluous `git diff` invocation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit And use better syntax to append to `GITHUB_OUTPUT`. Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) --- .github/workflows/ci.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed0c5f3..09f5752 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,12 +45,9 @@ jobs: set -xeEuo pipefail cat report.json python report_to_table.py - git diff table.md - { - echo 'DIFF_FOR_TABLE<> $GITHUB_OUTPUT + echo 'DIFF_FOR_TABLE<> "${GITHUB_OUTPUT}" + git diff table.md | tee -a "${GITHUB_OUTPUT}" + echo 'EOF' >> "${GITHUB_OUTPUT}" id: verify-table - name: Fail the job if the committed table differs from the calculated one if: steps.verify-table.outputs.DIFF_FOR_TABLE != ''