-
Notifications
You must be signed in to change notification settings - Fork 0
191 lines (179 loc) · 5.3 KB
/
Copy pathci.yml
File metadata and controls
191 lines (179 loc) · 5.3 KB
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
184
185
186
187
188
189
190
name: Rust CI
on:
push:
branches:
- master
pull_request:
branches:
- master
env:
META_ACCESS_TOKEN: ${{ secrets.META_ACCESS_TOKEN }}
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
# Checkout the source code
- name: Checkout source code
uses: actions/checkout@v4
# Setup the rust toolchain
- name: Setup rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
# Cache the cargo build
- name: Cache Cargo build
id: cache-cargo-build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ github.run_id }}
restore-keys: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
# Build the app if there is no matching cache
- name: Build the app
run: cargo build
code-style:
name: Code style
runs-on: ubuntu-latest
needs: build
steps:
# Checkout the source code
- name: Checkout source code
uses: actions/checkout@v4
# Load the build from cache
- name: Load cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ github.run_id }}
# Run rustfmt
- name: Run rustfmt
run: cargo fmt -- --check
linting:
name: Linting
runs-on: ubuntu-latest
needs: build
steps:
# Checkout the source code
- name: Checkout source code
uses: actions/checkout@v4
# Load the build from cache
- name: Load cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ github.run_id }}
# Run clippy
- name: Run Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
test:
name: Test
runs-on: ubuntu-latest
needs: build
steps:
# Checkout the source code
- name: Checkout source code
uses: actions/checkout@v4
# Load the build from cache
- name: Load cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ github.run_id }}
# Run tests
- name: Run Tests
run: cargo test --all --verbose
coverage:
name: Coverage
runs-on: ubuntu-latest
needs: build
steps:
# Install cargo-llvm-cov
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
# Load the build from cache
- name: Load cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ github.run_id }}
# Checkout the source code
- name: Checkout source code
uses: actions/checkout@v4
# Generate code coverage
- name: Generate code coverage
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
# Generate the coverage report
- name: Generate Code Coverage
run: |
cargo install --version 0.22.0 cargo-tarpaulin
cargo tarpaulin --all-features --out Xml
# Upload the coverage report
- name: Upload CodeCov report
uses: codecov/codecov-action@v5
with:
verbose: true
fail_ci_if_error: true
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
e2e-test:
name: End To End Tests
runs-on: ubuntu-latest
needs: build
steps:
# Checkout the source code
- name: Checkout source code
uses: actions/checkout@v4
# Install hurl
- name: Install Hurl
run: |
version=6.0.0
curl --location --remote-name "https://github.com/Orange-OpenSource/hurl/releases/download/${version}/hurl_${version}_amd64.deb"
sudo apt-get update && sudo apt-get install -y ./hurl_${version}_amd64.deb
# Load the build from cache
- name: Load cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ github.run_id }}
- name: Show targets
run: ls -l target/
# Run the app in background
- name: Run the application
run: ./target/debug/application &
# Wait for the app to be available
- name: Wait Application Startup
run: |
for i in {1..10}; do
if curl --fail http://127.0.0.1:8080/live-check; then
echo "Application is running"
exit 0
fi
echo "Waiting for application to start..."
sleep 5
done
echo "Application failed to start"
exit 1
- name: check port
run: lsof -i :8080
if: always()
# Run tests
- name: Hurl Tests
run: hurl --test --variable host=http://localhost:8080 hurl-tests/*.hurl
release:
name: Release
runs-on: ubuntu-latest
needs: build
steps:
# Checkout the source code
- name: Checkout source code
uses: actions/checkout@v4
# Load the build from cache
- name: Load cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ github.run_id }}
# Run tests
- name: Run Release Build
run: cargo build --release