Run linting and tests #509
This file contains hidden or 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: lint-and-test | |
| run-name: Run linting and tests | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| branches: | |
| - master | |
| jobs: | |
| linting: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Get USER_ID to env | |
| run: echo "USER_ID=$(id -u)" >> $GITHUB_ENV | |
| - name: Get GROUP_ID to env | |
| run: echo "GROUP_ID=$(id -g)" >> $GITHUB_ENV | |
| - name: Login to Docker Registry, bake/cache | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - run: docker buildx bake --file src/docker/testing-bake.yml --file src/docker/docker-compose-gha-cache.json | |
| - run: | | |
| docker compose --env-file src/docker/.compose.testing.env \ | |
| -f src/docker/docker-compose-testing.yml run web pylint \ | |
| -E --disable E1101,E0307 --ignore-paths \ | |
| '.*\/migrations\/[0-9]+.*.py' analysis datasets dashboard home jobs kantele rawstatus | |
| integration-tests: | |
| runs-on: ubuntu-latest | |
| needs: linting | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Get USER_ID to env | |
| run: echo "USER_ID=$(id -u)" >> $GITHUB_ENV | |
| - name: Get GROUP_ID to env | |
| run: echo "GROUP_ID=$(id -g)" >> $GITHUB_ENV | |
| - name: Login to Docker Registry to get bake cache | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - run: docker buildx bake --file src/docker/testing-bake.yml --file src/docker/docker-compose-gha-cache.json | |
| - name: Init test fixture "workflow repo" | |
| run: | | |
| git init | |
| git config user.name 'Fake GHA' | |
| git config user.email 'fakegha@' | |
| git add *.py | |
| git commit -m 'test fixtures' | |
| working-directory: data/test/nfrepo | |
| - run: | | |
| docker compose --env-file src/docker/.compose.testing.env -f src/docker/docker-compose-testing.yml \ | |
| up --detach db mq | |
| sleep 5 # DB needs to be up or app crashes trying to connect | |
| docker compose --env-file src/docker/.compose.testing.env -f src/docker/docker-compose-testing.yml \ | |
| run --use-aliases web python manage.py test --tag slow --exclude-tag mstulos | |
| unit-tests: | |
| runs-on: ubuntu-latest | |
| needs: linting | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Get USER_ID to env | |
| run: echo "USER_ID=$(id -u)" >> $GITHUB_ENV | |
| - name: Get GROUP_ID to env | |
| run: echo "GROUP_ID=$(id -g)" >> $GITHUB_ENV | |
| - name: Login to Docker Registry to get bake cache | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - run: docker buildx bake --file src/docker/testing-bake.yml --file src/docker/docker-compose-gha-cache.json | |
| - run: | | |
| docker compose --env-file src/docker/.compose.testing.env -f src/docker/docker-compose-testing.yml \ | |
| up --detach db mq | |
| sleep 5 # DB needs to be up or app crashes trying to connect | |
| docker compose --env-file src/docker/.compose.testing.env -f src/docker/docker-compose-testing.yml \ | |
| run --use-aliases web python manage.py test --exclude-tag slow |