followup #17561, skipping ci now implies green (#17813)

* followup #17561, skip ci now implies green; [skip ci]
* fixup [skip ci]
* fixup test without skip ci
* fixup [skip ci]
* fixup2 [skip ci]
* github actions now automatically supports [skip ci]
This commit is contained in:
Timothee Cour 2021-04-23 01:05:23 -07:00 • committed by GitHub
commit dbb053492a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 33 deletions

View file

@ -30,9 +30,6 @@ on:
jobs: jobs:
build: build:
# see D20210329T004830
if: |
!contains(format('{0}', github.event.pull_request.title), '[skip ci]')
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -54,14 +51,6 @@ jobs:
with: with:
fetch-depth: 2 fetch-depth: 2
- name: 'Check whether to skip CI'
shell: bash
run: |
# see D20210329T004830
commitMsg=$(git log --no-merges -1 --pretty=format:"%s")
echo commitMsg: $commitMsg
echo $commitMsg | grep -v '\[skip ci\]'
- name: 'Install build dependencies (macOS)' - name: 'Install build dependencies (macOS)'
if: runner.os == 'macOS' if: runner.os == 'macOS'
run: brew install make run: brew install make

View file

@ -3,9 +3,6 @@ on: [push, pull_request]
jobs: jobs:
build: build:
# see D20210329T004830
if: |
!contains(format('{0}', github.event.pull_request.title), '[skip ci]')
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -23,14 +20,6 @@ jobs:
with: with:
fetch-depth: 2 fetch-depth: 2
- name: 'Check whether to skip CI'
shell: bash
run: |
# see D20210329T004830
commitMsg=$(git log --no-merges -1 --pretty=format:"%s")
echo commitMsg: $commitMsg
echo $commitMsg | grep -v '\[skip ci\]'
- name: 'Checkout csources' - name: 'Checkout csources'
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:

View file

