Skip to content

Commit

Permalink
Merge pull request #54 from Integreat/IGAPP-338-skip-job
Browse files Browse the repository at this point in the history
IGAPP-338: Disable deliveries with environment variables
  • Loading branch information
maxammann authored Oct 31, 2020
2 parents 0ee6219 + cd45b2e commit 1fd836f
Show file tree
Hide file tree
Showing 20 changed files with 97 additions and 1 deletion.
46 changes: 46 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,32 @@ commands:
paths:
- ~/.cache/yarn-tools
- tools/node_modules
skip_job:
description: Skips the current build if neccassary
parameters:
build_config_name:
default: all
enum:
- integreat
- malte
- integreat-e2e
- integreat-test-cms
- all
type: enum
steps:
- run:
command: |
function skip_job {
build_config_name=$1
variable_name=SKIP_JOB_${CIRCLE_JOB%-*} # Remove everything after "-". e.g. "check_web-1" -> check_web
if [[ -n ${!variable_name} && ($build_config_name =~ ${!variable_name} || "all" =~ ${!variable_name}) ]]; then
echo "This job is skipped because the variable $variable_name is set"
circleci step halt
fi
}
skip_job << parameters.build_config_name >>
name: Skip the current build if neccassary
jobs:
build_android:
docker:
Expand All @@ -165,6 +191,8 @@ jobs:
resource_class: medium
shell: /bin/bash -eo pipefail
steps:
- skip_job:
build_config_name: << parameters.build_config_name >>
- add_ssh_keys:
fingerprints:
- 61:d8:94:00:53:5f:3b:19:fd:88:6b:fa:cd:ca:df:5d
Expand Down Expand Up @@ -218,6 +246,8 @@ jobs:
resource_class: medium
shell: /bin/bash --login -o pipefail
steps:
- skip_job:
build_config_name: << parameters.build_config_name >>
- add_ssh_keys:
fingerprints:
- 61:d8:94:00:53:5f:3b:19:fd:88:6b:fa:cd:ca:df:5d
Expand Down Expand Up @@ -259,6 +289,8 @@ jobs:
resource_class: small
shell: /bin/bash -eo pipefail
steps:
- skip_job:
build_config_name: << parameters.build_config_name >>
- checkout
- restore_yarn_cache
- run:
Expand Down Expand Up @@ -288,6 +320,7 @@ jobs:
type: enum
resource_class: small
steps:
- skip_job
- checkout
- restore_yarn_tools_cache
- run:
Expand Down Expand Up @@ -330,6 +363,7 @@ jobs:
resource_class: small
shell: /bin/bash -eo pipefail
steps:
- skip_job
- checkout
- check_config
- restore_yarn_cache
Expand All @@ -352,6 +386,7 @@ jobs:
resource_class: small
shell: /bin/bash -eo pipefail
steps:
- skip_job
- checkout
- check_config
- restore_yarn_cache
Expand Down Expand Up @@ -386,6 +421,8 @@ jobs:
resource_class: small
shell: /bin/bash -eo pipefail
steps:
- skip_job:
build_config_name: << parameters.build_config_name >>
- run: curl -sL https://sentry.io/get-cli/ | bash
- checkout
- prepare_workspace
Expand Down Expand Up @@ -430,6 +467,8 @@ jobs:
type: boolean
shell: /bin/bash --login -o pipefail
steps:
- skip_job:
build_config_name: << parameters.build_config_name >>
- run: curl -sL https://sentry.io/get-cli/ | bash
- checkout
- prepare_workspace
Expand Down Expand Up @@ -477,6 +516,7 @@ jobs:
resource_class: small
shell: /bin/bash -eo pipefail
steps:
- skip_job
- add_ssh_keys:
fingerprints:
- 68:a3:fe:e7:94:f7:a4:13:35:5c:63:30:2f:07:7d:02
Expand Down Expand Up @@ -508,6 +548,7 @@ jobs:
resource_class: small
shell: /bin/bash -eo pipefail
steps:
- skip_job
- checkout
- prepare_workspace
- restore_yarn_cache
Expand All @@ -526,6 +567,7 @@ jobs:
resource_class: small
shell: /bin/bash -eo pipefail
steps:
- skip_job
- checkout
- prepare_workspace
- restore_yarn_cache
Expand All @@ -541,6 +583,7 @@ jobs:
- image: circleci/node:12.16.3
resource_class: small
steps:
- skip_job
- checkout
- prepare_workspace
- restore_environment_variables
Expand All @@ -558,6 +601,7 @@ jobs:
type: boolean
resource_class: small
steps:
- skip_job
- checkout
- prepare_workspace
- restore_environment_variables
Expand All @@ -581,6 +625,7 @@ jobs:
type: boolean
resource_class: small
steps:
- skip_job
- checkout
- prepare_workspace
- restore_environment_variables
Expand All @@ -600,6 +645,7 @@ jobs:
- image: circleci/node:12.16.3
resource_class: small
steps:
- skip_job
- checkout
- prepare_workspace
- restore_environment_variables
Expand Down
1 change: 1 addition & 0 deletions .circleci/src/commands/check_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ steps:
command: yarn run circleci:update-config
- run: # Taken from https://github.com/roopakv/orbs/blob/master/src/commands/fail_if_dirty.yml
name: CircleCI config up to date
# language=bash
command: |
FILES_MODIFIED=""
setcommit () {
Expand Down
21 changes: 21 additions & 0 deletions .circleci/src/commands/skip_job.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
description: Skips the current build if neccassary
parameters:
build_config_name:
type: enum
enum: [integreat, malte, integreat-e2e, integreat-test-cms, "all"]
default: "all"
steps:
- run:
name: Skip the current build if neccassary
# language=bash
command: |
function skip_job {
build_config_name=$1
variable_name=SKIP_JOB_${CIRCLE_JOB%-*} # Remove everything after "-". e.g. "check_web-1" -> check_web
if [[ -n ${!variable_name} && ($build_config_name =~ ${!variable_name} || "all" =~ ${!variable_name}) ]]; then
echo "This job is skipped because the variable $variable_name is set"
circleci step halt
fi
}
skip_job << parameters.build_config_name >>
2 changes: 2 additions & 0 deletions .circleci/src/jobs/build_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ environment:
FASTLANE_SKIP_UPDATE_CHECK: true
shell: /bin/bash -eo pipefail
steps:
- skip_job:
build_config_name: << parameters.build_config_name >>
- add_ssh_keys: # Needed for credentials repo
fingerprints:
- 61:d8:94:00:53:5f:3b:19:fd:88:6b:fa:cd:ca:df:5d
Expand Down
2 changes: 2 additions & 0 deletions .circleci/src/jobs/build_ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ environment:
TOTAL_CPUS: 4 # For mac with resource_class medium, used in metro.config.ci.js.
shell: /bin/bash --login -o pipefail
steps:
- skip_job:
build_config_name: << parameters.build_config_name >>
- add_ssh_keys: # Needed for credentials repo
fingerprints:
- 61:d8:94:00:53:5f:3b:19:fd:88:6b:fa:cd:ca:df:5d
Expand Down
2 changes: 2 additions & 0 deletions .circleci/src/jobs/build_web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ environment:
TOTAL_CPUS: 1 # For resource_class small
shell: /bin/bash -eo pipefail
steps:
- skip_job:
build_config_name: << parameters.build_config_name >>
- checkout
- restore_yarn_cache
- run:
Expand Down
1 change: 1 addition & 0 deletions .circleci/src/jobs/bump_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ docker:
- image: circleci/node:12.16.3
resource_class: small
steps:
- skip_job
- checkout
- restore_yarn_tools_cache
- run:
Expand Down
1 change: 1 addition & 0 deletions .circleci/src/jobs/check_native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ environment:
TOTAL_CPUS: 1 # For resource_class small
shell: /bin/bash -eo pipefail
steps:
- skip_job
- checkout
- check_config
- restore_yarn_cache
Expand Down
1 change: 1 addition & 0 deletions .circleci/src/jobs/check_web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ environment:
TZ: "Europe/Berlin" # Should be removed in IGAPP-39
shell: /bin/bash -eo pipefail
steps:
- skip_job
- checkout
- check_config
- restore_yarn_cache
Expand Down
2 changes: 2 additions & 0 deletions .circleci/src/jobs/deliver_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ shell: /bin/bash -eo pipefail
environment:
FASTLANE_SKIP_UPDATE_CHECK: true
steps:
- skip_job:
build_config_name: << parameters.build_config_name >>
- run: 'curl -sL https://sentry.io/get-cli/ | bash'
- checkout
- prepare_workspace
Expand Down
2 changes: 2 additions & 0 deletions .circleci/src/jobs/deliver_ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ environment:
FASTLANE_SKIP_UPDATE_CHECK: true
shell: /bin/bash --login -o pipefail
steps:
- skip_job:
build_config_name: << parameters.build_config_name >>
- run: 'curl -sL https://sentry.io/get-cli/ | bash'
- checkout
- prepare_workspace
Expand Down
1 change: 1 addition & 0 deletions .circleci/src/jobs/deliver_web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ docker:
resource_class: small
shell: /bin/bash -eo pipefail
steps:
- skip_job
- add_ssh_keys:
fingerprints:
- "68:a3:fe:e7:94:f7:a4:13:35:5c:63:30:2f:07:7d:02"
Expand Down
1 change: 1 addition & 0 deletions .circleci/src/jobs/e2e_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ shell: /bin/bash -eo pipefail
environment:
FASTLANE_SKIP_UPDATE_CHECK: true
steps:
- skip_job
- checkout
- prepare_workspace
- restore_yarn_cache
Expand Down
1 change: 1 addition & 0 deletions .circleci/src/jobs/e2e_ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ shell: /bin/bash -eo pipefail
environment:
FASTLANE_SKIP_UPDATE_CHECK: true
steps:
- skip_job
- checkout
- prepare_workspace
- restore_yarn_cache
Expand Down
1 change: 1 addition & 0 deletions .circleci/src/jobs/move_release_notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ docker:
- image: circleci/node:12.16.3
resource_class: small
steps:
- skip_job
- checkout
- prepare_workspace
- restore_environment_variables
Expand Down
1 change: 1 addition & 0 deletions .circleci/src/jobs/notify_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ docker:
- image: circleci/node:12.16.3
resource_class: small
steps:
- skip_job
- checkout
- prepare_workspace
- restore_environment_variables
Expand Down
1 change: 1 addition & 0 deletions .circleci/src/jobs/notify_ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ docker:
- image: circleci/node:12.16.3
resource_class: small
steps:
- skip_job
- checkout
- prepare_workspace
- restore_environment_variables
Expand Down
1 change: 1 addition & 0 deletions .circleci/src/jobs/notify_web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ docker:
- image: circleci/node:12.16.3
resource_class: small
steps:
- skip_job
- checkout
- prepare_workspace
- restore_environment_variables
Expand Down
8 changes: 8 additions & 0 deletions docs/cicd.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ More information on the version naming schema used can be found [here](docs/conv
|FASTLANE_PASSWORD|Password for the Apple Account for delivery|Password Manager|123456|[Credentials](https://github.com/fastlane/fastlane/blob/b121a96e3e2e0bb83392c130cb3a088c773dbbaf/spaceship/docs/Authentication.md#credentials) [Avoid 2FA](https://github.com/fastlane/fastlane/blob/b121a96e3e2e0bb83392c130cb3a088c773dbbaf/spaceship/docs/Authentication.md#avoid-2fa-via-additional-account)|
|MATCH_PASSWORD|Password for accessing the certificates for the iOS app using [Fastlane Match](https://docs.fastlane.tools/actions/match/)|Password Manager|123456|[Using a Git Repo](https://docs.fastlane.tools/actions/match/#git-repo-encryption-password)|

## Skipping specific jobs

You can control which jobs should be skipped through environment variables. Set the variable `SKIP_JOB_deliver_ios` to `"all"` to skip all jobs with the name `deliver_ios`. Set the variable to `"malte"` in order to skip jobs which use the build config `malte` and have the name `deliver_ios`. You can also set it to `"malte|integreat"` in order to match multiple build configs.

Environment variables can be set in the [Project Settings](https://app.circleci.com/settings/project/github/Integreat/integreat-app/environment-variables) of CircleCI.

Some jobs like `bump_version` run only once for multiple build configs. Therefore, it does not make sense to set `SKIP_JOB_bump_version` to something other than `"all"`

## Hints and Quirks

### CPU count aka. $TOTAL_CPUS
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"scripts": {
"locales:missing": "node locales/tools/findMissingLocales",
"circleci:update-config": "cd .circleci && { cat autogenerated_header.yml; circleci config pack src; } > config.yml"
"circleci:update-config": "{ cat .circleci/autogenerated_header.yml; circleci config pack .circleci/src; } > .circleci/config.yml && circleci config validate"
},
"resolutions": {
"moment": "2.25.3"
Expand Down

0 comments on commit 1fd836f

Please sign in to comment.