Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change ci.yml in order to be able to run it with act locally #144

Merged
merged 4 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -29,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 }}
Expand All @@ -55,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 }}
Expand Down Expand Up @@ -94,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
Expand Down Expand Up @@ -123,11 +124,11 @@ 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()
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3
with:
name: playwright-${{ github.sha }}
path: test-results/
Expand All @@ -142,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/
Expand All @@ -153,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
Expand All @@ -162,6 +163,7 @@ jobs:

build:
needs: [test-local, test-compose]
if: ${{ !github.event.act }}
runs-on: ubuntu-latest
permissions:
packages: write
Expand Down Expand Up @@ -286,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:
Expand Down Expand Up @@ -314,7 +316,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') && !github.event.act}}
steps:
- uses: mattermost/action-mattermost-notify@master
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
3 changes: 3 additions & 0 deletions act_event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"act": true
}
Loading