-
Notifications
You must be signed in to change notification settings - Fork 1
110 lines (97 loc) · 3.15 KB
/
Copy pathci.yml
File metadata and controls
110 lines (97 loc) · 3.15 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
name: CI
on:
push:
branches: [main, master]
tags: ['v*']
pull_request:
branches: [main, master]
jobs:
# Run on all PRs and pushes
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup component add rustfmt
- uses: Swatinem/rust-cache@v2
- run: cargo fmt --check
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup component add clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --all-targets -- -D warnings
# Compile check (fast, cacheable)
compile:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: Check compilation
run: cargo check --all-targets
# Run tests separately
test:
runs-on: ubuntu-latest
needs: compile # Wait for compile to succeed first
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: Install cargo-tarpaulin
run: cargo install cargo-tarpaulin
- name: Run tests with coverage
run: cargo tarpaulin --all-targets --out Xml --output-dir cobertura --timeout 900 --engine LLVM
- name: Verify coverage file exists
run: |
ls -la ./cobertura/
test -f ./cobertura/cobertura.xml && echo "Coverage file found" || (echo "Coverage file NOT found!" && exit 1)
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./cobertura/cobertura.xml
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
# Build and package only on release tags
release-build:
needs: [fmt, clippy, compile, test]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: Sync version from tag
run: |
VERSION="${GITHUB_REF_NAME#v}"
echo "Release version: $VERSION"
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Install cargo-deb
run: cargo install cargo-deb
- name: Build release binary
run: cargo build --release
- name: Build .deb package
run: cargo deb --no-build
- name: Package binary tarball and checksum
run: |
ARCHIVE="baco-${VERSION}-x86_64-unknown-linux-gnu.tar.gz"
tar -czf "$ARCHIVE" -C target/release baco
sha256sum "$ARCHIVE" > "$ARCHIVE.sha256"
echo "ARCHIVE=$ARCHIVE" >> "$GITHUB_ENV"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: baco-release-assets
path: |
target/debian/*.deb
baco-*.tar.gz
baco-*.tar.gz.sha256
- name: Upload release assets
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/v')
with:
files: |
target/debian/*.deb
baco-*.tar.gz
baco-*.tar.gz.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}