forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 1
58 lines (56 loc) · 2.52 KB
/
Copy pathgraphite_ci_optimizer.yml
File metadata and controls
58 lines (56 loc) · 2.52 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
# Avoid running the full CI on mid-stack PRs: https://graphite.dev/docs/stacking-and-ci
#
# We still run some high-signal low-cost jobs (e.g. lint, unit tests) on these mid-stack PRs, just
# not anything slow (e.g. integration tests).
#
# Because we don't use Graphite's CI batching, full CI will still run on every PR individually
# before it merges. The goal is just to avoid wasting CI capacity when frequently rebasing large
# stacks.
#
# This can by bypassed by labeling a PR with 'CI Bypass Graphite Optimization', and manually
# re-running CI.
name: Graphite CI Optimizer
on:
workflow_call:
outputs:
skip:
description: "'true' if expensive CI checks should be skipped, 'false' otherwise."
value: ${{ jobs.optimize-ci.outputs.skip }}
secrets:
GRAPHITE_CI_OPTIMIZER_TOKEN:
description: 'The Graphite CI optimization secret'
# secrets are not available in forks, check-skip will just fail-open with a warning
required: false
env:
# FYI, if you add this label, you must *push* to the repository again to trigger a new event. Just
# re-running in the GitHub actions UI won't work, as it will re-use the old event with the old
# labels.
HAS_BYPASS_LABEL: |-
${{
github.event_name == 'pull_request' &&
contains(github.event.pull_request.labels.*.name, 'CI Bypass Graphite Optimization')
}}
jobs:
optimize-ci:
name: Graphite CI Optimizer
runs-on: ubuntu-latest
outputs:
# `== 'true'` comparison: If `step.check-skip` fails (`continue-on-error`), that output will
# be an empty string, which sets our `skip` output to `'false'`.
skip: ${{ env.HAS_BYPASS_LABEL == 'false' && steps.check-skip.outputs.skip == 'true' }}
steps:
- name: Optimize CI
id: check-skip
# Graphite's action is designed to fail open, but still sometimes fails if GH's infra flakes
continue-on-error: true
uses: withgraphite/graphite-ci-action@ee395f3a78254c006d11339669c6cabddf196f72 # main
with:
graphite_token: ${{ secrets.GRAPHITE_CI_OPTIMIZER_TOKEN }}
- name: Debug Output
run: |
echo 'github.event_name: ${{ github.event_name }}'
echo "secrets.GRAPHITE_CI_OPTIMIZER_TOKEN != '': ${GRAPHITE_CI_OPTIMIZER_TOKEN_NON_EMPTY}"
echo 'env.HAS_BYPASS_LABEL: ${{ env.HAS_BYPASS_LABEL }}'
echo 'steps.check-skip.outputs.skip: ${{ steps.check-skip.outputs.skip }}'
env:
GRAPHITE_CI_OPTIMIZER_TOKEN_NON_EMPTY: ${{ secrets.GRAPHITE_CI_OPTIMIZER_TOKEN != '' }}