From d15773531f6305e6c2d09acf6b7f8a2e29a763ac Mon Sep 17 00:00:00 2001 From: Matti Lamppu Date: Tue, 21 Jan 2025 13:11:22 +0200 Subject: [PATCH] Add action that updates test durations on a cron schedule --- .github/workflows/update_test_durations.yml | 74 +++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .github/workflows/update_test_durations.yml diff --git a/.github/workflows/update_test_durations.yml b/.github/workflows/update_test_durations.yml new file mode 100644 index 0000000000..e37825d345 --- /dev/null +++ b/.github/workflows/update_test_durations.yml @@ -0,0 +1,74 @@ +name: "Create a new PR to update test durations" + +on: + workflow_dispatch: + schedule: + # Run on the first day of every month + - cron: "0 0 1 * *" + +env: + POETRY_VERSION: 2.0.1 + PYTHON_VERSION: 3.13 + +jobs: + update-test-durations: + runs-on: ubuntu-latest + + services: + postgres: + image: postgis/postgis:13-3.3-alpine + env: + POSTGRES_USER: tvp + POSTGRES_PASSWORD: tvp + POSTGRES_DB: tvp + DEBUG: true + SECRET_KEY: build_secret + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 5s + --health-timeout 5s + --health-retries 10 + ports: + - 5432:5432 + + redis: + image: redis:7-alpine + # Set health checks to wait until redis has started + options: >- + --health-cmd "redis-cli ping" + --health-interval 5s + --health-timeout 5s + --health-retries 10 + ports: + - 6379:6379 + + steps: + - name: "Checkout code" + uses: actions/checkout@v4 + + - name: "Set up python" + id: setup-python + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: "Install Poetry and project dependencies" + uses: ./.github/actions/poetry + with: + poetry-version: ${{ env.POETRY_VERSION }} + python-version: ${{ steps.setup-python.outputs.python-version }} + + - name: "Run pytest with coverage" + run: poetry run pytest --disable-warnings --store-durations + env: + DJANGO_SETTINGS_ENVIRONMENT: AutomatedTests + + - name: "Create Pull Request" + uses: peter-evans/create-pull-request@v7 + with: + title: "[github-actions] Update test durations" + commit-message: "Update test durations" + branch: update-test-durations + delete-branch: true + labels: github_actions