Skip to content

Commit 58a3be4

Browse files
committed
Merge branch 'ps/ci-gitlab-windows' into next
Enable Windows-based CI in GitLab. * ps/ci-gitlab-windows: gitlab-ci: exercise Git on Windows gitlab-ci: introduce stages and dependencies ci: handle Windows-based CI jobs in GitLab CI ci: create script to set up Git for Windows SDK t7300: work around platform-specific behaviour with long paths on MinGW
2 parents 899fb7e + 631ddbb commit 58a3be4

File tree

5 files changed

+87
-12
lines changed

5 files changed

+87
-12
lines changed

.github/workflows/main.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,15 @@ jobs:
113113
cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
114114
steps:
115115
- uses: actions/checkout@v4
116-
- uses: git-for-windows/setup-git-for-windows-sdk@v1
116+
- name: setup SDK
117+
shell: powershell
118+
run: ci/install-sdk.ps1
117119
- name: build
118-
shell: bash
120+
shell: powershell
119121
env:
120122
HOME: ${{runner.workspace}}
121123
NO_PERL: 1
122-
run: . /etc/profile && ci/make-test-artifacts.sh artifacts
124+
run: git-sdk/usr/bin/bash.exe -l -c 'ci/make-test-artifacts.sh artifacts'
123125
- name: zip up tracked files
124126
run: git archive -o artifacts/tracked.tar.gz HEAD
125127
- name: upload tracked files and build artifacts
@@ -147,10 +149,12 @@ jobs:
147149
- name: extract tracked files and build artifacts
148150
shell: bash
149151
run: tar xf artifacts.tar.gz && tar xf tracked.tar.gz
150-
- uses: git-for-windows/setup-git-for-windows-sdk@v1
152+
- name: setup SDK
153+
shell: powershell
154+
run: ci/install-sdk.ps1
151155
- name: test
152-
shell: bash
153-
run: . /etc/profile && ci/run-test-slice.sh ${{matrix.nr}} 10
156+
shell: powershell
157+
run: git-sdk/usr/bin/bash.exe -l -c 'ci/run-test-slice.sh ${{matrix.nr}} 10'
154158
- name: print test failures
155159
if: failure() && env.FAILED_TEST_ARTIFACTS != ''
156160
shell: bash

.gitlab-ci.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
default:
22
timeout: 2h
33

4+
stages:
5+
- build
6+
- test
7+
- analyze
8+
49
workflow:
510
rules:
611
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
@@ -9,6 +14,8 @@ workflow:
914

1015
test:linux:
1116
image: $image
17+
stage: test
18+
needs: [ ]
1219
tags:
1320
- saas-linux-medium-amd64
1421
variables:
@@ -67,6 +74,8 @@ test:linux:
6774

6875
test:osx:
6976
image: $image
77+
stage: test
78+
needs: [ ]
7079
tags:
7180
- saas-macos-medium-m1
7281
variables:
@@ -100,8 +109,42 @@ test:osx:
100109
- t/failed-test-artifacts
101110
when: on_failure
102111

112+
build:mingw64:
113+
stage: build
114+
tags:
115+
- saas-windows-medium-amd64
116+
variables:
117+
NO_PERL: 1
118+
before_script:
119+
- ./ci/install-sdk.ps1 -directory "git-sdk"
120+
script:
121+
- git-sdk/usr/bin/bash.exe -l -c 'ci/make-test-artifacts.sh artifacts'
122+
artifacts:
123+
paths:
124+
- artifacts
125+
- git-sdk
126+
127+
test:mingw64:
128+
stage: test
129+
tags:
130+
- saas-windows-medium-amd64
131+
needs:
132+
- job: "build:mingw64"
133+
artifacts: true
134+
before_script:
135+
- git-sdk/usr/bin/bash.exe -l -c 'tar xf artifacts/artifacts.tar.gz'
136+
- New-Item -Path .git/info -ItemType Directory
137+
- New-Item .git/info/exclude -ItemType File -Value "/git-sdk"
138+
script:
139+
- git-sdk/usr/bin/bash.exe -l -c "ci/run-test-slice.sh $CI_NODE_INDEX $CI_NODE_TOTAL"
140+
after_script:
141+
- git-sdk/usr/bin/bash.exe -l -c 'ci/print-test-failures.sh'
142+
parallel: 10
143+
103144
test:fuzz-smoke-tests:
104145
image: ubuntu:latest
146+
stage: test
147+
needs: [ ]
105148
variables:
106149
CC: clang
107150
before_script:
@@ -111,6 +154,8 @@ test:fuzz-smoke-tests:
111154

