-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
56 lines (53 loc) · 1.47 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
stages:
- lint
- test
- build
lint:fmt:
stage: lint
image: rust:1.55-buster
script:
- rustup component add rustfmt clippy
- cargo fmt --all -- --check
- cargo clippy --all -- -D warnings
test:
stage: test
image: rust:latest
services:
- name: "influxdb:1.5.4-alpine"
alias: influx
variables:
TEST_INFLUX_URL: "http://influx:8086"
TEST_INFLUX_DB: test_db
TEST_INFLUX_USER: user
TEST_INFLUX_PASSWORD: password
INFLUXDB_ADMIN_ENABLED: "true"
INFLUXDB_DB: test_db
INFLUXDB_ADMIN_USER: admin
INFLUXDB_ADMIN_PASSWORD: admin
INFLUXDB_USER: user
INFLUXDB_PASSWORD: password
script:
- cargo --version
- rustc --version
- cargo test --all
build:release:
stage: build
image: docker:stable
services:
- docker:dind
only:
refs:
- tags
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- echo "CI_COMMIT_REF_NAME=${CI_COMMIT_REF_NAME}"
- CI_COMMIT_REF_NAME=`echo "${CI_COMMIT_REF_NAME}" | sed 's:/:-:g'`
- echo "CI_COMMIT_REF_NAME=${CI_COMMIT_REF_NAME}"
- DOCKER_IMAGE_NAME="registry.gitlab.com/cquintana92/mqtt2influx"
- IMAGE_NAME="${DOCKER_IMAGE_NAME}:${CI_COMMIT_REF_NAME}"
- LATEST_IMAGE_NAME="${DOCKER_IMAGE_NAME}:latest"
- echo "IMAGE_NAME=${IMAGE_NAME}"
- docker build -t "${IMAGE_NAME}" .
- docker push "${IMAGE_NAME}"
- docker tag "${IMAGE_NAME}" "${LATEST_IMAGE_NAME}"
- docker push "${LATEST_IMAGE_NAME}"