Skip to content

Commit 00b37aa

Browse files
authored
Merge pull request #68 from dtolnay/shallow
Speed up submodule clone in CI
2 parents d253cad + 119c210 commit 00b37aa

File tree

4 files changed

+84
-2
lines changed

4 files changed

+84
-2
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: git submodule init
2+
3+
runs:
4+
using: composite
5+
steps:
6+
- uses: ./.github/actions/fast-submodule
7+
with:
8+
submodule: rust
9+
- run: git -C rust log --all
10+
shell: bash
11+
- uses: ./.github/actions/fast-submodule
12+
with:
13+
working-directory: rust
14+
submodule: library/backtrace
15+
- uses: ./.github/actions/fast-submodule
16+
with:
17+
working-directory: rust
18+
submodule: library/stdarch
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: git submodule init
2+
3+
inputs:
4+
working-directory:
5+
description: root directory of parent repository
6+
required: false
7+
submodule:
8+
description: path of submodule relative to parent repository root
9+
required: true
10+
11+
runs:
12+
using: composite
13+
steps:
14+
- run: git submodule init "$SUBMODULE"
15+
env:
16+
SUBMODULE: ${{inputs.submodule}}
17+
working-directory: ${{inputs.working-directory}}
18+
shell: bash
19+
- id: path
20+
run: (echo -n gitdir=; git rev-parse --absolute-git-dir) | tee -a $GITHUB_OUTPUT
21+
working-directory: ${{inputs.working-directory}}
22+
shell: bash
23+
- run: mkdir -p "$DIR"
24+
env:
25+
DIR: ${{steps.path.outputs.gitdir}}/modules/${{inputs.submodule}}
26+
working-directory: ${{inputs.working-directory}}
27+
shell: bash
28+
- run: git -c advice.defaultBranchName=false init --separate-git-dir="$DIR" "$SUBMODULE"
29+
env:
30+
DIR: ${{steps.path.outputs.gitdir}}/modules/${{inputs.submodule}}
31+
SUBMODULE: ${{inputs.submodule}}
32+
working-directory: ${{inputs.working-directory}}
33+
shell: bash
34+
- id: config
35+
run: (echo -n url=; git config submodule."$SUBMODULE".url) | tee -a $GITHUB_OUTPUT
36+
env:
37+
SUBMODULE: ${{inputs.submodule}}
38+
working-directory: ${{inputs.working-directory}}
39+
shell: bash
40+
- run: git -C "$SUBMODULE" remote add origin "$URL"
41+
env:
42+
SUBMODULE: ${{inputs.submodule}}
43+
URL: ${{steps.config.outputs.url}}
44+
working-directory: ${{inputs.working-directory}}
45+
shell: bash
46+
- id: commit
47+
run: (echo -n commit=; git rev-parse :"$SUBMODULE") | tee -a $GITHUB_OUTPUT
48+
env:
49+
SUBMODULE: ${{inputs.submodule}}
50+
working-directory: ${{inputs.working-directory}}
51+
shell: bash
52+
- run: git -C "$SUBMODULE" fetch origin --refmap= --depth=1 "$COMMIT"
53+
env:
54+
COMMIT: ${{steps.commit.outputs.commit}}
55+
SUBMODULE: ${{inputs.submodule}}
56+
working-directory: ${{inputs.working-directory}}
57+
shell: bash
58+
- run: git -C "$SUBMODULE" -c advice.detachedHead=false checkout FETCH_HEAD
59+
env:
60+
SUBMODULE: ${{inputs.submodule}}
61+
working-directory: ${{inputs.working-directory}}
62+
shell: bash

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v4
2323
- uses: dtolnay/install-buck2@latest
24-
- run: ./submodule_init.sh
24+
- name: git submodule init
25+
uses: ./.github/actions/checkout
2526
- run: buck2 run stage2:rustc -- --version --verbose

.github/workflows/reindeer.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ jobs:
2323
- uses: actions/checkout@v4
2424
- uses: dtolnay/rust-toolchain@stable
2525
- uses: dtolnay/install@reindeer
26-
- run: ./submodule_init.sh
26+
- name: git submodule init
27+
uses: ./.github/actions/checkout
2728
- run: reindeer buckify
2829
- name: Check reindeer-generated BUCK file up to date
2930
run: git diff --exit-code

0 commit comments

Comments
 (0)