This repository has been archived by the owner on May 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
182 lines (171 loc) · 4.53 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
default:
image: registry.gitlab.com/basiliqio/dockerfiles
variables:
RUSTFLAGS: -C link-dead-code
stages:
- checks
- build
- test
- pack
- prepare-deploy
- deploy
basic_checks:
stage: checks
before_script:
- mkdir -p .git/hooks
script:
- cargo fmt -- --check
- cargo clippy -- -D warnings
build_debug:
stage: build
artifacts:
paths:
- tests_exe/
expire_in: 1 week
before_script:
- mkdir -p .git/hooks
- mkdir tests_exe
script:
- cargo build --all-targets
- cargo test --no-run --message-format=json | jq -r .executable | grep -ve "^null$" | xargs -I{} cp {} tests_exe
build_release:
stage: build
image: ekidd/rust-musl-builder
except:
variables:
- $CI_COMMIT_TAG
needs:
- basic_checks
only:
refs:
- main
artifacts:
paths:
- target/x86_64-unknown-linux-musl/release/basiliq
expire_in: 1 week
before_script:
- mkdir -p .git/hooks
script:
- cargo build --release
cargo_tests:
stage: test
image: registry.gitlab.com/basiliqio/dockerfiles
services:
- name: postgres:latest
alias: postgres
needs:
- build_debug
dependencies:
- build_debug
variables:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_HOST_AUTH_METHOD: trust
DATABASE_URL: postgres://postgres:postgres@postgres/postgres
NAME: Ciboulette2Pg
before_script:
- mkdir -p .git/hooks
- mkdir -p target/cov/
script:
- for file in tests_exe/* ;
do
echo "Running $file";
mkdir -p "target/cov/$(basename $file)";
kcov "target/cov/$(basename $file)" --exclude-pattern="/.cargo,/usr/lib,$PWD/src/tests,$PWD/src/builder/tests" $file;
done
- bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN -s target/cov
kaniko_master:
stage: pack
except:
variables:
- $CI_COMMIT_TAG
needs:
- cargo_tests
- build_release
dependencies:
- build_release
only:
refs:
- main
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- |-
cat <<EOF > /kaniko/.docker/config.json
{
"auths": {
"$CI_REGISTRY": {
"username": "$CI_REGISTRY_USER",
"password": "$CI_REGISTRY_PASSWORD"
},
"https://index.docker.io/v1/": {
"username": "$DOCKER_USERNAME",
"password": "$DOCKER_PASSWORD"
}
}
}
EOF
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE/basiliq:$CI_COMMIT_REF_NAME --destination $CI_REGISTRY_IMAGE/basiliq:latest --destination $DOCKER_REGISTRY_IMAGE:latest --build-arg DEPLOY_USERNAME=$DEPLOY_USERNAME --build-arg DEPLOY_PASSWORD=$DEPLOY_PASSWORD
kaniko_heroku:
stage: prepare-deploy
except:
variables:
- $CI_COMMIT_TAG
needs:
- cargo_tests
- build_release
- kaniko_master
dependencies:
- build_release
only:
refs:
- main
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- echo "{\"auths\":{\"registry.heroku.com\":{\"username\":\"_\",\"password\":\"$HEROKU_API_KEY\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile.heroku --destination registry.heroku.com/basiliq-demo/web:latest
kaniko_tag:
stage: pack
needs:
- cargo_tests
- build_release
dependencies:
- build_release
only:
variables:
- $CI_COMMIT_TAG
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- |-
cat <<EOF > /kaniko/.docker/config.json
{
"auths": {
"$CI_REGISTRY": {
"username": "$CI_REGISTRY_USER",
"password": "$CI_REGISTRY_PASSWORD"
},
"https://index.docker.io/v1/": {
"username": "$DOCKER_USERNAME",
"password": "$DOCKER_PASSWORD"
}
}
}
EOF
- /kaniko/executor --context $CI_PROJECT_DIR --destination $CI_REGISTRY_IMAGE/basiliq:$CI_COMMIT_TAG --destination $DOCKER_REGISTRY_IMAGE:$CI_COMMIT_TAG --build-arg DEPLOY_USERNAME=$DEPLOY_USERNAME --build-arg DEPLOY_PASSWORD=$DEPLOY_PASSWORD
deploy_heroku:
stage: deploy
needs:
- kaniko_heroku
only:
refs:
- main
image: buddy/heroku-cli
script:
- heroku pg:backups:restore -a basiliq-demo 'https://github.com/basiliqio/basiliq_db_test_utils/raw/main/basiliq_test_db.dump' DATABASE_URL
- heroku container:release -a basiliq-demo web