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
parent b59dc3b255
commit c495628255
8 changed files with 34 additions and 53 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -133,11 +133,7 @@ jobs:
- bash: |
set -e
. ci/funs.sh
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
nimInternalInstallDepsWindows
echo_run echo '##vso[task.prependpath]$(System.DefaultWorkingDirectory)/dist/mingw64/bin'
displayName: 'Install dependencies (Windows)'
@@ -163,13 +159,9 @@ jobs:
# condition: and(succeeded(), eq(variables['skipci'], 'false'))
# 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'))
displayName: 'Build koch'
# 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'
displayName: 'koch, Run CI'
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)

View File

@@ -31,6 +31,23 @@ nimIsCiSkip(){
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(){
. config/build_config.txt
nim_csources=bin/nim_csources_$nim_csourcesHash

View File

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