-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
183 lines (166 loc) · 4.41 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
# Set cargo home relative to the project directory to allow for caching
variables:
CARGO_HOME: $CI_PROJECT_DIR/.cargo
stages:
- build
- lint
- test
- deploy
- pass
# This is required for an issue with gitlab. When there are no jobs (no code
# changes, e.g just readme), there are no CI jobs, hence the pipeline will
# continually "get ready" to run, but never finish.
pipeline-pass:
stage: pass
script:
- echo "No jobs required for this commit."
except:
changes:
- revzen_backend/**/*
- revzen/**/*
# Backend should be run with the latest rust image, only if there are changes
# in the revzen_backend directory.
#
# The target directory is cached, this way if cargo determines some files do not
# need to be re downloaded or compiled, they can be reused (significant speedup).
.backend-run:
before_script:
- cd revzen_backend
image: rust:latest
cache:
key: backend-shared-cache
paths:
- revzen_backend/target/
- .cargo/
only:
changes:
- revzen_backend/**/*
backend-build:
extends:
- .backend-run
stage: build
script:
- cargo build --verbose
backend-test:
extends:
- .backend-run
stage: test
script:
- cargo test --verbose
backend-clippy:
extends:
- .backend-run
stage: lint
allow_failure: true
script:
- cargo clippy --verbose
backend-fmt:
extends:
- .backend-run
stage: lint
allow_failure: true
script:
- cargo fmt --check
# Heroku Backend Hosting:
# - A buildpack is used to set the revzen_backend directory as the root, allowing
# for the rust buildpack to be used. This requires a PROJECT_PATH variable in
# heroku as well as the packs to be ordered, and procfile placed in revzen_backend
# (subdir first)
# - A separate heroku app is used for the production environment.
# When merging into dev, we want to host on the development backend
deploy-backend-dev:
stage: deploy
image: ceorcham/dpl-heroku
script:
- dpl --provider=heroku --app=revzen-backend-dev --api-key=$HEROKU_API_KEY
# only:
# - dev
# When merging into master, we want to host on the production backend
deploy-backend-prod:
stage: deploy
image: ceorcham/dpl-heroku
script:
- dpl --provider=heroku --app=revzen-backend-prod --api-key=$HEROKU_API_KEY
only:
- master
# Frontend build requires java 8, as well as gradle. Gradle is used for build, test and lint.
.android-run:
before_script:
- cd revzen
- chmod +x ./gradlew
image: androidsdk/android-30
cache:
key: android-frontend-$CI_COMMIT_SHA
paths:
- build-cache/
only:
changes:
- revzen/**/*
build-android:
extends:
.android-run
stage: build
script:
- ./gradlew -Dorg.gradle.jvmargs=-Xmx2000m --no-daemon assembleDebug
artifacts:
paths:
- revzen/app/build/outputs/apk/debug/app-debug.apk
test-android:
extends:
.android-run
stage: test
script:
- ./gradlew -Dorg.gradle.jvmargs=-Xmx2000m --no-daemon test
# Run a linting pass, creating an artifact of the results if the lint fails.
lint-android:
extends:
.android-run
stage: lint
script:
- ./gradlew -Dorg.gradle.jvmargs=-Xmx2000m --no-daemon lint
allow_failure: true
artifacts:
when: on_failure
paths:
- revzen/app/build/reports/lint-results-debug.html
expire_in: 1 week
expose_as: 'Android App Linting Report'
deploy-android-dev:
extends:
.android-run
stage: deploy
script:
- ./gradlew -Dorg.gradle.jvmargs=-Xmx2000m --no-daemon assembleDev
artifacts:
paths:
- revzen/app/build/outputs/apk/dev/app-dev.apk
only:
- dev
deploy-android-prod:
extends:
.android-run
stage: deploy
script:
- ./gradlew -Dorg.gradle.jvmargs=-Xmx2000m --no-daemon assembleProd
artifacts:
paths:
- revzen/app/build/outputs/apk/prod/app-prod.apk
only:
- master
# When merging into the dev branch, publish the backend docs (hosted on gitlab
# pages)
pages:
extends:
- .android-run
stage: deploy
script:
- ./gradlew -Dorg.gradle.jvmargs=-Xmx2000m --no-daemon assembleDebug
- mkdir ../public
- mkdir ../public/android_app
- mv app/build/outputs/apk/debug/app-debug.apk ../public/app.apk
artifacts:
paths:
- public/app.apk
expire_in: 1 week
only:
- dev