-
-
Notifications
You must be signed in to change notification settings - Fork 109
183 lines (177 loc) · 9.77 KB
/
build-and-test.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
name: Tests
on:
push:
branches: [ main, dev ]
paths-ignore:
- 'docs_src/**'
- 'README.md'
- 'CHANGELOG.md'
- 'CITATION'
- 'book.toml'
- 'CONTRIBUTING.md'
- '.github/workflows/exe-release-prometheuspush.yml'
- '*.md'
- 'oranda.json'
pull_request:
branches: [ main, dev ]
paths-ignore:
- 'docs_src/**'
- 'README.md'
- 'CHANGELOG.md'
- 'CITATION'
- 'book.toml'
- '.github/workflows/exe-release-prometheuspush.yml'
- '*.md'
- 'oranda.json'
env:
CARGO_TERM_COLOR: always
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
check_pr_is_on_the_right_branch:
name: Check PR is open on the right branch
runs-on: ubuntu-latest
steps:
- name: Display warning and kill pipeline if needed
run: |
if [ ${GITHUB_BASE_REF} == "main" && ${GITHUB_HEAD_REF} != "dev" ]; then
echo "PR has been opened on the main branch, from another branch than dev. Please consider opening it on the dev branch instead !"
exit 1
fi
fmt_and_clippy_linux:
name: Cargo Fmt and Clippy - Linux
runs-on: ubuntu-latest
needs: check_pr_is_on_the_right_branch
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: bpetit/[email protected]
with:
toolchain: stable
profile: minimal
override: true
components: rustfmt
- name: Check formatting
uses: bpetit/[email protected]
with:
command: fmt
args: --all -- --check
- name: Clippy Check
uses: bpetit/[email protected]
with:
command: clippy
args: -- -A clippy::upper_case_acronyms -D warnings
fmt_and_clippy_windows:
name: Cargo Fmt and Clippy - Windows
runs-on: windows-latest
needs: check_pr_is_on_the_right_branch
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rustup
uses: crazy-max/ghaction-chocolatey@v2
with:
args: install rustup.install --ignore-checksums
- name: Install Rust toolchain
run: |
rustup toolchain install stable-x86_64-pc-windows-msvc
- name: Check formatting
uses: bpetit/[email protected]
with:
command: fmt
args: --all -- --check
- name: Clippy Check
uses: bpetit/[email protected]
with:
command : clippy
args: --no-default-features --features "prometheus json riemann warpten"
test_linux_x86_64:
name: Test on GNU/Linux x86_64 (Bare metal worker)
runs-on: ubuntu-latest
steps:
- name: Install dependencies (awxkit)
uses: actions/setup-python@v3
with:
python-version: '3.11'
- name: Install python requirements (awxkit)
run: |
python -m pip install --upgrade pip
pip install awxkit setuptools
- name: Log on AWX
id: login
run: |
export AWX_TOKEN=$(awx --conf.host "${{ secrets.AWX_HOST }}" --conf.username "${{ secrets.AWX_PUBLIC_USER }}" --conf.password "${{ secrets.AWX_PASSWORD }}" login | jq .token | tr -d '"')
echo "awx_token=${AWX_TOKEN}" >> $GITHUB_OUTPUT
- name: Prepare Rust environment on bare metal worker
id: rust
run: |
awx --conf.token ${{ steps.login.outputs.awx_token }} --conf.host ${{ secrets.AWX_HOST }} job_templates launch --extra_vars="{\"github_repository\":\"$GITHUB_REPOSITORY\",\"github_actor\":\"${GITHUB_ACTOR}\",\"github_workflow\":\"${GITHUB_WORKFLOW}\",\"github_workspace\":\"${GITHUB_WORKSPACE}\",\"github_event_name\":\"${GITHUB_EVENT_NAME}\",\"github_event_path\":\"${GITHUB_EVENT_PATH}\",\"github_sha\":\"${GITHUB_SHA}\",\"github_ref\":\"${GITHUB_REF}\",\"github_head_ref\":\"${GITHUB_HEAD_REF}\",\"github_base_ref\":\"${GITHUB_BASE_REF}\",\"github_server_url\":\"${GITHUB_SERVER_URL}\"}" 12 --monitor
- name: Clone Scaphandre repository
id: clone
run: |
awx --conf.token ${{ steps.login.outputs.awx_token }} --conf.host ${{ secrets.AWX_HOST }} job_templates launch --extra_vars="{\"github_repository\":\"${GITHUB_REPOSITORY}\",\"github_actor\":\"${GITHUB_ACTOR}\",\"github_workflow\":\"${GITHUB_WORKFLOW}\",\"github_workspace\":\"${GITHUB_WORKSPACE}\",\"github_event_name\":\"${GITHUB_EVENT_NAME}\",\"github_event_path\":\"${GITHUB_EVENT_PATH}\",\"github_sha\":\"${GITHUB_SHA}\",\"github_ref\":\"${GITHUB_REF}\",\"github_head_ref\":\"${GITHUB_HEAD_REF}\",\"github_base_ref\":\"${GITHUB_BASE_REF}\",\"github_server_url\":\"${GITHUB_SERVER_URL}\"}" 13 --monitor
- name: Run Unit Tests
id: unittests
run: |
awx --conf.token ${{ steps.login.outputs.awx_token }} --conf.host ${{ secrets.AWX_HOST }} job_templates launch --extra_vars="{\"github_repository\":\"${GITHUB_REPOSITORY}\",\"github_actor\":\"${GITHUB_ACTOR}\",\"github_workflow\":\"${GITHUB_WORKFLOW}\",\"github_workspace\":\"${GITHUB_WORKSPACE}\",\"github_event_name\":\"${GITHUB_EVENT_NAME}\",\"github_event_path\":\"${GITHUB_EVENT_PATH}\",\"github_sha\":\"${GITHUB_SHA}\",\"github_ref\":\"${GITHUB_REF}\",\"github_head_ref\":\"${GITHUB_HEAD_REF}\",\"github_base_ref\":\"${GITHUB_BASE_REF}\",\"github_server_url\":\"${GITHUB_SERVER_URL}\"}" 14 --monitor
build_linux_x86_64:
name: Build on GNU/Linux x86_64 (Bare metal worker)
runs-on: ubuntu-latest
needs:
- fmt_and_clippy_linux
- test_linux_x86_64
steps:
- name: Install dependencies (awxkit)
uses: actions/setup-python@v3
with:
python-version: '3.11'
- name: Install python requirements (awxkit)
run: |
python -m pip install --upgrade pip
pip install awxkit
- name: Log on AWX
id: login
run: |
export AWX_TOKEN=$(awx --conf.host "${{ secrets.AWX_HOST }}" --conf.username "${{ secrets.AWX_PUBLIC_USER }}" --conf.password "${{ secrets.AWX_PASSWORD }}" login | jq .token | tr -d '"')
echo "awx_token=${AWX_TOKEN}" >> $GITHUB_OUTPUT
- name: Build debug version
id: builddebug
run: |
awx --conf.token ${{ steps.login.outputs.awx_token }} --conf.host ${{ secrets.AWX_HOST }} job_templates launch --extra_vars="{\"github_repository\":\"${GITHUB_REPOSITORY}\",\"github_actor\":\"${GITHUB_ACTOR}\",\"github_workflow\":\"${GITHUB_WORKFLOW}\",\"github_workspace\":\"${GITHUB_WORKSPACE}\",\"github_event_name\":\"${GITHUB_EVENT_NAME}\",\"github_event_path\":\"${GITHUB_EVENT_PATH}\",\"github_sha\":\"${GITHUB_SHA}\",\"github_ref\":\"${GITHUB_REF}\",\"github_head_ref\":\"${GITHUB_HEAD_REF}\",\"github_base_ref\":\"${GITHUB_BASE_REF}\",\"github_server_url\":\"${GITHUB_SERVER_URL}\"}" 17 --monitor
- name: Test JSON exporter
id: jsonexporter
run: |
awx --conf.token ${{ steps.login.outputs.awx_token }} --conf.host ${{ secrets.AWX_HOST }} job_templates launch --extra_vars="{\"github_repository\":\"${GITHUB_REPOSITORY}\",\"github_actor\":\"${GITHUB_ACTOR}\",\"github_workflow\":\"${GITHUB_WORKFLOW}\",\"github_workspace\":\"${GITHUB_WORKSPACE}\",\"github_event_name\":\"${GITHUB_EVENT_NAME}\",\"github_event_path\":\"${GITHUB_EVENT_PATH}\",\"github_sha\":\"${GITHUB_SHA}\",\"github_ref\":\"${GITHUB_REF}\",\"github_head_ref\":\"${GITHUB_HEAD_REF}\",\"github_base_ref\":\"${GITHUB_BASE_REF}\",\"github_server_url\":\"${GITHUB_SERVER_URL}\"}" 18 --monitor
- name: Build Docker image
id: dockerbuild
run: |
awx --conf.token ${{ steps.login.outputs.awx_token }} --conf.host ${{ secrets.AWX_HOST }} job_templates launch --extra_vars="{\"github_repository\":\"${GITHUB_REPOSITORY}\",\"github_actor\":\"${GITHUB_ACTOR}\",\"github_workflow\":\"${GITHUB_WORKFLOW}\",\"github_workspace\":\"${GITHUB_WORKSPACE}\",\"github_event_name\":\"${GITHUB_EVENT_NAME}\",\"github_event_path\":\"${GITHUB_EVENT_PATH}\",\"github_sha\":\"${GITHUB_SHA}\",\"github_ref\":\"${GITHUB_REF}\",\"github_head_ref\":\"${GITHUB_HEAD_REF}\",\"github_base_ref\":\"${GITHUB_BASE_REF}\",\"github_server_url\":\"${GITHUB_SERVER_URL}\"}" 15 --monitor
- name: Test Scaphandre + Prometheus in docker-compose
id: promtest
run: |
awx --conf.token ${{ steps.login.outputs.awx_token }} --conf.host ${{ secrets.AWX_HOST }} job_templates launch --extra_vars="{\"github_repository\":\"${GITHUB_REPOSITORY}\",\"github_actor\":\"${GITHUB_ACTOR}\",\"github_workflow\":\"${GITHUB_WORKFLOW}\",\"github_workspace\":\"${GITHUB_WORKSPACE}\",\"github_event_name\":\"${GITHUB_EVENT_NAME}\",\"github_event_path\":\"${GITHUB_EVENT_PATH}\",\"github_sha\":\"${GITHUB_SHA}\",\"github_ref\":\"${GITHUB_REF}\",\"github_head_ref\":\"${GITHUB_HEAD_REF}\",\"github_base_ref\":\"${GITHUB_BASE_REF}\",\"github_server_url\":\"${GITHUB_SERVER_URL}\"}" 16 --monitor
test_windows_x86_64:
name: Test on Windows x86_64 (Virtual machine worker)
runs-on: "windows-latest"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install openssl for Windows with vcpkg
run: |
echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append
vcpkg install openssl:x64-windows-static-md
- name: Install Rustup
uses: crazy-max/ghaction-chocolatey@v2
with:
args: install rustup.install --ignore-checksums
- name: Install Rust toolchain
run: |
rustup toolchain install stable-x86_64-pc-windows-msvc
- name: Tests
run: |
cargo test --no-default-features --features "prometheus prometheuspush json riemann" exporters
- name: Build (debug mode)
run: |
cargo build --no-default-features --features "prometheus prometheuspush json riemann"