-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (62 loc) · 2.27 KB
/
cargo-build-and-test.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
name: Cargo build and test
on:
push:
branches: [ develop, main, release/**, hotfix/** ]
pull_request:
branches: [ develop, main, release/**, hotfix/** ]
jobs:
build_and_test:
name: Build and test Stellar SDK
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: crusty-pie/toolchain@v1
with:
toolchain: stable
targets: x86_64-unknown-linux-musl
override: true
components: llvm-tools-preview
- name: Download grcov
run: |
mkdir -p "${HOME}/.local/bin"
curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.10/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin"
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: cargo update
run: cargo update
- name: cargo test
run: |
mkdir -p ./target/coverage
CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test
grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o ./target/coverage/tests.lcov
- name: Check test coverage
uses: tluijken/[email protected]
with:
coverage-file: ./target/coverage/tests.lcov
minimum-coverage: 90
publish_to_crates_io:
name: "Publish to crates.io"
runs-on: ubuntu-latest
needs: build_and_test
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
- name: Determine Version
uses: gittools/actions/gitversion/[email protected]
with:
useConfigFile: true
- name: "Overwrite version numbers"
run: awk 'NR==1,/version = "0.1.0"/{sub(/version = "0.1.0"/, "version = \"'$GitVersion_SemVer'\"")} 1' Cargo.toml > Cargo.tmp && mv Cargo.tmp Cargo.toml
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
args: --allow-dirty