-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
216 lines (196 loc) · 6.59 KB
/
.gitlab-ci.yml
File metadata and controls
216 lines (196 loc) · 6.59 KB
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
include:
- project: chromaway/core-infra/gitlab-automation
ref: 1.3.3
file:
- templates/release.yml
- templates/report-code-coverage.yml
- templates/maven-dependency-scanning.yml
- templates/container-dependency-scanning.yml
image: registry.gitlab.com/chromaway/core-tools/chromia-images/maven-docker-java21:1.0.11@sha256:a985644b469b4d01dcbd726176d69e238d8c7012c077a429beb65f86905d0bd1
.setup:
artifacts:
when: always
paths:
- "**/*.log"
- $JACOCO_REPORT_DIR/*
reports:
junit:
- "*/target/surefire-reports/TEST-*.xml"
- "*/target/failsafe-reports/TEST-*.xml"
expire_in: 1 week
stages:
- build
- code-coverage
- deploy
- dependency-check
- release
build:
extends:
- .setup
- .visualise-test-coverage
stage: build
interruptible: true
except:
refs:
- tags
script:
- apt-get update
- apt-get -y install ssh
- mvn
$MAVEN_CLI_OPTS
--activate-profiles ci,docker,coverage
clean verify
dependency-check:
extends: .maven-dependency-check
stage: dependency-check
interruptible: true
rules:
- if: $RUN_DEPENDENCY_CHECK == "true"
container-scanning:
variables:
REGISTRY: registry.gitlab.com/chromaway/core-tools/chromia-cli
parallel:
matrix:
- IMAGE: [ chr ]
VERSION: [ latest ]
only:
variables:
- $RUN_DEPENDENCY_CHECK == "true"
test-coverage-report:
stage: code-coverage
except:
refs:
- tags
dependencies:
- build
# Triggered by that a semver tag was pushed
deploy:
extends: .setup
stage: deploy
rules:
- if: $CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/
script:
- apt-get update
- apt-get -y install ssh
- mvn
$MAVEN_CLI_OPTS
--activate-profiles ci,docker,docker-push
-Drevision=$CI_COMMIT_TAG
clean source:jar deploy
trigger-homebrew-release:
stage: release
rules:
- if: $CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/
variables:
VERSION: $CI_COMMIT_TAG
FORMULA: chr
trigger:
project: chromaway/core-tools/homebrew-chromia
strategy: depend
trigger-scoop-release:
stage: release
rules:
- if: $CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/
variables:
VERSION: $CI_COMMIT_TAG
APP: chr
trigger:
project: chromaway/core-tools/scoop-chromia
strategy: depend
trigger-apt-repo-release:
stage: release
rules:
- if: $CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/
variables:
VERSION: $CI_COMMIT_TAG
TOOL: chr
script: |
curl -L \
--user "$JENKINS_USER:$JENKINS_USER_TOKEN" \
--form TOOL=$TOOL \
--form VERSION=$VERSION \
--request POST \
https://jenkins.infra.chromia.dev/job/apt-repository-chromia/buildWithParameters?token=$JENKINS_APT_JOB_TOKEN
update-docs:
stage: release
rules:
- if: $CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/
variables:
VERSION: $CI_COMMIT_TAG
before_script:
- !reference [ .git-setup, script ]
script: |
GIT_EMAIL=`git config user.email`
GIT_NAME=`git config user.name`
git clone https://x-token-auth:$BITBUCKET_CI_TOKEN@bitbucket.org/chromawallet/chromia-docs.git docs-repo
cd docs-repo
bash generate-chromia-cli-docs.sh
bash generate-rell-docs.sh
bash chromia-cli-release-notes.sh ../CHANGELOG.md docs/build/cli/cli-release-notes.mdx
# Check if there are changes
if [ `git status --porcelain | wc -l` -gt 0 ]; then
# Commit and push the changes
branch=chr-version-$VERSION
git config user.email $GIT_EMAIL
git config user.name $GIT_NAME
git checkout -b $branch
git add .
git commit -m "Update chromia-cli docs to version $VERSION"
git push origin $branch
# Create a merge request
curl -v --request POST \
--header 'Authorization: Bearer '"$BITBUCKET_CI_TOKEN" \
--header 'Accept: application/json' \
--header "Content-Type: application/json" \
--data '{
"title": "BUILD_USER: Update chromia cli docs version '"$VERSION"'",
"source": {"branch": {"name": "'"$branch"'"}},
"destination": {"branch": {"name": "master"}}
}' \
"https://api.bitbucket.org/2.0/repositories/chromawallet/chromia-docs/pullrequests"
else
echo "No changes to commit."
fi
gitlab-release:
extends: .gitlab-release-with-notes
script:
- echo "Release CHR $CI_COMMIT_TAG"
release:
name: 'CHR $CI_COMMIT_TAG'
description: release_notes.md
tag_name: '$CI_COMMIT_TAG'
assets:
links:
- name: 'Build Artifact (.tar.gz)'
url: '${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/maven/com/chromia/cli/chromia-cli/${CI_COMMIT_TAG}/chromia-cli-${CI_COMMIT_TAG}-dist.tar.gz'
link_type: 'package'
- name: 'Build Artifact (.zip)'
url: '${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/maven/com/chromia/cli/chromia-cli/${CI_COMMIT_TAG}/chromia-cli-${CI_COMMIT_TAG}-dist.zip'
link_type: 'package'
variables:
# This will suppress any download for dependencies and plugins or upload messages which would clutter the console log.
# `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
# As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used
# when running from the command line.
# `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins.
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true -s .gitlab-settings.xml"
# Configure postgres service (https://hub.docker.com/_/postgres/)
DOCKER_HOST: tcp://docker:2375
POSTGRES_DB: postchain
POSTGRES_USER: postchain
POSTGRES_PASSWORD: postchain
POSTCHAIN_DB_URL: jdbc:postgresql://postgres/postchain
CHR_DB_URL: jdbc:postgresql://postgres/postchain
JACOCO_REPORT_DIR: coverage-report-aggregate/target/site/jacoco-aggregate
services:
- postgres:14.9-alpine3.18
- name: docker:20-dind
alias: docker
# explicitly disable tls to avoid docker startup interruption
command: [ "--tls=false" , "--experimental" ]
# Cache downloaded dependencies and plugins between builds.
# To keep cache across branches add 'key: "$CI_JOB_NAME"'
cache:
paths:
- .m2/repository