Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: stage0 autoupdater action #3042

Merged
merged 18 commits into from
Dec 11, 2023
60 changes: 60 additions & 0 deletions .github/workflows/update-stage0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Update stage0

# This action will update stage0 on master as soon as
# src/stdlib_flags.h and stage0/src/stdlib_flags.h
# are out of sync there. The update bypasses the merge queue to be quick.

on:
push:
branches:
- 'master'

concurrency:
group: stage0
cancel-in-progress: true

jobs:
update-stage0:
runs-on: ubuntu-latest
steps:
# This action should push to an otherwise protected branch, so it
# uses a deploy key with write permissions, as suggested at
# https://stackoverflow.com/a/76135647/946226
- uses: actions/checkout@v3
with:
ssh-key: ${{secrets.STAGE0_SSH_KEY}}
- name: Check if update is needed
run: |
if diff -u src/stdlib_flags.h stage0/src/stdlib_flags.h
then
echo "src/stdlib_flags.h and stage0/src/stdlib_flags.h agree, nothing to do"
echo "DOIT=no" >> "$GITHUB_ENV"
else
echo "DOIT=yes" >> "$GITHUB_ENV"
fi
- name: Setup git user
run: |
git config --global user.name "Lean stage0 autoupdater"
git config --global user.email "<>"
- if: env.DOIT == 'yes'
uses: DeterminateSystems/nix-installer-action@main
# Would be nice, but does not work yet:
# https://github.com/DeterminateSystems/magic-nix-cache/issues/39
# This action does not run that often and building runs in a few minutes, so ok for now
#- if: env.DOIT == 'yes'
# uses: DeterminateSystems/magic-nix-cache-action@v2
- if: env.DOIT == 'yes'
name: Install Cachix
uses: cachix/cachix-action@v12
with:
name: lean4
- if: env.DOIT == 'yes'
run: nix run .#update-stage0-commit
- if: env.DOIT == 'yes'
run: git show --stat
- if: env.DOIT == 'yes'
name: Sanity check # to avoid loops
run: |
diff -u src/stdlib_flags.h stage0/src/stdlib_flags.h || exit 1
- if: env.DOIT == 'yes'
run: git push origin HEAD:master
3 changes: 3 additions & 0 deletions doc/dev/bootstrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ work. Then, commit the updated `stage0` compiler code with the commit message:
chore: update stage0
```

The lean4 github repository has automation to update stage0 on `master` once
`src/stdlib_flags.h` and `stage0/src/stdlib_flags.h` are out of sync.

## Further Bootstrapping Complications

As written above, changes in meta code in the current stage usually will only
Expand Down