From d4e51249513579705fb5b2f0361786ab518d25ed Mon Sep 17 00:00:00 2001 From: Laurens Weijs Date: Thu, 1 Aug 2024 16:02:57 +0200 Subject: [PATCH 1/4] Add 2 fixes for running with ACT --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 88f1e740..8d6fbbe5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,7 @@ concurrency: env: REGISTRY: ghcr.io POETRY_CACHE_DIR: ~/.cache/pypoetry + PIPX_BIN_DIR: /usr/local/bin IMAGE_NAME: ${{ github.repository }} PYTHON_VERSION: "3.11" @@ -123,7 +124,7 @@ jobs: poetry run alembic upgrade head - name: Run pytest - run: poetry run coverage run -m pytest + run: TZ=UTC poetry run coverage run -m pytest - name: Upload playwright tracing if: failure() From 7777b470241df8512cb1fcdacba7a9cf2d727dff Mon Sep 17 00:00:00 2001 From: Laurens Weijs Date: Tue, 20 Aug 2024 08:54:25 +0200 Subject: [PATCH 2/4] Downgrade from actions/upload-artifact@v4 to v3 as v4 is incompatible with ACT --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8d6fbbe5..368ac7e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -128,7 +128,7 @@ jobs: - name: Upload playwright tracing if: failure() - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: playwright-${{ github.sha }} path: test-results/ @@ -143,7 +143,7 @@ jobs: - name: Upload code coverage report if: matrix.python-version == '3.11' - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: codecoverage-${{ github.sha }} path: htmlcov/ From 6cf4a509f3d32b28f2c3d6e1f69488ba5c121ab7 Mon Sep 17 00:00:00 2001 From: Laurens Weijs Date: Tue, 20 Aug 2024 11:45:36 +0200 Subject: [PATCH 3/4] Run steps only when on github actions --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 368ac7e1..ebe0dd04 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -95,7 +95,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.10", "3.11", "3.12"] + python-version: ["3.10", "3.11", "3.12"] # When using ACT only use ["3.11"] steps: - uses: actions/checkout@v4 @@ -154,7 +154,7 @@ jobs: run: poetry run coverage xml - name: SonarCloud Scan - if: matrix.python-version == '3.11' && github.actor != 'dependabot[bot]' + if: matrix.python-version == '3.11' && github.actor != 'dependabot[bot]' && !env.ACT uses: SonarSource/sonarcloud-github-action@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any @@ -315,7 +315,7 @@ jobs: notifyMattermost: runs-on: ubuntu-latest needs: [lint, security, test-local, test-compose, build ] - if: ${{ always() && contains(needs.*.result, 'failure') }} + if: ${{ always() && contains(needs.*.result, 'failure') && !env.ACT}} steps: - uses: mattermost/action-mattermost-notify@master if: github.event_name != 'pull_request' || github.event.pull_request.draft == false From 2003e935163687cc7533468c13089186adaaf9d9 Mon Sep 17 00:00:00 2001 From: Laurens Weijs Date: Tue, 20 Aug 2024 12:01:45 +0200 Subject: [PATCH 4/4] Ignore certain jobs also when running act + add README --- .github/workflows/ci.yml | 9 +++++---- README.md | 8 ++++++++ act_event.json | 3 +++ 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 act_event.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ebe0dd04..be5309b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: - name: Install poetry run: pipx install poetry - - name: Set up Python ${{ env.python-version }} + - name: Set up Python ${{ env.PYTHON_VERSION }} uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_VERSION }} @@ -56,7 +56,7 @@ jobs: - name: Install poetry run: pipx install poetry - - name: Set up Python ${{ env.python-version }} + - name: Set up Python ${{ env.PYTHON_VERSION }} uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_VERSION }} @@ -163,6 +163,7 @@ jobs: build: needs: [test-local, test-compose] + if: ${{ !github.event.act }} runs-on: ubuntu-latest permissions: packages: write @@ -287,7 +288,7 @@ jobs: deploy: runs-on: ubuntu-latest needs: [build] - if: ${{ github.event_name == 'push' }} + if: ${{ github.event_name == 'push' && !github.event.act}} permissions: actions: write steps: @@ -315,7 +316,7 @@ jobs: notifyMattermost: runs-on: ubuntu-latest needs: [lint, security, test-local, test-compose, build ] - if: ${{ always() && contains(needs.*.result, 'failure') && !env.ACT}} + if: ${{ always() && contains(needs.*.result, 'failure') && !github.event.act}} steps: - uses: mattermost/action-mattermost-notify@master if: github.event_name != 'pull_request' || github.event.pull_request.draft == false diff --git a/README.md b/README.md index 8d5b634a..441b8247 100644 --- a/README.md +++ b/README.md @@ -30,3 +30,11 @@ An example command: ```shell ./check-state urn:nl:aivt:ir:td:1.0 urn:nl:aivt:ir:iama:1.0 example/system_test_card.yaml ``` + +### For developers + +When running the GitHub actions locally you can use [act](https://github.com/nektos/act), to do this run change the +matrix in the `ci.yml` of the `test-local` job to have only python version 3.11. Then run the following command: +```shell +act -W '.github/workflows/ci.yml' -s GITHUB_TOKEN="$(gh auth token)" --artifact-server-path tmp/artifacts -e act_event.json +``` diff --git a/act_event.json b/act_event.json new file mode 100644 index 00000000..43c2f0eb --- /dev/null +++ b/act_event.json @@ -0,0 +1,3 @@ +{ + "act": true +}