-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy path.gitlab-ci.yml
174 lines (164 loc) · 5.07 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
stages:
- test
- build
- release
default:
# All jobs are interruptible.
# If any job must be uninterruptible, override this flag at the job level
# `interruptible: false`
interruptible: true
variables:
APP_NAME: "MacOSVK"
.go-build-macos:
image: macos-sonoma-runner:15.0.1
tags:
- macos.medium
variables:
GOPATH: "$CI_PROJECT_DIR/.go"
MISE_CACHE_DIR: "$CI_PROJECT_DIR/.mise/cache"
MISE_DATA_DIR: "$CI_PROJECT_DIR/.mise/data"
before_script:
- |
printf "\e[0Ksection_start:%s:prepare_go[collapsed=true]\r\e[0K%s\n" "$(date +%s)" "Prepare Go environment"
mkdir -p ".go"
curl -fsS https://mise.run | sh
export PATH="$HOME/.local/bin:$PATH"
mise install
eval "$(mise activate bash --shims)"
printf "\e[0Ksection_end:%s:prepare_go\r\e[0K\n" "$(date +%s)"
cache:
- key:
files:
- go.mod
- go.sum
paths:
- .go/pkg/mod/
- key:
files:
- .mise.toml
paths:
- .mise
.go-coverage:
variables:
GOCOVERPKG: "github.com/agoda-com/macOS-vz-kubelet/..."
JUNIT_FILE: "${CI_PROJECT_DIR}/build/junit.xml"
CODECOV_FILE: "${CI_PROJECT_DIR}/build/coverage.xml"
CODECOV_FLAG: ""
coverage: '/total\s+\(statements\)\s+(\d+.\d+)%/'
after_script:
- |
printf "\e[0Ksection_start:%s:codecov[collapsed=false]\r\e[0K%s\n" "$(date +%s)" "Upload coverage to Codecov"
mv "$CODECOV_CONFIG" "$CI_PROJECT_DIR/codecov.yml"
args=""
if [ -n "${CODECOV_TOKEN}" ]; then
args="$args -t ${CODECOV_TOKEN}"
fi
if [ -n "${CODECOV_FILE}" ]; then
args="$args -f ${CODECOV_FILE}"
fi
if [ -n "${CODECOV_FLAG}" ]; then
args="$args -F ${CODECOV_FLAG}"
fi
bash <(curl -s ${CODECOV_URL:-https://codecov.io}/bash) $args
printf "\e[0Ksection_end:%s:codecov\r\e[0K\n" "$(date +%s)"
artifacts:
reports:
junit: "${JUNIT_FILE}"
lint:
extends:
- .go-build-macos
stage: test
needs: []
dependencies: []
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_MERGE_REQUEST_ID
script:
- make generate format
- 'git diff --exit-code || (echo -e "\e[31mERROR: Run make generate format and commit changes\e[0m" && exit 1)'
- make lint
test:
extends:
- .go-build-macos
- .go-coverage
stage: test
needs: []
dependencies: []
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_MERGE_REQUEST_ID
script:
- make integration-test coverage
.build:
extends:
- .go-build-macos
variables:
APPLE_DEVELOPER_ID_INTERMEDIATE_CERT_G1_URL: "https://www.apple.com/certificateauthority/DeveloperIDCA.cer"
APPLE_DEVELOPER_ID_INTERMEDIATE_CERT_G2_URL: "https://www.apple.com/certificateauthority/DeveloperIDG2CA.cer"
SPACESHIP_SKIP_2FA_UPGRADE: 1 # Skip 2FA upgrade for fastlane
cache:
- !reference [.go-build-macos, cache]
- key:
files:
- Gemfile.lock
paths:
- ruby
before_script:
- set -eo pipefail
- !reference [.go-build-macos, before_script]
- |
printf "\e[0Ksection_start:%s:prepare_intermediate_cert[collapsed=true]\r\e[0K%s\n" "$(date +%s)" "Prepare Apple Developer ID Intermediate Certificate"
prepare_certificate() {
local cert_url="$1"
local cert_path="$(mktemp)"
curl -fsS "$cert_url" -o "$cert_path"
sudo security import "$cert_path" /Library/Keychains/System.keychain
}
prepare_certificate "$APPLE_DEVELOPER_ID_INTERMEDIATE_CERT_G1_URL"
prepare_certificate "$APPLE_DEVELOPER_ID_INTERMEDIATE_CERT_G2_URL"
printf "\e[0Ksection_end:%s:prepare_intermediate_cert\r\e[0K\n" "$(date +%s)"
- |
printf "\e[0Ksection_start:%s:prepare_fastlane[collapsed=true]\r\e[0K%s\n" "$(date +%s)" "Prepare Fastlane environment"
echo "Copying fastlane related secret configuration files..."
cp "$APPFILE" "$CI_PROJECT_DIR/fastlane/Appfile"
cp "$MATCHFILE" "$CI_PROJECT_DIR/fastlane/Matchfile"
echo "Installing fastlane..."
bundle install
printf "\e[0Ksection_end:%s:prepare_fastlane\r\e[0K\n" "$(date +%s)"
snapshot:
extends: .build
stage: build
needs:
- job: lint
optional: true
- job: unit-test
optional: true
dependencies: []
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_MERGE_REQUEST_ID
script:
- set -eo pipefail
- |
printf "\e[0Ksection_start:%s:build_project[collapsed=false]\r\e[0K%s\n" "$(date +%s)" "Build and sign project"
bundle exec fastlane build_snapshot
printf "\e[0Ksection_end:%s:build_project\r\e[0K\n" "$(date +%s)"
artifacts:
paths:
- build/*/*.app
expire_in: 1 week
release:
extends: .build
stage: release
needs: []
dependencies: []
rules:
- if: $CI_COMMIT_TAG
variables:
GITLAB_TOKEN: "${CI_JOB_TOKEN}"
script:
- set -eo pipefail
- |
printf "\e[0Ksection_start:%s:release_project[collapsed=false]\r\e[0K%s\n" "$(date +%s)" "Release project"
bundle exec fastlane build_release
printf "\e[0Ksection_end:%s:release_project\r\e[0K\n" "$(date +%s)"