CI: Use anchors to get rid of code dublication in the 'before_script' clauses
This commit is contained in:
parent
8dc340d2ea
commit
e55eeb0687
1 changed files with 23 additions and 26 deletions
|
@ -44,6 +44,23 @@ before_script:
|
||||||
# fetch the submodules (& if necessary re-fetch repo) from gitlab
|
# fetch the submodules (& if necessary re-fetch repo) from gitlab
|
||||||
- time ./tools/ci/get-full-sources.sh
|
- time ./tools/ci/get-full-sources.sh
|
||||||
|
|
||||||
|
.do_nothing_before:
|
||||||
|
before_script: &do_nothing_before
|
||||||
|
- echo "Not setting up GitLab key, not fetching submodules"
|
||||||
|
- source tools/ci/configure_ci_environment.sh
|
||||||
|
|
||||||
|
.add_gitlab_key_before:
|
||||||
|
before_script: &add_gitlab_key_before
|
||||||
|
- echo "Not fetching submodules"
|
||||||
|
- source tools/ci/configure_ci_environment.sh
|
||||||
|
# add gitlab ssh key
|
||||||
|
- mkdir -p ~/.ssh
|
||||||
|
- chmod 700 ~/.ssh
|
||||||
|
- echo -n $GITLAB_KEY > ~/.ssh/id_rsa_base64
|
||||||
|
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
|
||||||
|
- chmod 600 ~/.ssh/id_rsa
|
||||||
|
- echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
|
||||||
|
|
||||||
build_template_app:
|
build_template_app:
|
||||||
stage: build
|
stage: build
|
||||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env
|
image: $CI_DOCKER_REGISTRY/esp32-ci-env
|
||||||
|
@ -268,8 +285,6 @@ test_report:
|
||||||
- test "${TEST_RESULT}" = "Pass" || exit 1
|
- test "${TEST_RESULT}" = "Pass" || exit 1
|
||||||
|
|
||||||
push_master_to_github:
|
push_master_to_github:
|
||||||
before_script:
|
|
||||||
- echo "Not setting up GitLab key, not fetching submodules"
|
|
||||||
stage: deploy
|
stage: deploy
|
||||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env
|
image: $CI_DOCKER_REGISTRY/esp32-ci-env
|
||||||
tags:
|
tags:
|
||||||
|
@ -282,6 +297,7 @@ push_master_to_github:
|
||||||
dependencies: []
|
dependencies: []
|
||||||
variables:
|
variables:
|
||||||
GITHUB_PUSH_REFS: refs/remotes/origin/release refs/remotes/origin/master
|
GITHUB_PUSH_REFS: refs/remotes/origin/release refs/remotes/origin/master
|
||||||
|
before_script: *do_nothing_before
|
||||||
script:
|
script:
|
||||||
- mkdir -p ~/.ssh
|
- mkdir -p ~/.ssh
|
||||||
- chmod 700 ~/.ssh
|
- chmod 700 ~/.ssh
|
||||||
|
@ -298,8 +314,6 @@ push_master_to_github:
|
||||||
|
|
||||||
|
|
||||||
deploy_docs:
|
deploy_docs:
|
||||||
before_script:
|
|
||||||
- echo "Not setting up GitLab key, not fetching submodules"
|
|
||||||
stage: deploy
|
stage: deploy
|
||||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env
|
image: $CI_DOCKER_REGISTRY/esp32-ci-env
|
||||||
tags:
|
tags:
|
||||||
|
@ -311,6 +325,7 @@ deploy_docs:
|
||||||
- triggers
|
- triggers
|
||||||
dependencies:
|
dependencies:
|
||||||
- build_docs
|
- build_docs
|
||||||
|
before_script: *do_nothing_before
|
||||||
script:
|
script:
|
||||||
- mkdir -p ~/.ssh
|
- mkdir -p ~/.ssh
|
||||||
- chmod 700 ~/.ssh
|
- chmod 700 ~/.ssh
|
||||||
|
@ -355,8 +370,7 @@ check_commit_msg:
|
||||||
- /^release\/v/
|
- /^release\/v/
|
||||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||||
dependencies: []
|
dependencies: []
|
||||||
before_script:
|
before_script: *do_nothing_before
|
||||||
- echo "Not setting up GitLab key, not fetching submodules"
|
|
||||||
script:
|
script:
|
||||||
- git status
|
- git status
|
||||||
- git log -n10 --oneline
|
- git log -n10 --oneline
|
||||||
|
@ -375,8 +389,7 @@ check_submodule_sync:
|
||||||
dependencies: []
|
dependencies: []
|
||||||
variables:
|
variables:
|
||||||
GIT_STRATEGY: clone
|
GIT_STRATEGY: clone
|
||||||
before_script:
|
before_script: *do_nothing_before
|
||||||
- echo "Not setting up GitLab key, not fetching submodules"
|
|
||||||
script:
|
script:
|
||||||
# check if all submodules are correctly synced to public repostory
|
# check if all submodules are correctly synced to public repostory
|
||||||
- git submodule update --init --recursive
|
- git submodule update --init --recursive
|
||||||
|
@ -393,15 +406,7 @@ assign_test:
|
||||||
- components/idf_test/*/CIConfigs
|
- components/idf_test/*/CIConfigs
|
||||||
- components/idf_test/*/TC.sqlite
|
- components/idf_test/*/TC.sqlite
|
||||||
expire_in: 1 mos
|
expire_in: 1 mos
|
||||||
before_script:
|
before_script: *add_gitlab_key_before
|
||||||
- echo "Not fetching submodules"
|
|
||||||
# add gitlab ssh key
|
|
||||||
- mkdir -p ~/.ssh
|
|
||||||
- chmod 700 ~/.ssh
|
|
||||||
- echo -n $GITLAB_KEY > ~/.ssh/id_rsa_base64
|
|
||||||
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
|
|
||||||
- chmod 600 ~/.ssh/id_rsa
|
|
||||||
- echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
|
|
||||||
script:
|
script:
|
||||||
# first move test bins together: test_bins/CHIP_SDK/TestApp/bin_files
|
# first move test bins together: test_bins/CHIP_SDK/TestApp/bin_files
|
||||||
- mkdir -p test_bins/ESP32_IDF/UT
|
- mkdir -p test_bins/ESP32_IDF/UT
|
||||||
|
@ -438,15 +443,7 @@ assign_test:
|
||||||
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/components/idf_test/integration_test"
|
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/components/idf_test/integration_test"
|
||||||
MODULE_UPDATE_FILE: "$CI_PROJECT_DIR/components/idf_test/ModuleDefinition.yml"
|
MODULE_UPDATE_FILE: "$CI_PROJECT_DIR/components/idf_test/ModuleDefinition.yml"
|
||||||
CONFIG_FILE: "$CI_PROJECT_DIR/components/idf_test/integration_test/CIConfigs/$CI_JOB_NAME.yml"
|
CONFIG_FILE: "$CI_PROJECT_DIR/components/idf_test/integration_test/CIConfigs/$CI_JOB_NAME.yml"
|
||||||
before_script:
|
before_script: *add_gitlab_key_before
|
||||||
- echo "Not fetching submodules"
|
|
||||||
# add gitlab ssh key
|
|
||||||
- mkdir -p ~/.ssh
|
|
||||||
- chmod 700 ~/.ssh
|
|
||||||
- echo -n $GITLAB_KEY > ~/.ssh/id_rsa_base64
|
|
||||||
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
|
|
||||||
- chmod 600 ~/.ssh/id_rsa
|
|
||||||
- echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
|
|
||||||
script:
|
script:
|
||||||
# first test if config file exists, if not exist, exit 0
|
# first test if config file exists, if not exist, exit 0
|
||||||
- test -e $CONFIG_FILE || exit 0
|
- test -e $CONFIG_FILE || exit 0
|
||||||
|
|
Loading…
Reference in a new issue