-
Notifications
You must be signed in to change notification settings - Fork 18
93 lines (76 loc) · 3.04 KB
/
ci.yml
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: PR CI
on:
pull_request:
branches: [main]
jobs:
CI:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "18"
- name: Get yarn cache
id: yarn-cache
run: echo "YARN_CACHE_DIR=$(yarn cache dir)" >> "${GITHUB_OUTPUT}"
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache.outputs.YARN_CACHE_DIR }}
key: ${{ runner.os }}-website-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-website-
- run: yarn install --frozen-lockfile
- name: Check formatting
run: npm run check-formatting
- name: Compare synced directories between PR and base
# if the label exists, any changes are fine, so no need to check
if: >-
! contains(github.event.pull_request.labels.*.name , 'automation:sync-docs')
run: |
autogened=(
docs/docs
docs/reference/help-all.json
versioned_docs/*/docs
versioned_docs/*/reference/help-all.json
)
git fetch --depth=1 origin ${{ github.event.pull_request.base.ref }}
if ! git diff --quiet FETCH_HEAD HEAD -- "${autogened[@]}"; then
echo "::group::Full diff"
git diff FETCH_HEAD HEAD -- "${autogened[@]}"
echo "::endgroup::"
cat <<EOF
Error: found changes to files that are synced from <https://github.com/pantsbuild/pants>:
$(git diff --name-only FETCH_HEAD HEAD -- "${autogened[@]}")
Those files should be changed in <https://github.com/pantsbuild/pants>, and are
automatically synced to this repository after each release.
(If this change is intentional and you're sure it's appropriate, add the
'automation:sync-docs' label.)
EOF
exit 1
fi
- name: Check references are up to date
# NB. in future, it would be nice for this to be packaged as a test that one can run
# locally, e.g. https://github.com/pantsbuild/pants/discussions/18235
run: |
npm run generate-reference-all
if ! git diff --quiet ; then
echo "::group::Full diff"
git diff
echo "::endgroup::"
cat <<EOF
Error: the references have differences between what's committed and what would be
generated. Either:
- if you made changes to the generation scripts, please regenerate with `npm run
generate-reference-all` or `npm run generate-reference <specific directory>`.
- if you have edited the files directly, https://github.com/pantsbuild/pants is the
source of truth: make the changes there and they will be synced here on the next
release.
EOF
exit 1
fi
- name: Build
run: npm run build
env:
NODE_OPTIONS: --max-old-space-size=6144