Skip to content

Commit 9477f80

Browse files
committed
ci: add a workflow to test custom MSYS2 runtimes
Every once in a while it is necessary to verify that a given patch to the MSYS2 runtime does not regress on passing the Git test suite. To verify this, let's reuse what `setup-git-for-windows-sdk` uses in Git's very own CI: - determine the latest successful `ci-artifacts` workflow run in git-for-windows/git-sdk-64 - download its Git files and build artifacts - download its minimal-sdk - download a specified msys2-runtime build's artifacts and overwrite the corresponding files in the minimal-sdk - run the test suite and the assorted validations just like the `ci-artifacts` workflow (from which these jobs are copied) Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 87bebe7 commit 9477f80

File tree

1 file changed

+198
-0
lines changed

1 file changed

+198
-0
lines changed
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
name: test-msys2-runtime
2+
run-name: Test a specific MSYS2 runtime version
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
msys2-runtime-artifacts-url:
8+
# e.g. https://github.com/msys2/msys2-runtime/actions/runs/7865269712/artifacts/1236989688
9+
description: The URL to the artifacts of an msys2-runtime build
10+
type: string
11+
12+
env:
13+
LC_CTYPE: C.UTF-8
14+
MSYS2_RUNTIME_ARTIFACT_URL: ${{ inputs.msys2-runtime-artifacts-url }}
15+
G4W_SDK_REPO: git-for-windows/git-sdk-64
16+
17+
jobs:
18+
minimal-sdk-artifact:
19+
runs-on: windows-latest
20+
outputs:
21+
git-artifacts-extract-location: ${{ steps.git-artifacts-extract-location.outputs.result }}
22+
steps:
23+
- name: get latest successful ci-artifacts run
24+
id: ci-artifacts-run-id
25+
uses: actions/github-script@v7
26+
with:
27+
script: |
28+
const [ owner, repo ] = process.env.G4W_SDK_REPO.split('/')
29+
const info = await github.rest.actions.listWorkflowRuns({
30+
owner,
31+
repo,
32+
workflow_id: 938271, // ci-artifacts.yml
33+
status: 'success',
34+
per_page: 1
35+
})
36+
return info.data.workflow_runs[0].id
37+
- name: get the ci-artifacts build's artifacts
38+
shell: bash
39+
run: |
40+
run_id=${{ steps.ci-artifacts-run-id.outputs.result }} &&
41+
42+
curl -H "Authorization: token ${{secrets.GITHUB_TOKEN}}" \
43+
-L https://api.github.com/repos/$G4W_SDK_REPO/actions/runs/$run_id/artifacts |
44+
jq -r '.artifacts[] | [.name, .archive_download_url] | @tsv' |
45+
tr -d '\r' |
46+
while read name url
47+
do
48+
echo "$name"
49+
curl -H "Authorization: token ${{secrets.GITHUB_TOKEN}}" \
50+
-#sLo /tmp/"$name".zip "$url" &&
51+
unzip -qo /tmp/"$name".zip ||
52+
exit $?
53+
done
54+
ls -la
55+
- name: overwrite MSYS2 runtime with the msys2-runtime build's artifacts
56+
shell: bash
57+
run: |
58+
set -x &&
59+
case "$MSYS2_RUNTIME_ARTIFACT_URL" in
60+
https://github.com/*/actions/runs/[0-9]*/artifacts/[0-9]*)
61+
MSYS2_RUNTIME_ARTIFACT_URL="$(echo "$MSYS2_RUNTIME_ARTIFACT_URL" |
62+
sed 's|^\(https://\)\(github.com/\)\(.*/actions/\)runs/[0-9]*/\(artifacts/[0-9]*\)$|\1api.\2repos/\3\4/zip|')"
63+
;;
64+
esac
65+
66+
curl -H "Authorization: token ${{secrets.GITHUB_TOKEN}}" \
67+
-fLo msys2-runtime.zip "$MSYS2_RUNTIME_ARTIFACT_URL" &&
68+
mkdir minimal-sdk &&
69+
cd minimal-sdk &&
70+
tar xzf ../git-sdk-x86_64-minimal.tar.gz &&
71+
unzip -qo ../msys2-runtime.zip &&
72+
tar cvf - * .[0-9A-Za-z]* | gzip -1 >../git-sdk-x86_64-minimal.tar.gz
73+
- name: upload minimal-sdk artifact
74+
uses: actions/upload-artifact@v4
75+
with:
76+
name: minimal-sdk
77+
path: git-sdk-x86_64-minimal.tar.gz
78+
- name: run `uname`
79+
run: minimal-sdk\usr\bin\uname.exe -a
80+
- name: determine where `git-artifacts` want to be extracted
81+
id: git-artifacts-extract-location
82+
shell: bash
83+
run: |
84+
echo "result=$(tar Oxf git-artifacts.tar.gz git/bin-wrappers/git |
85+
sed -n 's|^GIT_EXEC_PATH='\''\(.*\)/git'\''$|\1|p')" >>$GITHUB_OUTPUT
86+
- name: upload git artifacts for testing
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: git-artifacts
90+
path: git-artifacts.tar.gz
91+
test-minimal-sdk:
92+
runs-on: windows-latest
93+
needs: [minimal-sdk-artifact]
94+
strategy:
95+
matrix:
96+
# 0..16 permuted according to the matrix builds' timings as of git/git@9fadedd63
97+
nr: [9, 6, 13, 0, 8, 5, 2, 16, 15, 11, 10, 1, 7, 3, 14, 12, 4]
98+
fail-fast: false
99+
steps:
100+
- name: download minimal-sdk artifact
101+
uses: actions/download-artifact@v4
102+
with:
103+
name: minimal-sdk
104+
path: ${{github.workspace}}
105+
- name: uncompress minimal-sdk
106+
shell: bash
107+
run: |
108+
mkdir -p minimal-sdk &&
109+
tar -C minimal-sdk -xzf git-sdk-x86_64-minimal.tar.gz &&
110+
cygpath -aw minimal-sdk/usr/bin >>$GITHUB_PATH
111+
- name: download git artifacts
112+
uses: actions/download-artifact@v4
113+
with:
114+
name: git-artifacts
115+
path: ${{github.workspace}}
116+
- name: uncompress git-artifacts
117+
shell: bash
118+
env:
119+
GIT_ARTIFACTS_EXTRACT_LOCATION: ${{ needs.minimal-sdk-artifact.outputs.git-artifacts-extract-location }}
120+
run: |
121+
mkdir -p "$GIT_ARTIFACTS_EXTRACT_LOCATION" &&
122+
tar -C "$GIT_ARTIFACTS_EXTRACT_LOCATION" -xzf git-artifacts.tar.gz
123+
- name: test
124+
shell: bash
125+
run: |
126+
set -x
127+
. /etc/profile
128+
test "$(cygpath -aw /)" = "${{github.workspace}}\minimal-sdk" || exit 1
129+
cd "$GIT_ARTIFACTS_EXTRACT_LOCATION"/git/t &&
130+
make T="$(ls -S t[0-9]*.sh | awk '!((NR+${{matrix.nr}})%17)' | tr '\n' \ )" prove || {
131+
for d in trash*
132+
do
133+
t=${d#trash directory.}
134+
echo ===========================
135+
echo Failed: $t.sh
136+
cat test-results/$t.out
137+
done
138+
exit 1
139+
}
140+
env:
141+
GIT_ARTIFACTS_EXTRACT_LOCATION: ${{ needs.minimal-sdk-artifact.outputs.git-artifacts-extract-location }}
142+
PATH: ${{github.workspace}}\minimal-sdk\mingw64\bin;${{github.workspace}}\minimal-sdk\usr\bin;${{github.workspace}}\minimal-sdk\usr\bin\core_perl;C:\Windows\system32;C:\Windows;C:\Windows\system32\wbem
143+
GIT_TEST_OPTS: --verbose-log -x --no-chain-lint
144+
GIT_PROVE_OPTS: --timer --jobs 8
145+
NO_SVN_TESTS: 1
146+
assorted-validations:
147+
runs-on: windows-latest
148+
needs: [minimal-sdk-artifact]
149+
steps:
150+
- name: download minimal-sdk artifact
151+
uses: actions/download-artifact@v4
152+
with:
153+
name: minimal-sdk
154+
path: ${{github.workspace}}
155+
- name: uncompress minimal-sdk
156+
shell: bash
157+
run: |
158+
mkdir -p minimal-sdk &&
159+
tar -C minimal-sdk -xzf git-sdk-x86_64-minimal.tar.gz &&
160+
cygpath -aw minimal-sdk/usr/bin >>$GITHUB_PATH
161+
- name: run some tests
162+
shell: bash
163+
env:
164+
PATH: ${{github.workspace}}\minimal-sdk\mingw64\bin;${{github.workspace}}\minimal-sdk\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32\wbem
165+
run: |
166+
set -x
167+
. /etc/profile
168+
169+
# cygpath works
170+
test "$(cygpath -aw /)" = "${{github.workspace}}\minimal-sdk" || exit 1
171+
172+
# comes with GCC and can compile a DLL
173+
test "$(type -p gcc)" = "/mingw64/bin/gcc" || exit 1
174+
cat >dll.c <<-\EOF &&
175+
__attribute__((dllexport)) int increment(int i)
176+
{
177+
return i + 1;
178+
}
179+
EOF
180+
181+
gcc -Wall -g -O2 -shared -o sample.dll dll.c || exit 1
182+
ls -la
183+
184+
# stat works
185+
test "stat is /usr/bin/stat" = "$(type stat)" || exit 1
186+
stat /usr/bin/stat.exe || exit 1
187+
188+
# unzip works
189+
test "unzip is /usr/bin/unzip" = "$(type unzip)" || exit 1
190+
git init unzip-test &&
191+
echo TEST >unzip-test/README &&
192+
git -C unzip-test add -A &&
193+
git -C unzip-test -c user.name=A -c [email protected] commit -m 'Testing, testing...' &&
194+
git --git-dir=unzip-test/.git archive -o test.zip HEAD &&
195+
unzip -v test.zip >unzip-test.out &&
196+
cat unzip-test.out &&
197+
test "grep is /usr/bin/grep" = "$(type grep)" || exit 1
198+
grep README unzip-test.out

0 commit comments

Comments
 (0)