From 4e7de9d346e65438efcc577b1457f10058f8c737 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Fri, 5 Jul 2024 13:23:09 -0700 Subject: [PATCH 1/2] Update GitHub Actions settings from the template Use an environment variable for the default Python version with which to run most actions. Add timeouts to jobs that were missing them. Use the tox-uv plugin uniformly. Fix one place where merge queues weren't handled correctly. --- .github/workflows/ci.yaml | 25 ++++++++++++++++++------- .github/workflows/periodic-ci.yaml | 15 ++++++++++++--- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5cbc5a7d..8f4765af 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,5 +1,11 @@ name: Python CI +env: + # Default Python version used for all jobs other than test, which uses a + # matrix of supported versions. Quote the version to avoid interpretation as + # a floating point number. + PYTHON_VERSION: "3.12" + "on": merge_group: {} pull_request: {} @@ -17,17 +23,18 @@ name: Python CI types: [published] jobs: - lint: runs-on: ubuntu-latest + timeout-minutes: 5 + steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: ${{ env.PYTHON_VERSION }} - name: Run pre-commit uses: pre-commit/action@v3.0.1 @@ -35,6 +42,7 @@ jobs: test: runs-on: ubuntu-latest + timeout-minutes: 10 strategy: matrix: @@ -50,11 +58,12 @@ jobs: with: python-version: ${{ matrix.python }} tox-envs: "py,typing" - tox-plugins: "tox-docker" + tox-plugins: "tox-docker tox-uv" docs: runs-on: ubuntu-latest + timeout-minutes: 10 steps: - uses: actions/checkout@v4 @@ -69,6 +78,7 @@ jobs: with: python-version: "3.12" tox-envs: "docs,docs-linkcheck" + tox-plugins: tox-uv # Only attempt documentation uploads for tagged releases and pull # requests from ticket branches in the same repository. This avoids @@ -82,8 +92,9 @@ jobs: username: ${{ secrets.LTD_USERNAME }} password: ${{ secrets.LTD_PASSWORD }} if: > - github.event_name != 'pull_request' - || startsWith(github.head_ref, 'tickets/') + github.event_name != 'merge_group' + && (github.event_name != 'pull_request' + || startsWith(github.head_ref, 'tickets/')) test-packaging: @@ -100,7 +111,7 @@ jobs: - name: Build and publish uses: lsst-sqre/build-and-publish-to-pypi@v2 with: - python-version: "3.12" + python-version: ${{ env.PYTHON_VERSION }} upload: false pypi: @@ -123,4 +134,4 @@ jobs: - uses: lsst-sqre/build-and-publish-to-pypi@v2 with: - python-version: "3.12" + python-version: ${{ env.PYTHON_VERSION }} diff --git a/.github/workflows/periodic-ci.yaml b/.github/workflows/periodic-ci.yaml index b7de5fac..d2e2dd83 100644 --- a/.github/workflows/periodic-ci.yaml +++ b/.github/workflows/periodic-ci.yaml @@ -5,6 +5,12 @@ name: Periodic CI +env: + # Default Python version used for all jobs other than test, which uses a + # matrix of supported versions. Quote the version to avoid interpretation as + # a floating point number. + PYTHON_VERSION: "3.12" + "on": schedule: - cron: "0 12 * * 1" @@ -13,6 +19,7 @@ name: Periodic CI jobs: test: runs-on: ubuntu-latest + timeout-minutes: 10 strategy: matrix: @@ -28,7 +35,7 @@ jobs: with: python-version: ${{ matrix.python }} tox-envs: "lint,typing,py" - tox-plugins: "tox-docker" + tox-plugins: "tox-docker tox-uv" use-cache: false - name: Report status @@ -43,6 +50,7 @@ jobs: docs: runs-on: ubuntu-latest + timeout-minutes: 10 steps: - uses: actions/checkout@v4 @@ -53,8 +61,9 @@ jobs: - name: Build docs in tox uses: lsst-sqre/run-tox@v1 with: - python-version: "3.12" + python-version: ${{ env.PYTHON_VERSION }} tox-envs: "docs,docs-linkcheck" + tox-plugins: tox-uv use-cache: false - name: Report status @@ -80,7 +89,7 @@ jobs: - name: Build and publish uses: lsst-sqre/build-and-publish-to-pypi@v2 with: - python-version: "3.12" + python-version: ${{ env.PYTHON_VERSION }} upload: false - name: Report status From a415caea895afb4f68dcf441802b96f156b3f5bb Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Fri, 5 Jul 2024 16:37:31 -0700 Subject: [PATCH 2/2] Update periodic CI notification configuration Include proposed template updates to the periodic CI notification configuration: use a better if trigger, and update the notification titles to be a bit more accurate. --- .github/workflows/periodic-ci.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/periodic-ci.yaml b/.github/workflows/periodic-ci.yaml index d2e2dd83..3d8e0e4b 100644 --- a/.github/workflows/periodic-ci.yaml +++ b/.github/workflows/periodic-ci.yaml @@ -39,7 +39,7 @@ jobs: use-cache: false - name: Report status - if: always() + if: failure() uses: ravsamhq/notify-slack-action@v2 with: status: ${{ job.status }} @@ -67,12 +67,12 @@ jobs: use-cache: false - name: Report status - if: always() + if: failure() uses: ravsamhq/notify-slack-action@v2 with: status: ${{ job.status }} notify_when: "failure" - notification_title: "Periodic documentation build for {repo} failed" + notification_title: "Periodic documentation test for {repo} failed" env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_ALERT_WEBHOOK }} @@ -93,11 +93,11 @@ jobs: upload: false - name: Report status - if: always() + if: failure() uses: ravsamhq/notify-slack-action@v2 with: status: ${{ job.status }} notify_when: "failure" - notification_title: "Periodic PyPI test for {repo} failed" + notification_title: "Periodic packaging test for {repo} failed" env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_ALERT_WEBHOOK }}