Python Canary Cron #138
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: Python Canary Cron | |
on: | |
schedule: | |
- cron: "0 18 * * 1-5" | |
workflow_dispatch: | |
jobs: | |
find-tox-testenv: | |
name: Find tox testenv | |
runs-on: ubuntu-latest | |
outputs: | |
list: ${{ steps.testenv.outputs.list }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
sparse-checkout: python | |
- uses: astral-sh/setup-uv@v5 | |
with: | |
version: 0.5.27 | |
enable-cache: false | |
- name: Extract testenv into JSON list | |
run: >- | |
echo "list=$(uvx --with tox-uv tox -l | |
| egrep -e '-latest$' | |
| jq -R -s -c 'split("\n")[:-1]')" | |
>> $GITHUB_OUTPUT | |
working-directory: python | |
id: testenv | |
canary: | |
name: ${{ matrix.testenv }} | |
needs: find-tox-testenv | |
if: ${{ needs.find-tox-testenv.outputs.list != '[]' }} | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
strategy: | |
fail-fast: false | |
matrix: | |
testenv: ${{ fromJSON(needs.find-tox-testenv.outputs.list) }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
sparse-checkout: python | |
- uses: astral-sh/setup-uv@v5 | |
with: | |
version: 0.5.27 | |
enable-cache: false | |
- run: uvx --with tox-uv tox r -e ${{ matrix.testenv }} -- -ra -x | |
working-directory: python | |
- run: touch ${{ runner.temp }}/${{ matrix.testenv }} | |
if: failure() | |
- uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: ${{ matrix.testenv }} | |
path: ${{ runner.temp }}/${{ matrix.testenv }} | |
retention-days: 1 | |
slack: | |
name: Slack notification | |
needs: canary | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
- name: List failures as markdown | |
run: | | |
{ | |
echo "list<<EOF" | |
find . -maxdepth 1 -type d ! -name '.' | sed 's|^\./||' | rev | sort -u | rev | nl -w2 -s'. ' | |
echo "EOF" | |
} >> "$GITHUB_OUTPUT" | |
id: failures | |
- name: Create message text | |
if: ${{ steps.failures.outputs.list != '' }} | |
run: | | |
{ | |
echo "text<<EOF" | |
echo "CI Failures for Python Packages:" | |
echo "${{ steps.failures.outputs.list }}" | |
echo "EOF" | |
} >> "$GITHUB_OUTPUT" | |
id: message | |
- name: Send message to Slack | |
if: ${{ steps.failures.outputs.list != '' }} | |
uses: slackapi/slack-github-action@v1 | |
with: | |
payload: | | |
{ | |
"type": "mrkdwn", | |
"text": ${{ toJSON(steps.message.outputs.text) }} | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |