Skip to content

Commit 6ef8cc2

Browse files
ci: auto-update mathlib-ci ref (#37493)
This adds steps to `update_dependencies.yml` to keep the default `ref` in the `get-mathlib-ci` action up to date. prepared with claude code
1 parent 8db507d commit 6ef8cc2

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

.github/actions/get-mathlib-ci/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ Any workflow that needs `mathlib-ci` should use this action instead of writing i
99
own `actions/checkout` block for `leanprover-community/mathlib-ci`.
1010

1111
The default `ref` in [`action.yml`](./action.yml) is the single canonical pinned
12-
`mathlib-ci` commit for this repository.
12+
`mathlib-ci` commit for this repository. This is auto-updated regularly by the
13+
[`update_dependencies.yml` workflow](../../workflows/update_dependencies.yml).
1314

1415
## Why
1516

.github/actions/get-mathlib-ci/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ inputs:
99
required: false
1010
# Default pinned commit used by workflows unless they explicitly override.
1111
# Update this ref as needed to pick up changes to mathlib-ci scripts
12+
# This is also updated automatically by .github/workflows/update_dependencies.yml
1213
default: b6def9edd1c39de8602b8c177c66e9416e5dbc60
1314
path:
1415
description: Checkout destination path.

.github/workflows/update_dependencies.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,27 @@ jobs:
7171
prNumber: ${{ steps.PR.outputs.number }}
7272
prUrl: ${{ steps.PR.outputs.pr_url }}
7373

74+
- name: Get latest mathlib-ci SHA
75+
if: ${{ !contains(steps.PR.outputs.pr_labels, 'ready-to-merge') }}
76+
id: mathlib-ci-sha
77+
env:
78+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
run: |
80+
SHA=$(gh api repos/leanprover-community/mathlib-ci/commits/HEAD --jq '.sha')
81+
echo "sha=$SHA" >> "$GITHUB_OUTPUT"
82+
83+
- name: Update mathlib-ci ref in get-mathlib-ci action
84+
if: ${{ !contains(steps.PR.outputs.pr_labels, 'ready-to-merge') }}
85+
id: update-mathlib-ci-ref
86+
run: |
87+
sed -i "s|^\( *default: \)[0-9a-f]\{40\}|\1${{ steps.mathlib-ci-sha.outputs.sha }}|" \
88+
.github/actions/get-mathlib-ci/action.yml
89+
if git diff --quiet .github/actions/get-mathlib-ci/action.yml; then
90+
echo "modified=false" >> "$GITHUB_OUTPUT"
91+
else
92+
echo "modified=true" >> "$GITHUB_OUTPUT"
93+
fi
94+
7495
- name: Update dependencies
7596
if: ${{ !contains(steps.PR.outputs.pr_labels, 'ready-to-merge') }}
7697
run: lake update -v
@@ -116,6 +137,10 @@ jobs:
116137
create_pr=true
117138
echo "Differences found with lake-manifest.json on $BRANCH_NAME, need to run create-pull-request to update $BRANCH_NAME"
118139
fi
140+
if [ "${{ steps.update-mathlib-ci-ref.outputs.modified }}" == "true" ]; then
141+
create_pr=true
142+
echo "mathlib-ci ref was updated, need to run create-pull-request"
143+
fi
119144
# Otherwise, there's no reason to run create-pull-request
120145
echo "create_pr=$create_pr" >> "${GITHUB_OUTPUT}"
121146

0 commit comments

Comments
 (0)