Skip to content

Commit c495628

Browse files
authored
refactor common code in CI pipelines (#18035)
* refactor CI with nimInternalInstallDepsWindows * refactor CI with nimInternalBuildKochAndRunCI * fixup
1 parent b59dc3b commit c495628

File tree

8 files changed

+34
-53
lines changed

8 files changed

+34
-53
lines changed

.builds/freebsd.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,11 @@ tasks:
2222
set -e
2323
cd Nim
2424
. ci/funs.sh && nimBuildCsourcesIfNeeded
25-
$nim_csources c --skipUserCfg --skipParentCfg koch
2625
echo 'export PATH=$HOME/Nim/bin:$PATH' >> $HOME/.buildenv
2726
- test: |
2827
set -e
2928
cd Nim
30-
if ! ./koch runCI; then
31-
nim r tools/ci_testresults.nim
32-
exit 1
33-
fi
29+
. ci/funs.sh && nimInternalBuildKochAndRunCI
3430
triggers:
3531
- action: email
3632
condition: failure

.builds/openbsd_0.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,11 @@ tasks:
2222
set -e
2323
cd Nim
2424
. ci/funs.sh && nimBuildCsourcesIfNeeded
25-
$nim_csources c --skipUserCfg --skipParentCfg koch
2625
echo 'export PATH=$HOME/Nim/bin:$PATH' >> $HOME/.buildenv
2726
- test: |
2827
set -e
2928
cd Nim
30-
if ! ./koch runCI; then
31-
nim r tools/ci_testresults.nim
32-
exit 1
33-
fi
29+
. ci/funs.sh && nimInternalBuildKochAndRunCI
3430
triggers:
3531
- action: email
3632
condition: failure

.builds/openbsd_1.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,11 @@ tasks:
2222
set -e
2323
cd Nim
2424
. ci/funs.sh && nimBuildCsourcesIfNeeded
25-
$nim_csources c --skipUserCfg --skipParentCfg koch
2625
echo 'export PATH=$HOME/Nim/bin:$PATH' >> $HOME/.buildenv
2726
- test: |
2827
set -e
2928
cd Nim
30-
if ! ./koch runCI; then
31-
nim r tools/ci_testresults.nim
32-
exit 1
33-
fi
29+
. ci/funs.sh && nimInternalBuildKochAndRunCI
3430
triggers:
3531
- action: email
3632
condition: failure

.github/workflows/ci_docs.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,9 @@ jobs:
5959
if: runner.os == 'Windows'
6060
shell: bash
6161
run: |
62-
mkdir dist
63-
curl -L https://nim-lang.org/download/mingw64.7z -o dist/mingw64.7z
64-
curl -L https://nim-lang.org/download/dlls.zip -o dist/dlls.zip
65-
7z x dist/mingw64.7z -odist
66-
7z x dist/dlls.zip -obin
62+
set -e
63+
. ci/funs.sh
64+
nimInternalInstallDepsWindows
6765
echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}"
6866
6967
- name: 'Add build binaries to PATH'

.github/workflows/ci_packages.yml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@ jobs:
4040
if: runner.os == 'Windows'
4141
shell: bash
4242
run: |
43-
mkdir dist
44-
curl -L https://nim-lang.org/download/mingw64.7z -o dist/mingw64.7z
45-
curl -L https://nim-lang.org/download/dlls.zip -o dist/dlls.zip
46-
7z x dist/mingw64.7z -odist
47-
7z x dist/dlls.zip -obin
48-
echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}"
43+
set -e
44+
. ci/funs.sh
45+
nimInternalInstallDepsWindows
46+
echo_run echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}"
4947
5048
- name: 'Add build binaries to PATH'
5149
shell: bash
@@ -59,14 +57,6 @@ jobs:
5957
shell: bash
6058
run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc ucpu='${{ matrix.cpu }}'
6159

62-
- name: 'Build koch'
60+
- name: 'koch, Run CI'
6361
shell: bash
64-
run: nim c koch
65-
- name: 'Run CI'
66-
shell: bash
67-
run: ./koch runCI
68-
69-
- name: 'Show failed tests'
70-
if: failure()
71-
shell: bash
72-
run: nim c -r tools/ci_testresults.nim
62+
run: . ci/funs.sh && nimInternalBuildKochAndRunCI

azure-pipelines.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,7 @@ jobs:
133133
- bash: |
134134
set -e
135135
. ci/funs.sh
136-
echo_run mkdir dist
137-
echo_run curl -L https://nim-lang.org/download/mingw64.7z -o dist/mingw64.7z
138-
echo_run curl -L https://nim-lang.org/download/dlls.zip -o dist/dlls.zip
139-
echo_run 7z x dist/mingw64.7z -odist
140-
echo_run 7z x dist/dlls.zip -obin
136+
nimInternalInstallDepsWindows
141137
echo_run echo '##vso[task.prependpath]$(System.DefaultWorkingDirectory)/dist/mingw64/bin'
142138
143139
displayName: 'Install dependencies (Windows)'
@@ -163,13 +159,9 @@ jobs:
163159
# condition: and(succeeded(), eq(variables['skipci'], 'false'))
164160
# displayName: 'Restore built csourcesAny'
165161

166-
- bash: nim c koch
162+
- bash: . ci/funs.sh && nimInternalBuildKochAndRunCI
163+
# would could also show on failure: echo '##vso[task.complete result=Failed]'
167164
condition: and(succeeded(), eq(variables['skipci'], 'false'))
168-
displayName: 'Build koch'
169-
170-
# set result to omit the "bash exited with error code '1'" message
171-
- bash: ./koch runCI || echo '##vso[task.complete result=Failed]'
172-
condition: and(succeeded(), eq(variables['skipci'], 'false'))
173-
displayName: 'Run CI'
165+
displayName: 'koch, Run CI'
174166
env:
175167
SYSTEM_ACCESSTOKEN: $(System.AccessToken)

ci/funs.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,23 @@ nimIsCiSkip(){
3131
fi
3232
}
3333

34+
nimInternalInstallDepsWindows(){
35+
echo_run mkdir dist
36+
echo_run curl -L https://nim-lang.org/download/mingw64.7z -o dist/mingw64.7z
37+
echo_run curl -L https://nim-lang.org/download/dlls.zip -o dist/dlls.zip
38+
echo_run 7z x dist/mingw64.7z -odist
39+
echo_run 7z x dist/dlls.zip -obin
40+
}
41+
42+
nimInternalBuildKochAndRunCI(){
43+
echo_run nim c koch
44+
if ! echo_run ./koch runCI; then
45+
echo_run echo "runCI failed"
46+
echo_run nim r -tools/ci_testresults.nim
47+
return 1
48+
fi
49+
}
50+
3451
nimDefineVars(){
3552
. config/build_config.txt
3653
nim_csources=bin/nim_csources_$nim_csourcesHash

tools/ci_generate.nim

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,11 @@ tasks:
2929
set -e
3030
cd Nim
3131
. ci/funs.sh && nimBuildCsourcesIfNeeded
32-
$nim_csources c --skipUserCfg --skipParentCfg koch
3332
echo 'export PATH=$HOME/Nim/bin:$PATH' >> $HOME/.buildenv
3433
- test: |
3534
set -e
3635
cd Nim
37-
if ! ./koch runCI; then
38-
nim r tools/ci_testresults.nim
39-
exit 1
40-
fi
36+
. ci/funs.sh && nimInternalBuildKochAndRunCI
4137
triggers:
4238
- action: email
4339
condition: failure

0 commit comments

Comments
 (0)