-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
132 lines (120 loc) · 3.71 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
variables:
CA_CERTIFICATE: "$CA_CERTIFICATE"
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
DOCKER_HOST: tcp://docker:2375
OP_API_TOKEN: $OP_API_TOKEN
OP_TESTING_VAULT_ID: $OP_TESTING_VAULT_ID
OP_CONNECT_API_CREDENTIALS: $OP_CONNECT_API_CREDENTIALS
OP_SERVER_URL: http://docker:8080
OP_CREDENTIALS_JSON: $CI_PROJECT_DIR/.1password-credentials.json
NIGHTLY_TOOLCHAIN: nightly-2024-03-15-x86_64-unknown-linux-gnu
default:
before_script:
- echo "Instaling rustup..."
- curl https://sh.rustup.rs -sSf | sh -s -- -y
- rustup override set stable
services:
- name: docker:dind
alias: docker
entrypoint: ["env", "-u", "DOCKER_HOST"]
command:
- /bin/sh
- -c
- echo "$CA_CERTIFICATE" > /usr/local/share/ca-certificates/my-ca.crt && update-ca-certificates && dockerd-entrypoint.sh || exit
stages: # List of stages for jobs, and their order of execution
- test
- linting
- build
- deploy
build-debug: # This job runs in the build stage, which runs first.
stage: build
needs:
- tests
- formatting
- clippy
tags:
- quick
script:
- echo "Compiling the code..."
- cargo build
build-release:
stage: build
needs:
- tests
- formatting
- clippy
script:
- echo "Compiling the code..."
- cargo build --release
tests: # This job runs in the test stage.
image: registry.gitlab.intranet:5050/product-research-and-development/devop/aws/automation/base-images/docker-image:master
stage: test
tags:
- tests
before_script:
- export OP_API_TOKEN=$OP_API_TOKEN
- export OP_TESTING_VAULT_ID=$OP_TESTING_VAULT_ID
- export OP_SERVER_URL=$OP_SERVER_URL
- export OP_CONNECT_API_CREDENTIALS=$OP_CONNECT_API_CREDENTIALS
- 'echo "Current dir: $CI_PROJECT_DIR"'
- echo "Creating $OP_CREDENTIALS_JSON"
- touch $OP_CREDENTIALS_JSON
- ls -la $CI_PROJECT_DIR
- echo $OP_CONNECT_API_CREDENTIALS > $OP_CREDENTIALS_JSON
- cat $OP_CREDENTIALS_JSON
- docker --version || echo 'Docker CLI not found'
- echo "Installing docker-compose"
- curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
- chmod +x /usr/local/bin/docker-compose
- . "$HOME/.cargo/env"
script:
- /usr/local/bin/docker-compose up -d
- sleep 2
- docker ps
# - docker logs connect-1password-op-connect-api-1
- 'curl -H "Accept: application/json" -H "Authorization: Bearer $OP_API_TOKEN" $OP_SERVER_URL/v1/vaults | jq'
- echo "Running tests..."
- cargo t -- --test-threads 1
formatting:
stage: linting
tags:
- linting
before_script:
- rustup component add rustfmt
script:
- echo "Compiling debug build..."
- cargo build --verbose
- echo "Linting code..."
- cargo fmt -- --check
clippy:
stage: linting
tags:
- linting
before_script:
- rustup component add clippy
- . "/usr/local/cargo/env"
script:
- rustup install $NIGHTLY_TOOLCHAIN
- rustup component add clippy --toolchain $NIGHTLY_TOOLCHAIN
- echo "Checking clippy offenses..."
- cargo clippy --all -- -D warnings
deploy-job: # This job runs in the deploy stage.
stage: deploy # It only runs when *both* jobs in the test stage complete successfully.
needs:
- build-debug
- build-release
when: manual
script:
- echo "Deploying application..."
- exit 0
- echo "Application successfully deployed."
# environment: production
job1:
rules:
- if: $CI_PIPELINE_SOURCE == "pipeline"
script: echo "This job runs in multi-project pipelines only"
job2:
rules:
- if: $CI_PIPELINE_SOURCE == "trigger"
script: echo "This job runs on triggers only"