@ -7,6 +7,10 @@ pr:
include: include:
- '*' - '*'
variables:
- name: skipci
value: false
jobs: jobs:
- job: packages - job: packages
@ -58,22 +62,22 @@ jobs:
fetchDepth: 2 # see D20210329T004830 fetchDepth: 2 # see D20210329T004830
- bash: | - bash: |
# D20210329T004830:here refs https://github.com/microsoft/azure-pipelines-agent/issues/2944 set -e
# `--no-merges` is needed to avoid merge commits which occur for PR's. . ci/funs.sh
# $(Build.SourceVersionMessage) is not helpful if nimIsCiSkip; then
# nor is `github.event.head_commit.message` for github actions. echo '##vso[task.setvariable variable=skipci]true'
commitMsg=$(git log --no-merges -1 --pretty=format:"%s") fi
echo commitMsg: $commitMsg
echo $commitMsg | grep -v '\[skip ci\]' # fails if [skip ci] not in commit msg
displayName: 'Check whether to skip CI' displayName: 'Check whether to skip CI'
- bash: git clone --depth 1 https://github.com/nim-lang/csources_v1 csources - bash: git clone --depth 1 https://github.com/nim-lang/csources_v1 csources
displayName: 'Checkout Nim csources' displayName: 'Checkout Nim csources'
condition: and(succeeded(), eq(variables['skipci'], 'false'))
- task: NodeTool@0 - task: NodeTool@0
inputs: inputs:
versionSpec: '12.x' versionSpec: '12.x'
displayName: 'Install node.js 12.x' displayName: 'Install node.js 12.x'
condition: and(succeeded(), eq(variables['skipci'], 'false'))
- bash: | - bash: |
set -e set -e
@ -83,7 +87,7 @@ jobs:
echo_run sudo apt-fast install --no-install-recommends -yq \ echo_run sudo apt-fast install --no-install-recommends -yq \
libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev valgrind libc6-dbg libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev valgrind libc6-dbg
displayName: 'Install dependencies (amd64 Linux)' displayName: 'Install dependencies (amd64 Linux)'
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'), eq(variables['CPU'], 'amd64')) condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Linux'), eq(variables['CPU'], 'amd64'))
- bash: | - bash: |
set -e set -e
@ -123,11 +127,11 @@ jobs:
echo_run chmod 755 bin/g++ echo_run chmod 755 bin/g++
displayName: 'Install dependencies (i386 Linux)' displayName: 'Install dependencies (i386 Linux)'
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'), eq(variables['CPU'], 'i386')) condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Linux'), eq(variables['CPU'], 'i386'))
- bash: brew install boehmgc make sfml - bash: brew install boehmgc make sfml
displayName: 'Install dependencies (OSX)' displayName: 'Install dependencies (OSX)'
condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin')) condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Darwin'))
- bash: | - bash: |
set -e set -e
@ -140,9 +144,10 @@ jobs:
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)'
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Windows_NT'))
- bash: echo '##vso[task.prependpath]$(System.DefaultWorkingDirectory)/bin' - bash: echo '##vso[task.prependpath]$(System.DefaultWorkingDirectory)/bin'
condition: and(succeeded(), eq(variables['skipci'], 'false'))
displayName: 'Add build binaries to PATH' displayName: 'Add build binaries to PATH'
- bash: | - bash: |
@ -155,15 +160,18 @@ jobs:
echo_run node -v echo_run node -v
echo_run echo '##[section]make version' echo_run echo '##[section]make version'
echo_run make -v echo_run make -v
condition: and(succeeded(), eq(variables['skipci'], 'false'))
displayName: 'System information' displayName: 'System information'
- bash: echo '##vso[task.setvariable variable=csources_version]'"$(git -C csources rev-parse HEAD)" - bash: echo '##vso[task.setvariable variable=csources_version]'"$(git -C csources rev-parse HEAD)"
condition: and(succeeded(), eq(variables['skipci'], 'false'))
displayName: 'Get csources version' displayName: 'Get csources version'
- task: Cache@2 - task: Cache@2
inputs: inputs:
key: 'csources | "$(Agent.OS)" | $(CPU) | $(csources_version)' key: 'csources | "$(Agent.OS)" | $(CPU) | $(csources_version)'
path: csources/bin path: csources/bin
condition: and(succeeded(), eq(variables['skipci'], 'false'))
displayName: 'Restore built csources' displayName: 'Restore built csources'
- bash: | - bash: |
@ -192,13 +200,16 @@ jobs:
fi fi
echo_run cp csources/bin/nim$ext bin echo_run cp csources/bin/nim$ext bin
condition: and(succeeded(), eq(variables['skipci'], 'false'))
displayName: 'Build 1-stage compiler from csources' displayName: 'Build 1-stage compiler from csources'
- bash: nim c koch - bash: nim c koch
condition: and(succeeded(), eq(variables['skipci'], 'false'))
displayName: 'Build koch' displayName: 'Build koch'
# set result to omit the "bash exited with error code '1'" message # set result to omit the "bash exited with error code '1'" message
- bash: ./koch runCI || echo '##vso[task.complete result=Failed]' - bash: ./koch runCI || echo '##vso[task.complete result=Failed]'
condition: and(succeeded(), eq(variables['skipci'], 'false'))
displayName: 'Run CI' displayName: 'Run CI'
env: env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken) SYSTEM_ACCESSTOKEN: $(System.AccessToken)

View file

@ -1,4 +1,5 @@
# utilities used in CI pipelines to avoid duplication. # utilities used in CI pipelines to avoid duplication.
# Avoid top-level statements.
echo_run () { echo_run () {
# echo's a command before running it, which helps understanding logs # echo's a command before running it, which helps understanding logs
@ -6,3 +7,24 @@ echo_run () {
echo "$@" echo "$@"
"$@" "$@"
} }
nimGetLastCommit() {
git log --no-merges -1 --pretty=format:"%s"
}
nimIsCiSkip(){
# D20210329T004830:here refs https://github.com/microsoft/azure-pipelines-agent/issues/2944
# `--no-merges` is needed to avoid merge commits which occur for PR's.
# $(Build.SourceVersionMessage) is not helpful
# nor is `github.event.head_commit.message` for github actions.
# Note: `[skip ci]` is now handled automatically for github actions, see https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/
commitMsg=$(nimGetLastCommit)
echo commitMsg: "$commitMsg"
if [[ $commitMsg == *"[skip ci]"* ]]; then
echo "skipci: true"
return 0
else
echo "skipci: false"
return 1
fi
}