Skip to content

Commit 80a293c

Browse files
authored
chore(ci): support for multi-lockfiles in the update-lockfiles WF (#1127)
* chore(ci): add support for multi-lock files in update_lockfiles * chore(ci): add compile checks and per-dependency back-off in update_lockfiles * chore(deps): intro 1.18 lock because of ex_ast * fix(ci): ensure all locks are checked * fix(deps): update locks for 1.13-1.14 * refactor(ci): extract refresh_lockfiles.sh
1 parent d2d5a98 commit 80a293c

7 files changed

Lines changed: 238 additions & 19 deletions

File tree

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ jobs:
127127

128128
- name: Ensure lockfiles are unchanged
129129
if: matrix.elixir == '1.13'
130-
run: git diff --exit-code -- mix-1.13-1.14.lock mix-1.15-1.17.lock mix.lock 'test_integrations/*/mix.lock'
130+
run: git diff --exit-code -- mix-1.13-1.14.lock mix-1.15-1.17.lock mix-1.18.lock mix.lock 'test_integrations/*/mix.lock' 'test_integrations/*/mix-*.lock'
131131

132132
- name: Check `mix release` with phoenix_app and sentry configured
133133
if: matrix.release_test

.github/workflows/update_lockfiles.yml

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,53 @@ permissions:
1111

1212
jobs:
1313
update-lockfiles:
14-
name: Refresh mix.lock files
14+
name: Refresh mix.lock files (${{ matrix.bucket }})
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 15
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
# Each project's mix.exs picks its lockfile based on the running Elixir
21+
# version (see `lockfile/1` in mix.exs), so one Elixir version per
22+
# supported range is needed to refresh every lockfile bucket.
23+
include:
24+
- bucket: "1.13-1.14"
25+
elixir: "1.13"
26+
otp: "25.3"
27+
- bucket: "1.15-1.17"
28+
elixir: "1.17"
29+
otp: "26.2"
30+
- bucket: "1.18"
31+
elixir: "1.18"
32+
otp: "27.2"
33+
- bucket: "default"
34+
elixir: "1.20.2-otp-29"
35+
otp: "29.0.1"
36+
37+
steps:
38+
- name: Check out this repository
39+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
40+
41+
- name: Setup Elixir and Erlang
42+
uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 # v1.24.0
43+
with:
44+
elixir-version: ${{ matrix.elixir }}
45+
otp-version: ${{ matrix.otp }}
46+
47+
- name: Refresh lockfiles
48+
id: refresh
49+
run: scripts/refresh_lockfiles.sh "${{ matrix.bucket }}"
50+
51+
- name: Upload updated lockfiles
52+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
53+
with:
54+
name: lockfiles-${{ matrix.bucket }}
55+
path: ${{ steps.refresh.outputs.paths }}
56+
if-no-files-found: error
57+
58+
create-pr:
59+
name: Create pull request
60+
needs: update-lockfiles
1561
runs-on: ubuntu-latest
1662
timeout-minutes: 15
1763
steps:
@@ -27,19 +73,11 @@ jobs:
2773
with:
2874
token: ${{ steps.token.outputs.token }}
2975

30-
- name: Setup Elixir and Erlang
31-
uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 # v1.24.0
76+
- name: Download updated lockfiles
77+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6
3278
with:
33-
elixir-version: "1.18"
34-
otp-version: "27.2"
35-
36-
- name: Refresh lockfiles
37-
run: |
38-
for lock in mix.lock test_integrations/*/mix.lock; do
39-
dir=$(dirname "$lock")
40-
echo "==> Refreshing mix.lock in $dir"
41-
(cd "$dir" && mix deps.update --all)
42-
done
79+
pattern: lockfiles-*
80+
merge-multiple: true
4381

4482
- name: Configure git
4583
run: |
@@ -51,7 +89,8 @@ jobs:
5189
run: |
5290
# Stage first, then diff the index against HEAD: plain `git diff` ignores
5391
# untracked files, so a brand-new project's lock would look unchanged.
54-
git add mix.lock 'test_integrations/*/mix.lock'
92+
mapfile -t lockfiles < <(git ls-files -- 'mix.lock' 'mix-*.lock' 'test_integrations/*/mix.lock' 'test_integrations/*/mix-*.lock')
93+
git add "${lockfiles[@]}"
5594
5695
if git diff --cached --quiet; then
5796
echo "No lockfile changes; nothing to do."
@@ -81,7 +120,7 @@ jobs:
81120
script: |
82121
const branchName = process.env.BRANCH_NAME;
83122
const commitTitle = process.env.COMMIT_TITLE;
84-
const prBody = `Automated weekly refresh of the committed \`mix.lock\` files via \`mix deps.update --all\`, keeping dependency pins current with the latest security patches allowed by each project's version constraints.
123+
const prBody = `Automated weekly refresh of the committed \`mix.lock\` files (including the per-Elixir-version-range lockfiles) via \`mix deps.update --all\`, keeping dependency pins current with the latest security patches allowed by each project's version constraints.
85124
86125
#skip-changelog
87126

0 commit comments

Comments
 (0)