112155
static-analysis:
113156
image: ubuntu:22.04
157+
stage: analyze
158+
needs: [ ]
114159
variables:
115160
jobname: StaticAnalysis
116161
before_script:
@@ -121,6 +166,8 @@ static-analysis:
121166

122167
check-whitespace:
123168
image: ubuntu:latest
169+
stage: analyze
170+
needs: [ ]
124171
before_script:
125172
- ./ci/install-dependencies.sh
126173
# Since $CI_MERGE_REQUEST_TARGET_BRANCH_SHA is only defined for merged
@@ -135,6 +182,8 @@ check-whitespace:
135182

136183
check-style:
137184
image: ubuntu:latest
185+
stage: analyze
186+
needs: [ ]
138187
allow_failure: true
139188
variables:
140189
CC: clang
@@ -153,6 +202,8 @@ check-style:
153202

154203
documentation:
155204
image: ubuntu:latest
205+
stage: analyze
206+
needs: [ ]
156207
variables:
157208
jobname: Documentation
158209
before_script:

ci/install-sdk.ps1

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
param(
2+
[string]$directory='git-sdk',
3+
[string]$url='https://github.com/git-for-windows/git-sdk-64/releases/download/ci-artifacts/git-sdk-x86_64-minimal.zip'
4+
)
5+
6+
Invoke-WebRequest "$url" -OutFile git-sdk.zip
7+
Expand-Archive -LiteralPath git-sdk.zip -DestinationPath "$directory"
8+
Remove-Item -Path git-sdk.zip
9+
10+
New-Item -Path .git/info -ItemType Directory -Force
11+
New-Item -Path .git/info/exclude -ItemType File -Force
12+
Add-Content -Path .git/info/exclude -Value "/$directory"

ci/lib.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,18 +250,26 @@ then
250250
CI_TYPE=gitlab-ci
251251
CI_BRANCH="$CI_COMMIT_REF_NAME"
252252
CI_COMMIT="$CI_COMMIT_SHA"
253-
case "$CI_JOB_IMAGE" in
254-
macos-*)
253+
254+
case "$OS,$CI_JOB_IMAGE" in
255+
Windows_NT,*)
256+
CI_OS_NAME=windows
257+
JOBS=$NUMBER_OF_PROCESSORS
258+
;;
259+
*,macos-*)
255260
# GitLab CI has Python installed via multiple package managers,
256261
# most notably via asdf and Homebrew. Ensure that our builds
257262
# pick up the Homebrew one by prepending it to our PATH as the
258263
# asdf one breaks tests.
259264
export PATH="$(brew --prefix)/bin:$PATH"
260265

261266
CI_OS_NAME=osx
267+
JOBS=$(nproc)
268+
;;
269+
*,alpine:*|*,fedora:*|*,ubuntu:*)
270+
CI_OS_NAME=linux
271+
JOBS=$(nproc)
262272
;;
263-
alpine:*|fedora:*|ubuntu:*)
264-
CI_OS_NAME=linux;;
265273
*)
266274
echo "Could not identify OS image" >&2
267275
env >&2
@@ -272,6 +280,7 @@ then
272280
CI_JOB_ID="$CI_JOB_ID"
273281
CC="${CC_PACKAGE:-${CC:-gcc}}"
274282
DONT_SKIP_TAGS=t
283+
275284
handle_failed_tests () {
276285
create_failed_test_artifacts
277286
return 1
@@ -280,7 +289,6 @@ then
280289
cache_dir="$HOME/none"
281290

282291
distro=$(echo "$CI_JOB_IMAGE" | tr : -)
283-
JOBS=$(nproc)
284292
else
285293
echo "Could not identify CI type" >&2
286294
env >&2

t/t7300-clean.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ test_expect_success MINGW 'handle clean & core.longpaths = false nicely' '
747747
test_must_fail git clean -xdf 2>.git/err &&
748748
# grepping for a strerror string is unportable but it is OK here with
749749
# MINGW prereq
750-
test_grep "too long" .git/err
750+
test_grep -e "too long" -e "No such file or directory" .git/err
751751
'
752752

753753
test_expect_success 'clean untracked paths by pathspec' '

0 commit comments

Comments
 (0)