Skip to content

Commit 2bd5ef5

Browse files
authored
Allow configuration of submodule.fetchJobs
1 parent b4ffde6 commit 2bd5ef5

File tree

11 files changed

+271
-102
lines changed

11 files changed

+271
-102
lines changed

.github/workflows/test.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,17 @@ jobs:
150150
- name: Verify submodules recursive
151151
run: __test__/verify-submodules-recursive.sh
152152

153+
# Submodules fetchJobs
154+
- name: Checkout submodules true
155+
uses: ./
156+
with:
157+
ref: test-data/v2/submodule-ssh-url
158+
path: submodules-true
159+
submodules: recursive
160+
submodulesFetchJobs: "10"
161+
- name: Verify submodules true
162+
run: __test__/verify-submodules-with-jobs.sh
163+
153164
# Basic checkout using REST API
154165
- name: Remove basic
155166
if: runner.os != 'windows'
@@ -242,7 +253,7 @@ jobs:
242253
path: basic
243254
- name: Verify basic
244255
run: __test__/verify-basic.sh --archive
245-
256+
246257
test-git-container:
247258
runs-on: ubuntu-latest
248259
container: bitnami/git:latest
@@ -279,4 +290,4 @@ jobs:
279290
- name: Fix Checkout v3
280291
uses: actions/checkout@v3
281292
with:
282-
path: v3
293+
path: v3

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
111111
# Default: false
112112
submodules: ''
113113

114+
# Specifies how many submodules are fetched/cloned at the same time. A positive
115+
# integer allows up to that number of submodules fetched in parallel. A value of 0
116+
# will give some reasonable default. If unset, it defaults to 1.
117+
# Default: 1
118+
submodulesFetchJobs: ''
119+
114120
# Add repository path as safe.directory for Git global config by running `git
115121
# config --global --add safe.directory <path>`
116122
# Default: true

