diff --git a/content/pages/app-upgrade-policy.md b/content/pages/app-upgrade-policy.md index b5b01381c..c87f9c502 100644 --- a/content/pages/app-upgrade-policy.md +++ b/content/pages/app-upgrade-policy.md @@ -6,11 +6,13 @@ This policy encompasses Infra's approach to upgrades of Jenkins, Confluence and ## Jenkins ### Main Jenkins instance + _Upgrades once a quarter_ Infra follows the LTS line of releases, which the Jenkins Project releases on a 12-week cycle. Once every three months, on the last Saturday or Sunday of the month following the Jenkins LTS release, ASF Infra upgrades the main instance. ### Jenkins plugins + _Upgrade once a month_ We upgrade all plugins (there are more than 200!) before and after the main instance upgrade, as appropriate, and at the end of each month when there is no main instance upgrade to perform. @@ -18,11 +20,13 @@ We upgrade all plugins (there are more than 200!) before and after the main inst ## Jira ### Main Jira instance + _Upgrades every six months_ Jira gets a new release every two to six weeks, far too often (and unpredictable) for us to upgrade every release they make. Infra upgrades our Jira instance to whatever the latest release is every six months. ### Jira plugins + _Upgrade every two months_ We upgrade Jira plugins before or after each main instance upgrade, as appropriate, and once every two months between main instance upgrades. @@ -30,11 +34,13 @@ We upgrade Jira plugins before or after each main instance upgrade, as appropria ## Confluence ### Main Confluence instance + _Upgrades every six months_ Our goal is to upgrade Confluence to the latest version twice a year. ### Confluence plugins + _Upgrade every two months_ Every two months we perform upgrades to plugins that are compatible with the version of the main Confluence instance we are running. diff --git a/content/pages/github-actions-optimization.md b/content/pages/github-actions-optimization.md index 9be21b5e9..038bcf7fa 100644 --- a/content/pages/github-actions-optimization.md +++ b/content/pages/github-actions-optimization.md @@ -18,6 +18,7 @@ Some of these techniques are experiments that Airflow is exploring. Treat them a | [Cap open pull requests per contributor](#pr-cap) | In production | 210 PRs from 21 contributors closed in the first pass | | [Run external contributors' CI in their forks](#fork-ci) | **Experimental** | Expected to cut shared-runner use by about 40% | | [Self-hosted runners with RunsOn](#runs-on) | **Experimental** | Expected to move at least 40% of the heaviest jobs off shared runners | +| [Cancel the runs of merged pull requests](#cancel-merged) | **Proposed** | Stops runs that keep going after their pull request has merged |

Start with the basics

@@ -189,6 +190,55 @@ RunsOn offers two modes. Fleet adds a GitHub runner group restricted to selected Airflow references: AIP-118: Self-hosted runners for Apache Airflow CI and its appendix with evidence and implementation details, the AIP-119 discussion on cost guardrails, the implementation and its security review in apache/airflow#74889, and the earlier full-CI experiment in apache/airflow#74714. See also RunsOn's own documentation on security for public repositories. +

Cancel the runs of merged pull requests (proposed)

+ +**Status: proposed.** Results will be added here once it has been used in production for a while. + +Merging a pull request does not stop its `pull_request` runs. A maintainer often merges as soon as the checks they need are green, while slower jobs of the same run are still queued or running. Those jobs keep holding runners for a result nobody reads, because the change is already on its target branch. A concurrency group does not help: the merge does not start a new run in the pull request's group. + +A workflow triggered by `push` can cancel them. Merging pushes a commit to the target branch, so the workflow starts right after the merge, looks up the pull request of that commit and cancels its unfinished `pull_request` runs. A `push` run has a token that can write to the base repository, so it can also cancel the runs of pull requests from forks. Things to get right: + +- **Match runs by the head of the pull request.** The `pull_requests` field of a run is empty when the pull request comes from a fork, so filter the runs by the head commit and head repository of the merged pull request instead. +- **Only cancel runs created before the merge.** Workflows triggered by the merge itself, for example on the `closed` event, are meant to run. +- **Skip heads that an open pull request still uses.** The same commit can be the head of another pull request, for example one that targets a different branch. +- **Force-cancel what does not stop.** A job that ignores the cancellation keeps its runner. Use the force-cancel endpoint to cancel a run that continues after a normal cancel. + +A minimal version, which needs write access only to `actions`. List the branches that your pull requests merge into under `branches`: + +```yaml +name: Cancel the runs of merged pull requests +on: + push: + branches: [main] +permissions: + actions: write + contents: read + pull-requests: read +jobs: + cancel: + runs-on: ubuntu-slim + timeout-minutes: 5 + steps: + - env: + GH_TOKEN: ${{ github.token }} + REPO: ${{ github.repository }} + SHA: ${{ github.sha }} + run: | + gh api "repos/$REPO/commits/$SHA/pulls" \ + --jq '.[] | select(.merged_at != null) | [.head.repo.full_name, .head.sha, .merged_at] | @tsv' | + while IFS=$'\t' read -r head_repo head_sha merged_at; do + open=$(gh pr list -R "$REPO" --state open --search "$head_sha" --json headRefOid \ + --jq "[.[] | select(.headRefOid == \"$head_sha\")] | length") + [[ "$open" == 0 ]] || continue + for status in queued in_progress; do + gh api --paginate "repos/$REPO/actions/runs?event=pull_request&head_sha=$head_sha&status=$status" \ + --jq ".workflow_runs[] | select(.head_repository.full_name == \"$head_repo\" and .created_at < \"$merged_at\") | .id" + done | while read -r id; do + gh run cancel "$id" -R "$REPO" + done + done +``` +

Audit your workflows with Apache Magpie

Apache Magpie is a set of skills for the AI agent a maintainer already uses, built at the ASF for the work of running a project. Its repo-health skills let a PMC audit its repositories without writing anything to them: each skill reads the repository, reports what it found, and proposes changes that the maintainers decide on.