diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 9483cee..bcc69ff 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,6 +8,8 @@ updates: # GitHub Actions - package-ecosystem: "github-actions" directory: "/" + cooldown: + default-days: 7 schedule: interval: "weekly" groups: @@ -17,6 +19,8 @@ updates: # Python - package-ecosystem: "pip" # See documentation for possible values directory: "/" # Location of package manifests + cooldown: + default-days: 7 schedule: interval: "weekly" groups: diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml new file mode 100644 index 0000000..034f0e3 --- /dev/null +++ b/.github/workflows/automerge.yml @@ -0,0 +1,36 @@ +name: Dependabot auto-merge + +# API calls only. Do not check out the PR or run code or artifacts from it. +on: + pull_request_target: # zizmor: ignore[dangerous-triggers] -- no PR code runs with write access. + branches: [develop] + types: [opened, reopened, synchronize, ready_for_review] + +permissions: {} + +jobs: + automerge: + if: >- + github.event.pull_request.user.login == 'dependabot[bot]' && + github.event.pull_request.head.repo.full_name == github.repository && + !github.event.pull_request.draft && + vars.DEPENDABOT_AUTOMERGE == 'true' + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + env: + GH_TOKEN: ${{ github.token }} + PR: ${{ github.event.pull_request.number }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + steps: + - name: Enable auto-merge for signed Dependabot commits + run: | + commits=$(gh api --paginate --slurp "repos/$GITHUB_REPOSITORY/pulls/$PR/commits?per_page=100") + if ! jq -e --arg head "$HEAD_SHA" 'flatten | length > 0 and last.sha == $head and + all(.[]; .author.login == "dependabot[bot]" and .commit.verification.verified == true)' \ + <<< "$commits" > /dev/null; then + echo 'Not a verified Dependabot head; leaving this PR for manual review.' + exit 0 + fi + gh pr merge "$PR" --repo "$GITHUB_REPOSITORY" --auto --squash --match-head-commit "$HEAD_SHA" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7e29efb..4dfa61f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -61,12 +61,12 @@ jobs: - name: Test run: bash scripts/test.sh env: - COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.pydantic-version }} - CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.pydantic-version }} + COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }} + CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }} - name: Store coverage files uses: actions/upload-artifact@v7 with: - name: .coverage.${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.pydantic-version }} + name: .coverage.${{ runner.os }}-py${{ matrix.python-version }} path: coverage if-no-files-found: error include-hidden-files: true @@ -109,10 +109,12 @@ jobs: include-hidden-files: true # https://github.com/marketplace/actions/alls-green#why - check: # This job does nothing and is only used for the branch protection - if: github.event.pull_request.draft == false + check: # Aggregate required status for branch protection, including failed prerequisites. + if: always() && github.event.pull_request.draft == false needs: + - static_analysis + - test - coverage-combine runs-on: ubuntu-latest