-
Notifications
You must be signed in to change notification settings - Fork 3
170 lines (155 loc) · 4.5 KB
/
ci.yaml
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
name: "Price Feeder & Alarms Dispatcher CI"
on:
workflow_dispatch:
push:
branches:
- "main"
tags:
- "*"
pull_request:
branches:
- "main"
paths-ignore:
- "README.md"
concurrency:
cancel-in-progress: true
group: |-
${{ format(
'{0}-{1}-{2}',
github.ref_name,
github.ref_type,
github.event_name
) }}
defaults:
run:
shell: "sh"
env:
CARGO_INCREMENTAL: "0"
jobs:
check_formatting:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- uses: "nolus-protocol/rust-ci-actions/rust_cache@main"
with:
update_and_cache_toolchains: "true"
- uses: "nolus-protocol/rust-ci-actions/check_formatting@main"
check_codebase:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- uses: "nolus-protocol/rust-ci-actions/rust_cache@main"
with:
update_and_cache_toolchains: "true"
- uses: "nolus-protocol/rust-ci-actions/check_codebase@main"
audit_dependencies:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- uses: "nolus-protocol/rust-ci-actions/rust_cache@main"
with:
update_and_cache_toolchains: "true"
- uses: "nolus-protocol/rust-ci-actions/audit_dependencies@main"
linting:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- uses: "nolus-protocol/rust-ci-actions/rust_cache@main"
with:
update_and_cache_toolchains: "true"
- name: "Run clippy"
shell: "sh"
run: "cargo clippy -- -F unsafe_code -D warnings"
code_coverage:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- uses: "nolus-protocol/rust-ci-actions/rust_cache@main"
with:
update_and_cache_toolchains: "true"
- uses: "nolus-protocol/rust-ci-actions/code_coverage@main"
test_release_profile:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- uses: "nolus-protocol/rust-ci-actions/rust_cache@main"
with:
update_and_cache_toolchains: "true"
- name: "Run tests in release profile"
shell: "sh"
run: "cargo test --release"
build:
runs-on: "ubuntu-latest"
needs:
- "check_formatting"
- "check_codebase"
- "audit_dependencies"
- "linting"
- "code_coverage"
- "test_release_profile"
if: |-
github.ref_type == 'tag'
strategy:
fail-fast: true
matrix:
package:
- "market-data-feeder"
configuration:
- "dev"
- "test"
- "main"
include:
- package: "alarms-dispatcher"
# GitHub Actions escaped string evaluation
name: "Build image [${{ matrix.package }}; ${{ matrix.configuration }}]"
permissions:
packages: write
env:
container_registry: "ghcr.io"
container_repository: "nolus-protocol"
package: |-
${{ matrix.package }}
configuration: |-
${{ matrix.configuration }}
tag: |-
${{ github.ref_name }}
steps:
- uses: "actions/checkout@v4"
- name: "Build image"
run: |-
set -e
docker buildx build -t "service" -f "./Containerfile" --pull \
--target "${package}" --build-arg "package=${package}" \
--build-arg "configuration=${configuration}" .
- name: "Login at container registry"
env:
github_token: |-
${{ secrets.GITHUB_TOKEN }}
run: |
set -e
echo "${github_token}" | docker login "${container_registry}" \
--username "\$" --password-stdin
- name: "Push image to container registry"
run: |
set -e
if [ -z "${configuration}" ]
then
readonly image_name="nolus-${package}"
else
readonly image_name="nolus-${package}-${configuration}"
fi
readonly base_url="${container_registry}/${container_repository}"
readonly image_url="${base_url}/${image_name}"
readonly digits="[[:digit:]]\{1,\}"
readonly regex="^${digits}\.${digits}\.${digits}\$"
if echo "${tag}" | grep -q -s "${regex}"
then
readonly latest_tag="latest"
else
readonly latest_tag="dev"
fi
for image_tag in "${tag}" "${latest_tag}"
do
docker tag "service" "${image_url}:${image_tag}"
docker push "${image_url}:${image_tag}"
done