Skip to content

Add PR CI check that humans don't edit auto-generated files #92

Add PR CI check that humans don't edit auto-generated files

Add PR CI check that humans don't edit auto-generated files #92

Workflow file for this run

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