Workflow tests #268
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Workflow tests | |
# These permissions are needed to interact with GitHub's OIDC Token endpoint. | |
permissions: | |
id-token: write | |
contents: read | |
packages: write | |
actions: write | |
on: | |
workflow_dispatch: | |
inputs: | |
container-tag: | |
description: 'Container tag' | |
required: true | |
default: 'dev' | |
keep-workdirs: | |
description: 'Keep working directories for debugging' | |
required: false | |
default: 'false' | |
schedule: | |
# 01:00 every day, using last commit on default branch | |
- cron: "0 1 * * *" | |
jobs: | |
pre_job: | |
continue-on-error: true | |
runs-on: ubuntu-latest | |
# Map a step output to a job output | |
outputs: | |
should_skip: ${{ steps.skip_check.outputs.should_skip }} | |
paths_result: ${{ steps.skip_check.outputs.paths_result }} | |
steps: | |
- id: skip_check | |
uses: fkirc/skip-duplicate-actions@v5 | |
with: | |
concurrent_skipping: "same_content_newer" | |
skip_after_successful_duplicate: "true" | |
do_not_skip: '["workflow_dispatch"]' | |
paths_filter: | | |
pixelator: | |
paths: | |
- 'src/pixelator/**' | |
- 'tests/**' | |
- 'pyproject.toml' | |
- 'poetry.lock' | |
paths_ignore: | |
- 'tests/**/*.md' | |
setup: | |
runs-on: ubuntu-latest | |
needs: pre_job | |
if: needs.pre_job.outputs.should_skip == '{}' || !fromJSON(needs.pre_job.outputs.paths_result).pixelator.should_skip | |
outputs: | |
docker_username: ${{ steps.login-ecr.outputs.docker_username_890888997283_dkr_ecr_eu_north_1_amazonaws_com }} | |
docker_password: ${{ steps.login-ecr.outputs.docker_password_890888997283_dkr_ecr_eu_north_1_amazonaws_com }} | |
steps: | |
- name: Configure AWS credentials | |
id: configure-aws-credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-region: eu-north-1 | |
role-to-assume: arn:aws:iam::890888997283:role/GithubActionsRole | |
role-session-name: GitHubActions | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
with: | |
mask-password: 'false' | |
test: | |
runs-on: [ "self-hosted", "Linux", "X64" ] | |
needs: [setup] | |
container: | |
image: 890888997283.dkr.ecr.eu-north-1.amazonaws.com/pixelator:${{ github.event.inputs.container-tag || 'dev' }} | |
credentials: | |
username: ${{ needs.setup.outputs.docker_username }} | |
password: ${{ needs.setup.outputs.docker_password }} | |
volumes: | |
- /mnt/pixelgen-github-actions-data:/mnt/pixelgen-github-actions-data | |
- /mnt/pixelgen-technologies-datasets:/mnt/pixelgen-technologies-datasets | |
strategy: | |
fail-fast: false | |
matrix: | |
test: [ "test_small_D21", "test_full_D21" ] | |
steps: | |
- name: Install poetry | |
run: | | |
python -m pip install --user pipx | |
python -m pipx ensurepath | |
pipx install poetry | |
poetry self add poetry-plugin-export | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install dev dependencies | |
run: | | |
poetry export -f requirements.txt --output requirements_only_dev.txt --only dev | |
pip3 install -r requirements_only_dev.txt | |
- name: Test pixelator | |
run: | | |
CMD="pytest --log-cli-level=DEBUG" | |
if [[ "${{ github.event.inputs.keep-workdirs }}" == "true" ]]; then | |
CMD="$CMD --keep-workdirs" | |
fi | |
$CMD -m "workflow_test" -k "${{ matrix.test }}" |