-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
129 lines (121 loc) · 3.51 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
variables:
DEBIAN_FRONTEND: noninteractive
APT_GET_INSTALL: "apt-get install --no-install-recommends -q -y"
stages:
- check_coding_style
- test_build
- release
- deploy
pre-commit:
stage: check_coding_style
image:
# https://hub.docker.com/_/alpine
name: alpine:latest
script:
- date
# install necessary packages:
- apk add --no-cache bash gcc git libc-dev npm py3-pip python3-dev
- pip3 install pre-commit
- pre-commit --version
- pre-commit run --all-files
arduino-lint:
stage: check_coding_style
image:
# https://hub.docker.com/_/debian
name: debian:latest
script:
- date
- apt-get update
- $APT_GET_INSTALL curl ca-certificates
- (cd && curl -fsSL https://raw.githubusercontent.com/arduino/arduino-lint/main/etc/install.sh | sh)
- ~/bin/arduino-lint --version
- ~/bin/arduino-lint --compliance strict --library-manager update
arduino_ci:
stage: test_build
image:
# https://hub.docker.com/_/debian
name: debian:latest
script:
- date
- apt-get update
- $APT_GET_INSTALL ruby build-essential
- gem install bundler arduino_ci
- export EXPECT_UNITTESTS=1
- export EXPECT_EXAMPLES=1
- arduino_ci.rb
prepare_release:
stage: test_build
rules:
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
image:
# https://hub.docker.com/_/alpine
name: alpine:latest
script:
- date
- cat library.properties
- echo "EXTRA_DESCRIPTION=$(grep sentence library.properties | cut -d "=" -f 2) $(grep paragraph library.properties | cut -d '=' -f 2)" > variables.env
- echo "TAG=$(grep version library.properties | cut -d "=" -f 2)" >> variables.env
- cat variables.env
artifacts:
expire_in: 1 hrs
reports:
dotenv: variables.env
release_job:
stage: release
image:
# https://docs.gitlab.com/ee/user/project/releases/release_cicd_examples.html#create-release-metadata-in-a-custom-script
registry.gitlab.com/gitlab-org/release-cli:latest
needs:
- job: arduino-lint
- job: arduino_ci
- job: prepare_release
artifacts: true
rules:
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- date
- echo "running release_job for $TAG"
release:
name: 'Release $TAG'
description: '$EXTRA_DESCRIPTION'
tag_name: '$TAG'
ref: '$CI_COMMIT_SHA'
deploy_to_github:
stage: deploy
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
image:
# https://hub.docker.com/_/alpine
name: alpine:latest
needs:
- job: release_job
script:
- date
- apk add --no-cache git openssh
- mkdir ~/.ssh && chmod 700 ~/.ssh
- ssh-keyscan -H github.com >> ~/.ssh/known_hosts
- mv $github_deploy_key ~/.ssh/id_ed25519 && chmod 600 ~/.ssh/id_ed25519
- repopath=$(mktemp -d)
- git clone --bare --mirror ${CI_REPOSITORY_URL} $repopath
- (cd $repopath && git push --prune --mirror git@github.com:ug-cp/fast_samd21_tc.git)
deploy_to_repo:
stage: deploy
allow_failure: true
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
image:
# https://hub.docker.com/_/alpine
name: alpine:latest
needs:
- job: release_job
script:
- date
- apk add --no-cache git
- repopath=$(mktemp -d)
- git clone --bare --mirror ${CI_REPOSITORY_URL} $repopath
- (cd $repopath && git for-each-ref --format 'delete %(refname)' refs/merge-requests | tee >(git update-ref --stdin))
- (cd $repopath && git push --prune --mirror $backup_repo)