Skip to content

Commit 0360263

Browse files
committed
Merge branch 'feature/add_ci' into 'master'
Add ci script See merge request sdk/ESP8266_RTOS_SDK!2
2 parents 936c92a + 3f43e12 commit 0360263

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed

.gitlab-ci.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
stages:
2+
- build
3+
- deploy
4+
5+
variables:
6+
GIT_STRATEGY: clone
7+
8+
# before each job, we need to check if this job is filtered by bot stage/job filter
9+
.apply_bot_filter: &apply_bot_filter
10+
python $APPLY_BOT_FILTER_SCRIPT || exit 0
11+
12+
before_script:
13+
- mkdir -p ~/.ssh
14+
- chmod 700 ~/.ssh
15+
- echo -n $GITLAB_KEY >> ~/.ssh/id_rsa_base64
16+
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
17+
- chmod 600 ~/.ssh/id_rsa
18+
- echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
19+
20+
.do_nothing_before:
21+
before_script: &do_nothing_before
22+
# apply bot filter in before script
23+
- *apply_bot_filter
24+
- echo "Not setting up GitLab key, not fetching submodules"
25+
- source tools/ci/configure_ci_environment.sh
26+
27+
.build_template: &build_template
28+
stage: build
29+
image: ci_test
30+
tags:
31+
- build
32+
33+
build_ssc:
34+
<<: *build_template
35+
artifacts:
36+
paths:
37+
- ./SSC/ssc_bin
38+
expire_in: 6 mos
39+
script:
40+
- git clone $GITLAB_SSH_SERVER/yinling/SSC.git
41+
- cd SSC
42+
# try checkout same branch
43+
- git checkout ${CI_BUILD_REF_NAME} || echo "Using default branch..."
44+
- chmod +x gen_misc_rtos.sh
45+
- ./gen_misc_rtos.sh
46+
47+
push_master_to_github:
48+
stage: deploy
49+
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
50+
tags:
51+
- deploy
52+
only:
53+
- master
54+
- /^release\/v/
55+
- /^v\d+\.\d+(\.\d+)?($|-)/
56+
when: on_success
57+
dependencies: []
58+
variables:
59+
GITHUB_PUSH_REFS: refs/remotes/origin/release refs/remotes/origin/master
60+
before_script: *do_nothing_before
61+
script:
62+
- mkdir -p ~/.ssh
63+
- chmod 700 ~/.ssh
64+
- echo -n $GH_PUSH_KEY > ~/.ssh/id_rsa_base64
65+
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
66+
- chmod 600 ~/.ssh/id_rsa
67+
- echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
68+
- git remote remove github &>/dev/null || true
69+
- git remote add github git@github.com:espressif/ESP8266_RTOS_SDK.git
70+
# What the next line of script does: goes through the list of refs for all branches we push to github,
71+
# generates a snippet of shell which is evaluated. The snippet checks CI_COMMIT_SHA against the SHA
72+
# (aka objectname) at tip of each branch, and if any SHAs match then it checks out the local branch
73+
# and then pushes that ref to a corresponding github branch
74+
- eval $(git for-each-ref --shell bash --format 'if [ $CI_COMMIT_SHA == %(objectname) ]; then git checkout -B %(refname:strip=3); git push --follow-tags github %(refname:strip=3); fi;' $GITHUB_PUSH_REFS)

tools/ci/configure_ci_environment.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This file is sourced in to the CI environment
2+
# in .gitlab-ci.yml
3+
#
4+
5+
# Sets the error behaviour options for shell throughout the CI environment
6+
#
7+
set -o errexit # Exit if command failed.
8+
set -o pipefail # Exit if pipe failed.
9+
10+
# we can use the appropriate secret variable for debugging
11+
[ ! -z $DEBUG_SHELL ] && set -x
12+
13+
[ -z $CI_COMMIT_REF_NAME ] && echo "This internal script should only be run by a Gitlab CI runner." && exit 1
14+
15+
# Sets IS_PUBLIC and IS_PRIVATE based on branch type
16+
#
17+
# Public branches are:
18+
# release branches - start with release/
19+
# release tags - look like vXX.YY or vXX.YY.ZZ with an optional dash followed by anything on the end
20+
# master branch
21+
#
22+
# These POSIX REs are equivalent to the REs in some "only:" sections of the gitlab-ci.yml file
23+
#
24+
REF=$CI_COMMIT_REF_NAME
25+
if [[ $REF = "master" || $REF =~ ^release/v || $REF =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?(-|$) ]]; then
26+
export IS_PRIVATE=
27+
export IS_PUBLIC=1
28+
else
29+
export IS_PRIVATE=1
30+
export IS_PUBLIC=
31+
fi
32+
unset REF

0 commit comments

Comments
 (0)