-
Notifications
You must be signed in to change notification settings - Fork 406
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: CI creates lean-pr-testing-NNNN branches at Std too #3200
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
bdde13e
chore: CI looks for nightly-testing-YYYY-MM-DD at Mathlib as either a…
kim-em 0fe71e9
add comment
kim-em cf6d522
chore: create lean-pr-testing-NNNN branches at Std too
kim-em cb5a0e9
advice from linter
kim-em f9bd389
more good advice from the linter
kim-em 5694dab
Update .github/workflows/pr-release.yml
kim-em 0cc8496
followup to review suggestion
kim-em 89c7336
merge master
kim-em a63acb3
more fixes
kim-em File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,22 +126,32 @@ jobs: | |
if [ "$NIGHTLY_SHA" = "$MERGE_BASE_SHA" ]; then | ||
echo "The merge base of this PR coincides with the nightly release" | ||
|
||
REMOTE_TAGS="$(git ls-remote https://github.com/leanprover-community/mathlib4.git nightly-testing-"$MOST_RECENT_NIGHTLY")" | ||
MATHLIB_REMOTE_TAGS="$(git ls-remote https://github.com/leanprover-community/mathlib4.git nightly-testing-"$MOST_RECENT_NIGHTLY")" | ||
|
||
if [[ -n "$REMOTE_TAGS" ]]; then | ||
if [[ -n "$MATHLIB_REMOTE_TAGS" ]]; then | ||
echo "... and Mathlib has a 'nightly-testing-$MOST_RECENT_NIGHTLY' tag." | ||
MESSAGE="" | ||
else | ||
echo "... but Mathlib does not yet have a 'nightly-testing-$MOST_RECENT_NIGHTLY' tag." | ||
MESSAGE="- ❗ Mathlib CI can not be attempted yet, as the \`nightly-testing-$MOST_RECENT_NIGHTLY\` tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto \`nightly-with-mathlib\`, Mathlib CI should run now." | ||
fi | ||
|
||
STD_REMOTE_TAGS="$(git ls-remote https://github.com/leanprover/std4.git nightly-testing-"$MOST_RECENT_NIGHTLY")" | ||
|
||
if [[ -n "$STD_REMOTE_TAGS" ]]; then | ||
echo "... and Std has a 'nightly-testing-$MOST_RECENT_NIGHTLY' tag." | ||
MESSAGE="" | ||
else | ||
echo "... but Std does not yet have a 'nightly-testing-$MOST_RECENT_NIGHTLY' tag." | ||
MESSAGE="- ❗ Std CI can not be attempted yet, as the \`nightly-testing-$MOST_RECENT_NIGHTLY\` tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto \`nightly-with-mathlib\`, Std CI should run now." | ||
fi | ||
|
||
else | ||
echo "The most recently nightly tag on this branch has SHA: $NIGHTLY_SHA" | ||
echo "but 'git merge-base origin/master HEAD' reported: $MERGE_BASE_SHA" | ||
git -C lean4.git log -10 origin/master | ||
|
||
MESSAGE="- ❗ Mathlib CI will not be attempted unless your PR branches off the \`nightly-with-mathlib\` branch." | ||
MESSAGE="- ❗ Std/Mathlib CI will not be attempted unless your PR branches off the \`nightly-with-mathlib\` branch." | ||
fi | ||
|
||
if [[ -n "$MESSAGE" ]]; then | ||
|
@@ -213,6 +223,62 @@ jobs: | |
description: description, | ||
}); | ||
|
||
# We next automatically create a Std branch using this toolchain. | ||
# Std doesn't itself have a mechanism to report results of CI from this branch back to Lean | ||
# Instead this is taken care of by Mathlib CI, which will fail if Std fails. | ||
- name: Cleanup workspace | ||
if: steps.workflow-info.outputs.pullRequestNumber != '' && steps.ready.outputs.mathlib_ready == 'true' | ||
run: | | ||
sudo rm -rf ./* | ||
|
||
# Checkout the Std repository with all branches | ||
- name: Checkout Std repository | ||
if: steps.workflow-info.outputs.pullRequestNumber != '' && steps.ready.outputs.mathlib_ready == 'true' | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: leanprover/std4 | ||
token: ${{ secrets.MATHLIB4_BOT }} | ||
ref: nightly-testing | ||
fetch-depth: 0 # This ensures we check out all tags and branches. | ||
|
||
- name: Check if tag exists | ||
if: steps.workflow-info.outputs.pullRequestNumber != '' && steps.ready.outputs.mathlib_ready == 'true' | ||
id: check_std_tag | ||
run: | | ||
git config user.name "leanprover-community-mathlib4-bot" | ||
git config user.email "[email protected]" | ||
|
||
if git ls-remote --heads --tags --exit-code origin "nightly-testing-${MOST_RECENT_NIGHTLY}" >/dev/null; then | ||
BASE="nightly-testing-${MOST_RECENT_NIGHTLY}" | ||
else | ||
echo "This shouldn't be possible: couldn't find a 'nightly-testing-${MOST_RECENT_NIGHTLY}' tag at Std. Falling back to 'nightly-testing'." | ||
BASE=nightly-testing | ||
fi | ||
|
||
echo "Using base branch: $BASE" | ||
|
||
EXISTS="$(git ls-remote --heads origin lean-pr-testing-${{ steps.workflow-info.outputs.pullRequestNumber }} | wc -l)" | ||
echo "Branch exists: $EXISTS" | ||
if [ "$EXISTS" = "0" ]; then | ||
echo "Branch does not exist, creating it." | ||
git switch -c lean-pr-testing-${{ steps.workflow-info.outputs.pullRequestNumber }} "$BASE" | ||
echo "leanprover/lean4-pr-releases:pr-release-${{ steps.workflow-info.outputs.pullRequestNumber }}" > lean-toolchain | ||
git add lean-toolchain | ||
git commit -m "Update lean-toolchain for testing https://github.com/leanprover/lean4/pull/${{ steps.workflow-info.outputs.pullRequestNumber }}" | ||
else | ||
echo "Branch already exists, pushing an empty commit." | ||
git switch lean-pr-testing-${{ steps.workflow-info.outputs.pullRequestNumber }} | ||
# The Std `nightly-testing` or `nightly-testing-YYYY-MM-DD` branch may have moved since this branch was created, so merge their changes. | ||
# (This should no longer be possible once `nightly-testing-YYYY-MM-DD` is a tag, but it is still safe to merge.) | ||
git merge "$BASE" --strategy-option ours --no-commit --allow-unrelated-histories | ||
git commit --allow-empty -m "Trigger CI for https://github.com/leanprover/lean4/pull/${{ steps.workflow-info.outputs.pullRequestNumber }}" | ||
fi | ||
|
||
- name: Push changes | ||
if: steps.workflow-info.outputs.pullRequestNumber != '' && steps.ready.outputs.mathlib_ready == 'true' | ||
run: | | ||
git push origin lean-pr-testing-${{ steps.workflow-info.outputs.pullRequestNumber }} | ||
|
||
|
||
# We next automatically create a Mathlib branch using this toolchain. | ||
# Mathlib CI will be responsible for reporting back success or failure | ||
|
@@ -234,7 +300,7 @@ jobs: | |
|
||
- name: Check if tag exists | ||
if: steps.workflow-info.outputs.pullRequestNumber != '' && steps.ready.outputs.mathlib_ready == 'true' | ||
id: check_tag | ||
id: check_mathlib_tag | ||
run: | | ||
git config user.name "leanprover-community-mathlib4-bot" | ||
git config user.email "[email protected]" | ||
|
@@ -248,20 +314,20 @@ jobs: | |
|
||
echo "Using base tag: $BASE" | ||
|
||
git checkout "$BASE" | ||
|
||
EXISTS="$(git ls-remote --heads origin lean-pr-testing-${{ steps.workflow-info.outputs.pullRequestNumber }} | wc -l)" | ||
echo "Branch exists: $EXISTS" | ||
if [ "$EXISTS" = "0" ]; then | ||
echo "Branch does not exist, creating it." | ||
git checkout -b lean-pr-testing-${{ steps.workflow-info.outputs.pullRequestNumber }} | ||
git switch -c lean-pr-testing-${{ steps.workflow-info.outputs.pullRequestNumber }} "$BASE" | ||
echo "leanprover/lean4-pr-releases:pr-release-${{ steps.workflow-info.outputs.pullRequestNumber }}" > lean-toolchain | ||
git add lean-toolchain | ||
sed -i "s/require std from git \"https:\/\/github.com\/leanprover\/std4\" @ \".\+\"/require std from git \"https:\/\/github.com\/leanprover\/std4\" @ \"nightly-testing-${MOST_RECENT_NIGHTLY}\"/" lakefile.lean | ||
git add lakefile.lean | ||
git commit -m "Update lean-toolchain for testing https://github.com/leanprover/lean4/pull/${{ steps.workflow-info.outputs.pullRequestNumber }}" | ||
else | ||
echo "Branch already exists, pushing an empty commit." | ||
git checkout lean-pr-testing-${{ steps.workflow-info.outputs.pullRequestNumber }} | ||
# The Mathlib `nightly-testing` or `nightly-testing-YYYY-MM-DD` tag may have moved since this branch was created, so merge their changes. | ||
git switch lean-pr-testing-${{ steps.workflow-info.outputs.pullRequestNumber }} | ||
# The Mathlib `nightly-testing` branch or `nightly-testing-YYYY-MM-DD` tag may have moved since this branch was created, so merge their changes. | ||
# (This should no longer be possible once `nightly-testing-YYYY-MM-DD` is a tag, but it is still safe to merge.) | ||
git merge "$BASE" --strategy-option ours --no-commit --allow-unrelated-histories | ||
git commit --allow-empty -m "Trigger CI for https://github.com/leanprover/lean4/pull/${{ steps.workflow-info.outputs.pullRequestNumber }}" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm turns out
works if
base
is a local tag, but not if it is a (remote) branch.The old code (
git checkout base
) would work for a (remote) branch, but not for a tag. Kinda annoying.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we need to parse this output to go onto a common path in both cases
Alternatively, we can once manually convert all
nightly-testing-YYYY-MM-DD
branches to tags on mathlib4. Maybe easier.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible fix in #3208