Merge pull request #1055 from opengisch/fix-gh-build-and-push #5091
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: Test | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
push: | |
branches: | |
- master | |
- release | |
pull_request: | |
jobs: | |
lint: | |
if: '! github.event.pull_request.draft' | |
name: Lint code base | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Pre-commit | |
uses: pre-commit/action@v3.0.1 | |
test: | |
name: Run tests | |
runs-on: ubuntu-24.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
django_app: | |
- authentication | |
- notifs | |
- subscription | |
- core | |
- __flaky__ | |
continue-on-error: true | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Check env vars configuration | |
run: | | |
scripts/check_envvars.sh | |
- name: Export the env variables file | |
run: | | |
cp .env.example .env | |
sed -ri 's/^COMPOSE_FILE=(.*)/COMPOSE_FILE=\1:docker-compose.override.test.yml/g' .env | |
eval $(egrep "^[^#;]" .env | xargs -d'\n' -n1 | sed -E 's/(\w+)=(.*)/export \1='"'"'\2'"'"'/g') | |
- name: Pull docker containers | |
run: docker compose pull | |
- name: Build and run docker containers | |
run: | | |
docker compose up -d --build | |
- name: Initial manage.py commands | |
run: | | |
docker compose run app python manage.py makemigrations --no-input --check | |
docker compose run app python manage.py migrate | |
docker compose run app python manage.py collectstatic | |
- name: Run mandatory unit and integration tests | |
if: matrix.django_app != '__flaky__' | |
run: | | |
docker compose run app python manage.py test --keepdb -v2 --exclude-tag="flaky" qfieldcloud.${{ matrix.django_app }} | |
- name: Run flaky unit and integration tests | |
if: matrix.django_app == '__flaky__' | |
run: | | |
docker compose run app python manage.py test --keepdb -v2 --tag="flaky" qfieldcloud | |
- name: "failure logs" | |
if: failure() | |
run: | | |
docker compose logs | |
- name: Post Google Chat message on failure | |
if: failure() && matrix.django_app != '__flaky__' | |
uses: julb/action-post-googlechat-message@v1 | |
with: | |
message: | | |
Failed job run for branch `${{ github.head_ref || github.ref_name }}`, check ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} . | |
gchat_webhook_url: ${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }} | |
# - name: Setup tmate session | |
# if: ${{ failure() }} | |
# uses: mxschmitt/action-tmate@v3 | |
# timeout-minutes: 30 | |
# with: | |
# limit-access-to-actor: true |