refactor common code in CI pipelines (#18035)

* refactor CI with nimInternalInstallDepsWindows

* refactor CI with nimInternalBuildKochAndRunCI

* fixup
This commit is contained in:
Timothee Cour 2021-05-26 00:43:30 -07:00 • committed by GitHub
commit c495628255
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 34 additions and 53 deletions

View file

@ -22,15 +22,11 @@ tasks:
set -e set -e
cd Nim cd Nim
. ci/funs.sh && nimBuildCsourcesIfNeeded . ci/funs.sh && nimBuildCsourcesIfNeeded
$nim_csources c --skipUserCfg --skipParentCfg koch
echo 'export PATH=$HOME/Nim/bin:$PATH' >> $HOME/.buildenv echo 'export PATH=$HOME/Nim/bin:$PATH' >> $HOME/.buildenv
- test: | - test: |
set -e set -e
cd Nim cd Nim
if ! ./koch runCI; then . ci/funs.sh && nimInternalBuildKochAndRunCI
nim r tools/ci_testresults.nim
exit 1
fi
triggers: triggers:
- action: email - action: email
condition: failure condition: failure

View file

@ -22,15 +22,11 @@ tasks:
set -e set -e
cd Nim cd Nim
. ci/funs.sh && nimBuildCsourcesIfNeeded . ci/funs.sh && nimBuildCsourcesIfNeeded
$nim_csources c --skipUserCfg --skipParentCfg koch
echo 'export PATH=$HOME/Nim/bin:$PATH' >> $HOME/.buildenv echo 'export PATH=$HOME/Nim/bin:$PATH' >> $HOME/.buildenv
- test: | - test: |
set -e set -e
cd Nim cd Nim
if ! ./koch runCI; then . ci/funs.sh && nimInternalBuildKochAndRunCI
nim r tools/ci_testresults.nim
exit 1
fi
triggers: triggers:
- action: email - action: email
condition: failure condition: failure

View file

@ -22,15 +22,11 @@ tasks:
set -e set -e
cd Nim cd Nim
. ci/funs.sh && nimBuildCsourcesIfNeeded . ci/funs.sh && nimBuildCsourcesIfNeeded
$nim_csources c --skipUserCfg --skipParentCfg koch
echo 'export PATH=$HOME/Nim/bin:$PATH' >> $HOME/.buildenv echo 'export PATH=$HOME/Nim/bin:$PATH' >> $HOME/.buildenv
- test: | - test: |
set -e set -e
cd Nim cd Nim
if ! ./koch runCI; then . ci/funs.sh && nimInternalBuildKochAndRunCI
nim r tools/ci_testresults.nim
exit 1
fi
triggers: triggers:
- action: email - action: email
condition: failure condition: failure

View file

@ -59,11 +59,9 @@ jobs:
if: runner.os == 'Windows' if: runner.os == 'Windows'
shell: bash shell: bash
run: | run: |
mkdir dist set -e
curl -L https://nim-lang.org/download/mingw64.7z -o dist/mingw64.7z . ci/funs.sh
curl -L https://nim-lang.org/download/dlls.zip -o dist/dlls.zip nimInternalInstallDepsWindows
7z x dist/mingw64.7z -odist
7z x dist/dlls.zip -obin
echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}" echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}"
- name: 'Add build binaries to PATH' - name: 'Add build binaries to PATH'

View file

@ -40,12 +40,10 @@ jobs:
if: runner.os == 'Windows' if: runner.os == 'Windows'
shell: bash shell: bash
run: | run: |
mkdir dist set -e
curl -L https://nim-lang.org/download/mingw64.7z -o dist/mingw64.7z . ci/funs.sh
curl -L https://nim-lang.org/download/dlls.zip -o dist/dlls.zip nimInternalInstallDepsWindows
7z x dist/mingw64.7z -odist echo_run echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}"
7z x dist/dlls.zip -obin
echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}"
- name: 'Add build binaries to PATH' - name: 'Add build binaries to PATH'
shell: bash shell: bash
@ -59,14 +57,6 @@ jobs:
shell: bash shell: bash
run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc ucpu='${{ matrix.cpu }}' run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc ucpu='${{ matrix.cpu }}'
- name: 'Build koch' - name: 'koch, Run CI'
shell: bash shell: bash
run: nim c koch run: . ci/funs.sh && nimInternalBuildKochAndRunCI
- name: 'Run CI'
shell: bash
run: ./koch runCI
- name: 'Show failed tests'
if: failure()
shell: bash
run: nim c -r tools/ci_testresults.nim