__test__/git-auth-helper.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,7 @@ async function setup(testName: string): Promise<void> {
811811
lfs: false,
812812
submodules: false,
813813
nestedSubmodules: false,
814+
submodulesFetchJobs: '1',
814815
persistCredentials: true,
815816
ref: 'refs/heads/main',
816817
repositoryName: 'my-repo',
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
if [ ! -f "./submodules-recursive/regular-file.txt" ]; then
4+
echo "Expected regular file does not exist"
5+
exit 1
6+
fi
7+
8+
if [ ! -f "./submodules-recursive/submodule-level-1/submodule-file.txt" ]; then
9+
echo "Expected submodule file does not exist"
10+
exit 1
11+
fi
12+
13+
if [ ! -f "./submodules-recursive/submodule-level-1/submodule-level-2/nested-submodule-file.txt" ]; then
14+
echo "Expected nested submodule file does not exists"
15+
exit 1
16+
fi
17+
18+
echo "Testing fetchJobs exists"
19+
git config --local --get-regexp submodules.fetchJobs | grep 10
20+
if [ "$?" != "0" ]; then
21+
echo "Failed to validate fetchJobs configuration"
22+
exit 1
23+
fi
24+
25+
echo "Testing persisted credential"
26+
pushd ./submodules-recursive/submodule-level-1/submodule-level-2
27+
git config --local --name-only --get-regexp http.+extraheader && git fetch
28+
if [ "$?" != "0" ]; then
29+
echo "Failed to validate persisted credential"
30+
popd
31+
exit 1
32+
fi
33+
popd

action.yml

Lines changed: 104 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,104 @@
1-
name: 'Checkout'
2-
description: 'Checkout a Git repository at a particular version'
3-
inputs:
4-
repository:
5-
description: 'Repository name with owner. For example, actions/checkout'
6-
default: ${{ github.repository }}
7-
ref:
8-
description: >
9-
The branch, tag or SHA to checkout. When checking out the repository that
10-
triggered a workflow, this defaults to the reference or SHA for that
11-
event. Otherwise, uses the default branch.
12-
token:
13-
description: >
14-
Personal access token (PAT) used to fetch the repository. The PAT is configured
15-
with the local git config, which enables your scripts to run authenticated git
16-
commands. The post-job step removes the PAT.
17-
18-
19-
We recommend using a service account with the least permissions necessary.
20-
Also when generating a new PAT, select the least scopes necessary.
21-
22-
23-
[Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)
24-
default: ${{ github.token }}
25-
ssh-key:
26-
description: >
27-
SSH key used to fetch the repository. The SSH key is configured with the local
28-
git config, which enables your scripts to run authenticated git commands.
29-
The post-job step removes the SSH key.
30-
31-
32-
We recommend using a service account with the least permissions necessary.
33-
34-
35-
[Learn more about creating and using
36-
encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)
37-
ssh-known-hosts:
38-
description: >
39-
Known hosts in addition to the user and global host key database. The public
40-
SSH keys for a host may be obtained using the utility `ssh-keyscan`. For example,
41-
`ssh-keyscan github.com`. The public key for github.com is always implicitly added.
42-
ssh-strict:
43-
description: >
44-
Whether to perform strict host key checking. When true, adds the options `StrictHostKeyChecking=yes`
45-
and `CheckHostIP=no` to the SSH command line. Use the input `ssh-known-hosts` to
46-
configure additional hosts.
47-
default: true
48-
persist-credentials:
49-
description: 'Whether to configure the token or SSH key with the local git config'
50-
default: true
51-
path:
52-
description: 'Relative path under $GITHUB_WORKSPACE to place the repository'
53-
clean:
54-
description: 'Whether to execute `git clean -ffdx && git reset --hard HEAD` before fetching'
55-
default: true
56-
filter:
57-
description: >
58-
Partially clone against a given filter.
59-
Overrides sparse-checkout if set.
60-
default: null
61-
sparse-checkout:
62-
description: >
63-
Do a sparse checkout on given patterns.
64-
Each pattern should be separated with new lines.
65-
default: null
66-
sparse-checkout-cone-mode:
67-
description: >
68-
Specifies whether to use cone-mode when doing a sparse checkout.
69-
default: true
70-
fetch-depth:
71-
description: 'Number of commits to fetch. 0 indicates all history for all branches and tags.'
72-
default: 1
73-
fetch-tags:
74-
description: 'Whether to fetch tags, even if fetch-depth > 0.'
75-
default: false
76-
show-progress:
77-
description: 'Whether to show progress status output when fetching.'
78-
default: true
79-
lfs:
80-
description: 'Whether to download Git-LFS files'
81-
default: false
82-
submodules:
83-
description: >
84-
Whether to checkout submodules: `true` to checkout submodules or `recursive` to
85-
recursively checkout submodules.
86-
87-
88-
When the `ssh-key` input is not provided, SSH URLs beginning with `[email protected]:` are
89-
converted to HTTPS.
90-
default: false
91-
set-safe-directory:
92-
description: Add repository path as safe.directory for Git global config by running `git config --global --add safe.directory <path>`
93-
default: true
94-
github-server-url:
95-
description: The base URL for the GitHub instance that you are trying to clone from, will use environment defaults to fetch from the same instance that the workflow is running from unless specified. Example URLs are https://github.com or https://my-ghes-server.example.com
96-
required: false
97-
runs:
98-
using: node20
99-
main: dist/index.js
100-
post: dist/index.js
1+
name: 'Checkout'
2+
description: 'Checkout a Git repository at a particular version'
3+
inputs:
4+
repository:
5+
description: 'Repository name with owner. For example, actions/checkout'
6+
default: ${{ github.repository }}
7+
ref:
8+
description: >
9+
The branch, tag or SHA to checkout. When checking out the repository that
10+
triggered a workflow, this defaults to the reference or SHA for that
11+
event. Otherwise, uses the default branch.
12+
token:
13+
description: >
14+
Personal access token (PAT) used to fetch the repository. The PAT is configured
15+
with the local git config, which enables your scripts to run authenticated git
16+
commands. The post-job step removes the PAT.
17+
18+
19+
We recommend using a service account with the least permissions necessary.
20+
Also when generating a new PAT, select the least scopes necessary.
21+
22+
23+
[Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)
24+
default: ${{ github.token }}
25+
ssh-key:
26+
description: >
27+
SSH key used to fetch the repository. The SSH key is configured with the local
28+
git config, which enables your scripts to run authenticated git commands.
29+
The post-job step removes the SSH key.
30+
31+
32+
We recommend using a service account with the least permissions necessary.
33+
34+
35+
[Learn more about creating and using
36+
encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)
37+
ssh-known-hosts:
38+
description: >
39+
Known hosts in addition to the user and global host key database. The public
40+
SSH keys for a host may be obtained using the utility `ssh-keyscan`. For example,
41+
`ssh-keyscan github.com`. The public key for github.com is always implicitly added.
42+
ssh-strict:
43+
description: >
44+
Whether to perform strict host key checking. When true, adds the options `StrictHostKeyChecking=yes`
45+
and `CheckHostIP=no` to the SSH command line. Use the input `ssh-known-hosts` to
46+
configure additional hosts.
47+
default: true
48+
persist-credentials:
49+
description: 'Whether to configure the token or SSH key with the local git config'
50+
default: true
51+
path:
52+
description: 'Relative path under $GITHUB_WORKSPACE to place the repository'
53+
clean:
54+
description: 'Whether to execute `git clean -ffdx && git reset --hard HEAD` before fetching'
55+
default: true
56+
filter:
57+
description: >
58+
Partially clone against a given filter.
59+
Overrides sparse-checkout if set.
60+
default: null
61+
sparse-checkout:
62+
description: >
63+
Do a sparse checkout on given patterns.
64+
Each pattern should be separated with new lines.
65+
default: null
66+
sparse-checkout-cone-mode:
67+
description: >
68+
Specifies whether to use cone-mode when doing a sparse checkout.
69+
default: true
70+
fetch-depth:
71+
description: 'Number of commits to fetch. 0 indicates all history for all branches and tags.'
72+
default: 1
73+
fetch-tags:
74+
description: 'Whether to fetch tags, even if fetch-depth > 0.'
75+
default: false
76+
show-progress:
77+
description: 'Whether to show progress status output when fetching.'
78+
default: true
79+
lfs:
80+
description: 'Whether to download Git-LFS files'
81+
default: false
82+
submodules:
83+
description: >
84+
Whether to checkout submodules: `true` to checkout submodules or `recursive` to
85+
recursively checkout submodules.
86+
87+
88+
When the `ssh-key` input is not provided, SSH URLs beginning with `[email protected]:` are
89+
converted to HTTPS.
90+
default: false
91+
submodulesFetchJobs:
92+
description: >
93+
Specifies how many submodules are fetched/cloned at the same time. A positive integer allows up to that number of submodules fetched in parallel. A value of 0 will give some reasonable default. If unset, it defaults to 1.
94+
default: 1
95+
set-safe-directory:
96+
description: Add repository path as safe.directory for Git global config by running `git config --global --add safe.directory <path>`
97+
default: true
98+
github-server-url:
99+
description: The base URL for the GitHub instance that you are trying to clone from, will use environment defaults to fetch from the same instance that the workflow is running from unless specified. Example URLs are https://github.com or https://my-ghes-server.example.com
100+
required: false
101+
runs:
102+
using: node20
103+
main: dist/index.js
104+
post: dist/index.js

dist/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,7 @@ function getSource(settings) {
13041304
core.endGroup();
13051305
// Checkout submodules
13061306
core.startGroup('Fetching submodules');
1307+
yield git.config('submodule.fetchJobs', settings.submodulesFetchJobs);
13071308
yield git.submoduleSync(settings.nestedSubmodules);
13081309
yield git.submoduleUpdate(settings.fetchDepth, settings.nestedSubmodules);
13091310
yield git.submoduleForeach('git config --local gc.auto 0', settings.nestedSubmodules);
@@ -1770,8 +1771,10 @@ function getInputs() {
17701771
else if (submodulesString == 'TRUE') {
17711772
result.submodules = true;
17721773
}
1774+
result.submodulesFetchJobs = core.getInput('submodulesFetchJobs') || '1';
17731775
core.debug(`submodules = ${result.submodules}`);
17741776
core.debug(`recursive submodules = ${result.nestedSubmodules}`);
1777+
core.debug(`submodules fetchJobs= ${result.submodulesFetchJobs}`);
17751778
// Auth token
17761779
result.authToken = core.getInput('token', { required: true });
17771780
// SSH

flake.lock

Lines changed: 78 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)