summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2021-05-26 00:43:30 -0700
committerGitHub <noreply@github.com>2021-05-26 09:43:30 +0200
commitc495628255330a559e3398663cc8872cca18b04d (patch)
treecf85c44fe30068263515dbfe53709ebc508c56de
parentb59dc3b255d778cefdbef2c0c3ff55d43892c11c (diff)
downloadNim-c495628255330a559e3398663cc8872cca18b04d.tar.gz
refactor common code in CI pipelines (#18035)
* refactor CI with nimInternalInstallDepsWindows

* refactor CI with nimInternalBuildKochAndRunCI

* fixup
-rw-r--r--.builds/freebsd.yml6
-rw-r--r--.builds/openbsd_0.yml6
-rw-r--r--.builds/openbsd_1.yml6
-rw-r--r--.github/workflows/ci_docs.yml8
-rw-r--r--.github/workflows/ci_packages.yml22
-rw-r--r--azure-pipelines.yml16
-rw-r--r--ci/funs.sh17
-rw-r--r--tools/ci_generate.nim6
8 files changed, 34 insertions, 53 deletions
diff --git a/.builds/freebsd.yml b/.builds/freebsd.yml
index 8f336771a..15d09dda0 100644
--- a/.builds/freebsd.yml
+++ b/.builds/freebsd.yml
@@ -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
diff --git a/.builds/openbsd_0.yml b/.builds/openbsd_0.yml
index c19cd63c6..c3b2fd43e 100644
--- a/.builds/openbsd_0.yml
+++ b/.builds/openbsd_0.yml
@@ -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
diff --git a/.builds/openbsd_1.yml b/.builds/openbsd_1.yml
index 06f5f2ae5..e98ec4640 100644
--- a/.builds/openbsd_1.yml
+++ b/.builds/openbsd_1.yml
@@ -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
diff --git a/.github/workflows/ci_docs.yml b/.github/workflows/ci_docs.yml
index 364c05051..ddef94fbe 100644
--- a/.github/workflows/ci_docs.yml
+++ b/.github/workflows/ci_docs.yml
@@ -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'
diff --git a/.github/workflows/ci_packages.yml b/.github/workflows/ci_packages.yml
index d033aba10..aeb29e147 100644
--- a/.github/workflows/ci_packages.yml
+++ b/.github/workflows/ci_packages.yml
@@ -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
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 112fb0a62..f0c3b2d0a 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -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)
diff --git a/ci/funs.sh b/ci/funs.sh
index 0e4f0eb3b..9772535be 100644
--- a/ci/funs.sh
+++ b/ci/funs.sh
@@ -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
diff --git a/tools/ci_generate.nim b/tools/ci_generate.nim
index f08cd5409..52b84f0d8 100644
--- a/tools/ci_generate.nim
+++ b/tools/ci_generate.nim
@@ -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