-
Notifications
You must be signed in to change notification settings - Fork 12
/
.gitlab-ci.yml
216 lines (205 loc) · 8.67 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
variables:
DEBIAN_FRONTEND: noninteractive
DOCKER_HOST: "tcp://docker:2376"
DOCKER_CERT_PATH: "/certs/client"
DOCKER_TLS_VERIFY: "1"
DOCKER_TLS_CERTDIR: "/certs"
DEFAULT_BRANCH: "master"
GITHUB_REPO_URL:
description: "The Github Repo URL for release-please, in the format of 'owner/repo'"
value: "mendersoftware/app-update-module"
GITHUB_USER_NAME:
description: "The Github username for release-please"
value: "mender-test-bot"
GITHUB_USER_EMAIL:
description: "The Github user email for release-please"
value: "[email protected]"
GITHUB_CHANGELOG_REPO_URL:
description: "The Github Repo URL where to push the changelog"
value: "mendersoftware/mender-docs-changelog"
CHANGELOG_REMOTE_FILE:
description: "The changelog file in the remote changelog repo"
value: "70.app-update-module/docs.md"
RUN_RELEASE:
description: "Run a new release"
value: "false"
options:
- "true"
- "false"
GIT_CLIFF:
description: "Run git cliff to override the release-please changelog"
value: "true"
options:
- "true"
- "false"
stages:
- test
- changelog
- release
include:
- project: 'Northern.tech/Mender/mendertesting'
file:
- '.gitlab-ci-check-commits.yml'
- '.gitlab-ci-check-license.yml'
- '.gitlab-ci-github-status-updates.yml'
- '.gitlab-ci-check-shell-format.yml'
.docker_login_registries: &docker_login_registries |
docker login -u "$REGISTRY_MENDER_IO_USERNAME" -p "$REGISTRY_MENDER_IO_PASSWORD" registry.mender.io || \
echo "Warning: registry.mender.io credentials unavailable or invalid"
docker login -u "$DOCKER_HUB_USERNAME" -p "$DOCKER_HUB_PASSWORD" || \
echo "Warning: Docker credentials unavailable or invalid"
test:check-shell-formatting:
before_script:
- SHELL_SCRIPTS="src/app src/app-modules/docker-compose gen/app-gen tests/app/run.sh tests/app/scenarios/00_basic_ArtifactInstall.run.sh acceptance-tests/scenarios.d/00.basic.non.delta.successful.sh acceptance-tests/run.sh acceptance-tests/bt/main.sh acceptance-tests/bt/lib/functions.sh acceptance-tests/bt/bt.sh"
test:smoketests:
stage: test
variables:
DOCKER_BUILDKIT: 0
COMPOSE_DOCKER_CLI_BUILD: 0
tags:
# docker login doesn't work for this job: Cannot perform an interactive login from a non TTY device
- mender-qa-worker-generic-light
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/tiangolo/docker-with-compose
services:
- name: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:20.10.10-dind-alpine3.14
alias: docker
before_script:
- apk --update --no-cache add bash gawk curl aws-cli tree xz jq wget xdelta3 openssl1.1-compat gcompat
script:
- ./tests/app/run.sh
- ./tests/gen/run.sh
artifacts:
expire_in: 2w
paths:
- tests/app/data/docker/output
- tests/gen/data/docker/output
when: always
test:acceptancetests:
stage: test
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/ubuntu:20.04
tags:
# docker privileged is required for this job
- mender-qa-worker-generic-light
services:
- name: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:23.0.5-dind-alpine3.17
alias: docker
before_script:
- *docker_login_registries
- apt update && apt install -yy bash wget xz-utils awscli docker.io curl make xdelta3 tree containerd
- docker ps
- docker info
- mkdir -p ~/.docker/cli-plugins/
- curl -SL https://github.com/docker/compose/releases/download/v2.3.3/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose
- chmod +x ~/.docker/cli-plugins/docker-compose
- ~/.docker/cli-plugins/docker-compose --help
- cp ~/.docker/cli-plugins/docker-compose /usr/bin/
- docker compose version
- echo "installing k3d"
- wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
- curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
- chmod +x ./kubectl
- mv ./kubectl /usr/bin/kubectl
script:
- ./acceptance-tests/run.sh
changelog:
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/node:20
stage: changelog
variables:
GIT_DEPTH: 0 # Always get the full history
GIT_STRATEGY: clone # Always get the full history
tags:
- hetzner-amd-beefy
rules:
- if: $RUN_RELEASE == "true"
when: never
- if: $CI_COMMIT_BRANCH =~ "/^\d+\.\d+\.x$/"
- if: $CI_COMMIT_BRANCH == $DEFAULT_BRANCH
before_script:
# install release-please
- npm install -g release-please
# install github-cli
- mkdir -p -m 755 /etc/apt/keyrings
- wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null
- chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
- echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null
- apt update
- apt install gh jq -y
# Setting up git
- git config --global user.email "${GITHUB_USER_EMAIL}"
- git config --global user.name "${GITHUB_USER_NAME}"
- npm install -g git-cliff
# GITHUB_TOKEN for Github cli authentication
- export GITHUB_TOKEN=${GITHUB_CLI_TOKEN}
# getting the centralized git cliff config
script:
- release-please release-pr
--token=${GITHUB_BOT_TOKEN_REPO_FULL}
--repo-url=${GITHUB_REPO_URL}
--target-branch=${CI_COMMIT_REF_NAME}
# git cliff: override the changelog
- test $GIT_CLIFF == "false" && echo "INFO - Skipping git-cliff" && exit 0
- git remote add github-${CI_JOB_ID} https://${GITHUB_USER_NAME}:${GITHUB_BOT_TOKEN_REPO_FULL}@github.com/${GITHUB_REPO_URL} || true # Ignore already existing remote
- gh repo set-default https://${GITHUB_USER_NAME}:${GITHUB_BOT_TOKEN_REPO_FULL}@github.com/${GITHUB_REPO_URL}
- RELEASE_PLEASE_PR=$(gh pr list --author "${GITHUB_USER_NAME}" --head "release-please--branches--${CI_COMMIT_REF_NAME}" --json number | jq -r '.[0].number // empty')
- test -z "$RELEASE_PLEASE_PR" && echo "No release-please PR found" && exit 0
- gh pr checkout --force $RELEASE_PLEASE_PR
- wget --output-document cliff.toml https://raw.githubusercontent.com/mendersoftware/mendertesting/master/utils/cliff.toml
- git cliff --bump --output CHANGELOG.md --github-repo ${GITHUB_REPO_URL}
- git add CHANGELOG.md
- git commit --amend -s --no-edit
- git push github-${CI_JOB_ID} --force
# Update the PR body
- git cliff --unreleased --bump -o tmp_pr_body.md --github-repo ${GITHUB_REPO_URL}
- gh pr edit $RELEASE_PLEASE_PR --body-file tmp_pr_body.md
- rm tmp_pr_body.md
after_script:
- git remote remove github-${CI_JOB_ID}
release:github:
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/node:20
stage: release
tags:
- hetzner-amd-beefy
rules:
- if: $CI_COMMIT_BRANCH =~ "/^\d+\.\d+\.x$/" && $RUN_RELEASE == "true"
- if: $CI_COMMIT_BRANCH == $DEFAULT_BRANCH && $RUN_RELEASE == "true"
script:
- npm install -g release-please
- release-please github-release
--token=${GITHUB_BOT_TOKEN_REPO_FULL}
--repo-url=${GITHUB_REPO_URL}
--target-branch=${CI_COMMIT_REF_NAME}
release:mender-docs-changelog:
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/alpine:latest
stage: release
tags:
- hetzner-amd-beefy
rules:
- if: $CI_COMMIT_TAG =~ "/^\d+\.\d+\.\d+$/"
before_script:
- apk add git bash curl jq github-cli
- |
echo "INFO - setting up git"
git config --global user.email ${GITHUB_USER_EMAIL}
git config --global user.name ${GITHUB_USER_NAME}
export GITHUB_TOKEN=${GITHUB_BOT_TOKEN_REPO_FULL} # used for gh cli
script:
- git clone https://${GITHUB_USER}:${GITHUB_TOKEN_NT}@github.com/${GITHUB_CHANGELOG_REPO_URL}
- cd ${GITHUB_CHANGELOG_REPO_URL#*/}
- git checkout -b changelog-${CI_PIPELINE_ID}
- |
cat ../docs_header.md > ${CHANGELOG_REMOTE_FILE}
cat ../CHANGELOG.md | grep -v -E '^---' >> ${CHANGELOG_REMOTE_FILE}
git add ${CHANGELOG_REMOTE_FILE}
git commit -s -m "chore: add app-update-module changelog"
git push origin changelog-${CI_PIPELINE_ID}
- gh pr create --title "Update CHANGELOG.md" --body "Automated change to the CHANGELOG.md file" --base master --head changelog-${CI_PIPELINE_ID}
release:mender-dist-packages:
stage: release
when: manual
trigger:
project: Northern.tech/Mender/mender-dist-packages
strategy: depend
variables:
MENDER_APP_UPDATE_MODULE_VERSION: ${CI_COMMIT_TAG}
rules:
- if: $CI_COMMIT_TAG =~ "/^\d+\.\d+\.\d+$/"