Skip to content

[pre-commit.ci] pre-commit autoupdate #1812

[pre-commit.ci] pre-commit autoupdate

[pre-commit.ci] pre-commit autoupdate #1812

Workflow file for this run

---
name: tox
on:
merge_group:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: "0 0 * * *"
workflow_call:
concurrency:
group: >
${{ github.workflow }}-
${{ github.event_name }}-
${{ github.event.pull_request.number }}-
${{ github.sha }}
cancel-in-progress: true
env:
FORCE_COLOR: 1 # tox, pytest, ansible-lint
PY_COLORS: 1
jobs:
prepare:
name: prepare
runs-on: ubuntu-24.04
permissions:
checks: read
outputs:
matrix: ${{ steps.generate_matrix.outputs.matrix }}
steps:
# - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
# with:
# fetch-depth: 0 # needed by setuptools-scm
# ref: ${{ github.ref }} # ensures you have the branch, not detached (needed by gh cli)
# submodules: true
- name: Determine matrix
id: generate_matrix
uses: coactions/dynamic-matrix@adb35c02b55e67564ae7feebfcbc3358d8d02900 # v4
with:
min_python: "3.10"
default_python: |
3.10
max_python: "3.13"
other_names: |
lint:tox -e py310-lint;tox -e py310-lint
docs
integration
pkg
lower
devel
platforms: linux,macos
# https://github.com/orgs/community/discussions/16059
- name: Wait for ack workflow to pass
id: wait
# cspell: ignore smartcontractkit chainlink
uses: smartcontractkit/chainlink-github-actions/utils/wait-for-workflows@1ada5d85b0de3439a0ba238210d40605b5ed6704 # v2.3.32
with:
max-timeout: "240"
polling-interval: "15"
github-token: ${{ secrets.GITHUB_TOKEN }}
env:
DEBUG: "true"
- name: Wait for required GitHub Checks to pass
if: github.event_name == 'pull_request'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
#!/usr/bin/env bash
set -euo pipefail
TIMEOUT=120
INTERVAL=10
CHECK_NAME="pre-commit"
MAX_RETRIES=$((TIMEOUT / INTERVAL))
for ((i=1; i<=MAX_RETRIES; i++)); do
# https://docs.github.com/en/graphql/reference/enums#checkrunstate
lines=()
while IFS= read -r line; do
lines+=("$line")
done < <(gh pr checks --repo ${{ github.repository }} --required --json name,state,link --jq ".[] | select(.name | test(\"^${CHECK_NAME}\")) | .state,.link" ${{ github.event.pull_request.number || github.ref_name }} || true)
state=${lines[0]-}
link=${lines[1]-}
if [[ "$state" == "SUCCESS" ]]; then
exit 0
elif [[ "$state" =~ ^(TIME_OUT|FAILURE|ERROR|STALE|SKIPPED|CANCELLED)$ ]]; then
echo "::error title=Check ${CHECK_NAME}::Check ${CHECK_NAME} failed due to reporting ${state} ${link}"
exit 1
fi
# Other known values: QUEUED, PENDING
echo "::debug title=Check ${CHECK_NAME}::Attempt ${i}/${MAX_RETRIES}: ack state='${state}' (waiting ${INTERVAL}s)..."
sleep "${INTERVAL}"
done
echo "::error title=Check ${CHECK_NAME}::Check ${CHECK_NAME} did not reach SUCCESS within ${TIMEOUT}s. Last state: ${state} ${link}"
exit 1
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os || 'ubuntu-24.04' }}
needs:
- prepare
defaults:
run:
shell: ${{ matrix.shell || 'bash'}}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.prepare.outputs.matrix) }}
env:
# Number of expected test passes, safety measure for accidental skip of
# tests. Update value if you add/remove tests.
PYTEST_REQPASS: 8
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
with:
fetch-depth: 0 # needed by setuptools-scm
submodules: true
- name: Install system dependencies
if: ${{ !contains(matrix.name, 'macos') }}
run: |
sudo apt-get update \
&& sudo apt-get install -y libvirt-dev zsh
- name: Install mise
uses: jdx/mise-action@5ac50f778e26fac95da98d50503682459e86d566 # v3
- name: Set up Python ${{ matrix.python_version || '3.10' }}
if: "!contains(matrix.shell, 'wsl')"
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
cache: pip
python-version: ${{ matrix.python_version || '3.10' }}
- name: Install tox
run: |
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade "tox>=4.0.0" "tox-uv>=1.25.0" "uv>=0.6.6"
- name: Log installed dists
run: python3 -m pip freeze --all
- run: ${{ matrix.command }}
- run: ${{ matrix.command2 }}
if: ${{ matrix.command2 }}
- run: ${{ matrix.command3 }}
if: ${{ matrix.command3 }}
- run: ${{ matrix.command4 }}
if: ${{ matrix.command4 }}
- run: ${{ matrix.command5 }}
if: ${{ matrix.command5 }}
- name: Archive logs
uses: coactions/upload-artifact@ec1957e16e4ecd304d3a115907ccb4ba5f636e9d # v4
with:
name: logs-${{ matrix.name }}.zip
include-hidden-files: true
if-no-files-found: ignore
path: |
.tox/**/.coverage*
.tox/**/coverage.xml
.tox/**/log
- name: Report failure if git reports dirty status
run: |
if [[ -n $(git status -s) ]]; then
# shellcheck disable=SC2016
echo -n '::error file=git-status::'
printf '### Failed as git reported modified and/or untracked files\n```\n%s\n```\n' "$(git status -s)" | tee -a "$GITHUB_STEP_SUMMARY"
exit 99
fi
# https://github.com/actions/toolkit/issues/193
check: # This job does nothing and is only used for the branch protection
if: always()
permissions:
checks: read # codecov-action
id-token: write # codecov-action
pull-requests: write # allow codenotify to comment on pull-request
needs:
- build
runs-on: ubuntu-latest
steps:
# checkout needed for codecov action which needs codecov.yml file
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- name: Set up Python # likely needed for coverage
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.13"
- run: pip3 install 'coverage>=7.5.1'
if: ${{ needs.build.result != 'skipped' }}
- name: Merge logs into a single archive
if: ${{ needs.build.result != 'skipped' }}
uses: actions/upload-artifact/merge@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: logs.zip
include-hidden-files: true
pattern: logs-*.zip
# artifacts like py312.zip and py312-macos do have overlapping files
separate-directories: true
- name: Download artifacts
if: ${{ needs.build.result != 'skipped' }}
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5
continue-on-error: true # to allow rerunning this job
with:
name: logs.zip
path: .
- name: Upload coverage data
if: ${{ needs.build.result != 'skipped' }}
uses: codecov/codecov-action@fdcc8476540edceab3de004e990f80d881c6cc00 # v5
with:
name: ${{ matrix.name }}
# verbose: true # optional (default = false)
fail_ci_if_error: true
use_oidc: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }} # cspell:ignore oidc
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
- name: Delete Merged Artifacts
uses: actions/upload-artifact/merge@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
include-hidden-files: true
delete-merged: true
pattern: logs-*.zip