View file

@ -133,11 +133,7 @@ jobs:
- bash: | - bash: |
set -e set -e
. ci/funs.sh . ci/funs.sh
echo_run mkdir dist nimInternalInstallDepsWindows
echo_run curl -L https://nim-lang.org/download/mingw64.7z -o dist/mingw64.7z
echo_run curl -L https://nim-lang.org/download/dlls.zip -o dist/dlls.zip
echo_run 7z x dist/mingw64.7z -odist
echo_run 7z x dist/dlls.zip -obin
echo_run echo '##vso[task.prependpath]$(System.DefaultWorkingDirectory)/dist/mingw64/bin' echo_run echo '##vso[task.prependpath]$(System.DefaultWorkingDirectory)/dist/mingw64/bin'
displayName: 'Install dependencies (Windows)' displayName: 'Install dependencies (Windows)'
@ -163,13 +159,9 @@ jobs:
# condition: and(succeeded(), eq(variables['skipci'], 'false')) # condition: and(succeeded(), eq(variables['skipci'], 'false'))
# displayName: 'Restore built csourcesAny' # displayName: 'Restore built csourcesAny'
- bash: nim c koch - bash: . ci/funs.sh && nimInternalBuildKochAndRunCI
# would could also show on failure: echo '##vso[task.complete result=Failed]'
condition: and(succeeded(), eq(variables['skipci'], 'false')) condition: and(succeeded(), eq(variables['skipci'], 'false'))
displayName: 'Build koch' displayName: 'koch, Run CI'
# set result to omit the "bash exited with error code '1'" message
- bash: ./koch runCI || echo '##vso[task.complete result=Failed]'
condition: and(succeeded(), eq(variables['skipci'], 'false'))
displayName: 'Run CI'
env: env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken) SYSTEM_ACCESSTOKEN: $(System.AccessToken)

View file

@ -31,6 +31,23 @@ nimIsCiSkip(){
fi fi
} }
nimInternalInstallDepsWindows(){
echo_run mkdir dist
echo_run curl -L https://nim-lang.org/download/mingw64.7z -o dist/mingw64.7z
echo_run curl -L https://nim-lang.org/download/dlls.zip -o dist/dlls.zip
echo_run 7z x dist/mingw64.7z -odist
echo_run 7z x dist/dlls.zip -obin
}
nimInternalBuildKochAndRunCI(){
echo_run nim c koch
if ! echo_run ./koch runCI; then
echo_run echo "runCI failed"
echo_run nim r -tools/ci_testresults.nim
return 1
fi
}
nimDefineVars(){ nimDefineVars(){
. config/build_config.txt . config/build_config.txt
nim_csources=bin/nim_csources_$nim_csourcesHash nim_csources=bin/nim_csources_$nim_csourcesHash

View file

@ -29,15 +29,11 @@ tasks:
set -e set -e
cd Nim cd Nim
. ci/funs.sh && nimBuildCsourcesIfNeeded . ci/funs.sh && nimBuildCsourcesIfNeeded
$nim_csources c --skipUserCfg --skipParentCfg koch
echo 'export PATH=$HOME/Nim/bin:$PATH' >> $HOME/.buildenv echo 'export PATH=$HOME/Nim/bin:$PATH' >> $HOME/.buildenv
- test: | - test: |
set -e set -e
cd Nim cd Nim
if ! ./koch runCI; then . ci/funs.sh && nimInternalBuildKochAndRunCI
nim r tools/ci_testresults.nim
exit 1
fi
triggers: triggers:
- action: email - action: email
condition: failure condition: failure