Repository navigation
73 lines (69 loc) · 2.95 KB
/
Copy pathcontributor-ci.yml
File metadata and controls
73 lines (69 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Contributor CI
# CI from pull requests opened from forks goes second (scripts/contributor-ci.ts). When a job of
# CopilotKit's own has waited more than three minutes for a runner, the fork runs in progress or
# queued are cancelled, with a comment on each pull request; once nothing of CopilotKit's is
# waiting, they are re-run one at a time. Nothing here checks out or runs a pull request's code:
# it reads and acts on runs through the API only. On workflow_run the checkout is the default
# branch, never the run's head.
#
# It looks when a run of CI or Desktop is requested (a job may soon be waiting for a runner, so it
# watches for a few minutes while a contributor run is active) and when one completes (runners are
# free, so a paused run can go again). The schedule is a slow fallback for a missed event.
on:
workflow_run:
workflows: [CI, Desktop]
types: [requested, completed]
schedule:
# Off the top of the hour, when scheduled runs are most often delayed.
- cron: "7,22,37,52 * * * *"
workflow_dispatch:
inputs:
dry_run:
description: Say what would be paused or re-run, and do nothing.
type: boolean
default: true
permissions:
contents: read
concurrency:
group: contributor-ci
cancel-in-progress: false
jobs:
yield:
name: make way for CopilotKit's runs
# A contributor's run being requested never makes the team wait, so it needs no look.
if: >-
github.event_name != 'workflow_run' ||
github.event.action == 'completed' ||
github.event.workflow_run.head_repository.full_name == github.repository
# A standard runner: it calls the API for a few seconds. On the 16-core pool it queued
# behind the very backlog it exists to make way for. Its own job never counts as the team
# waiting: it is in progress while it looks, and the next one is pending with no job.
runs-on: ubuntu-latest
timeout-minutes: 8
permissions:
contents: read
# To cancel and re-run contributors' runs.
actions: write
# To say so on the pull request.
pull-requests: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
sparse-checkout: scripts/contributor-ci.ts
sparse-checkout-cone-mode: false
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: 1.4.3
no-cache: true
- name: Pause or resume contributor CI
env:
GH_TOKEN: ${{ github.token }}
DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run }}
WATCH: ${{ github.event_name == 'workflow_run' && github.event.action == 'requested' }}
run: |
set -euo pipefail
args=()
if [ "$DRY_RUN" = true ]; then args+=(--dry-run); fi
if [ "$WATCH" = true ]; then args+=(--watch); fi
bun scripts/contributor-ci.ts "${args[@]}"