Skip to content

Commit fe5965d

Browse files
authored
ci: Implement parallel submodule cloning for faster CI/CD performance (#13045)
1 parent 73a6f25 commit fe5965d

File tree

2 files changed

+83
-44
lines changed

2 files changed

+83
-44
lines changed

.github/actions/clone-submodules/action.yml

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -36,47 +36,12 @@ inputs:
3636
runs:
3737
using: composite
3838
steps:
39-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
40-
if: ${{ inputs.test262 == 'true' }}
41-
with:
42-
show-progress: false
43-
persist-credentials: false
44-
repository: tc39/test262
45-
path: tasks/coverage/test262
46-
ref: 4b5d36ab6ef2f59d0a8902cd383762547a3a74c4
47-
48-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
49-
if: ${{ inputs.babel == 'true' }}
50-
with:
51-
show-progress: false
52-
persist-credentials: false
53-
repository: babel/babel
54-
path: tasks/coverage/babel
55-
ref: 98d18aa4f66ce300a6a863bad223ab67b3fdf282
56-
57-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
58-
if: ${{ inputs.typescript == 'true' }}
59-
with:
60-
show-progress: false
61-
persist-credentials: false
62-
repository: microsoft/TypeScript
63-
path: tasks/coverage/typescript
64-
ref: 81c951894e93bdc37c6916f18adcd80de76679bc
65-
66-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
67-
if: ${{ inputs.prettier == 'true' }}
68-
with:
69-
show-progress: false
70-
persist-credentials: false
71-
repository: prettier/prettier
72-
path: tasks/prettier_conformance/prettier
73-
ref: 7584432401a47a26943dd7a9ca9a8e032ead7285 # v3.5.0
74-
75-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
76-
if: ${{ inputs.acorn-test262 == 'true' }}
77-
with:
78-
show-progress: false
79-
persist-credentials: false
80-
repository: oxc-project/acorn-test262
81-
path: tasks/coverage/acorn-test262
82-
ref: d9ba02ddea22800a285c7ad24e3fbfbb00ccbb02 # Latest main at 1/7/25
39+
- name: Clone submodules in parallel
40+
shell: bash
41+
run: |
42+
${{ github.action_path }}/clone-parallel.sh \
43+
"${{ inputs.test262 }}" \
44+
"${{ inputs.babel }}" \
45+
"${{ inputs.typescript }}" \
46+
"${{ inputs.prettier }}" \
47+
"${{ inputs.acorn-test262 }}"
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
3+
# Clone submodules in parallel for faster setup
4+
# Usage: ./clone-parallel.sh [test262] [babel] [typescript] [prettier] [acorn-test262]
5+
# Arguments: "true" or "false" for each submodule
6+
7+
set -euo pipefail
8+
9+
# Default values
10+
TEST262=${1:-true}
11+
BABEL=${2:-true}
12+
TYPESCRIPT=${3:-true}
13+
PRETTIER=${4:-true}
14+
ACORN_TEST262=${5:-true}
15+
16+
# Array to store background process PIDs
17+
declare -a PIDS=()
18+
19+
# Function to clone a repository in the background
20+
clone_repo() {
21+
local should_clone="$1"
22+
local repo="$2"
23+
local path="$3"
24+
local ref="$4"
25+
local name="$5"
26+
27+
if [[ "$should_clone" == "true" ]]; then
28+
echo "Starting clone of $name..."
29+
(
30+
# Create the directory structure if it doesn't exist
31+
mkdir -p "$(dirname "$path")"
32+
33+
# Clone the repository with minimal progress output
34+
git clone --quiet --no-progress --single-branch --depth 1 \
35+
"https://github.com/$repo.git" "$path"
36+
37+
# Checkout the specific commit
38+
cd "$path"
39+
git fetch --quiet --depth 1 origin "$ref"
40+
git checkout --quiet "$ref"
41+
42+
echo "✓ Completed clone of $name"
43+
) &
44+
PIDS+=($!)
45+
else
46+
echo "Skipping $name"
47+
fi
48+
}
49+
50+
echo "Cloning submodules in parallel..."
51+
52+
# Start all clone operations in parallel
53+
clone_repo "$TEST262" "tc39/test262" "tasks/coverage/test262" "4b5d36ab6ef2f59d0a8902cd383762547a3a74c4" "test262"
54+
clone_repo "$BABEL" "babel/babel" "tasks/coverage/babel" "98d18aa4f66ce300a6a863bad223ab67b3fdf282" "babel"
55+
clone_repo "$TYPESCRIPT" "microsoft/TypeScript" "tasks/coverage/typescript" "81c951894e93bdc37c6916f18adcd80de76679bc" "typescript"
56+
clone_repo "$PRETTIER" "prettier/prettier" "tasks/prettier_conformance/prettier" "7584432401a47a26943dd7a9ca9a8e032ead7285" "prettier"
57+
clone_repo "$ACORN_TEST262" "oxc-project/acorn-test262" "tasks/coverage/acorn-test262" "d9ba02ddea22800a285c7ad24e3fbfbb00ccbb02" "acorn-test262"
58+
59+
# Wait for all background processes to complete
60+
echo "Waiting for all clone operations to complete..."
61+
failed_count=0
62+
for pid in "${PIDS[@]}"; do
63+
if ! wait "$pid"; then
64+
echo "❌ Clone operation failed (PID: $pid)"
65+
((failed_count++))
66+
fi
67+
done
68+
69+
if [[ $failed_count -eq 0 ]]; then
70+
echo "✅ All submodule clones completed successfully!"
71+
else
72+
echo "$failed_count clone operation(s) failed"
73+
exit 1
74+
fi

0 commit comments

Comments
 (0)