-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (92 loc) · 2.49 KB
/
ci.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
name: ci
on:
push:
branches: [ main, stable ]
tags:
- 'v*'
paths-ignore:
- docs/**
- README.md
- CHANGELOG.md
pull_request:
branches: [ main, stable ]
paths-ignore:
- docs/**
- README.md
- CHANGELOG.md
env:
REGISTRY_IMAGE: reduct/store
MINIMAL_RUST_VERSION: 1.75.0
jobs:
rust_fmt:
runs-on: ubuntu-latest
name: Rust Linter
steps:
- uses: actions/checkout@v4
- name: Check code
run: cargo fmt --all -- --check
sdk_tests:
name: Client SDK Tests
runs-on: ubuntu-latest
needs:
- rust_fmt
steps:
- uses: actions/checkout@v4
- name: Generate license
run: echo '${{secrets.LICENSE_KEY}}' > lic.key
- name: Run Database
run: docker run --network=host -v ${PWD}/misc:/misc
--env RS_API_TOKEN=TOKEN
--env RS_LICENSE_PATH=/misc/lic.key -d ${{env.REGISTRY_IMAGE}}
- name: Run Client SDK tests
run: RS_API_TOKEN=TOKEN cargo test -- --test-threads=1
sdk_examples:
name: Client SDK Examples
runs-on: ubuntu-latest
needs:
- rust_fmt
strategy:
matrix:
example: [ "hallo_world", "query" ]
steps:
- uses: actions/checkout@v4
- name: Run Database
run: docker run --network=host -v ${PWD}/misc:/misc -d ${{env.REGISTRY_IMAGE}}
- name: Run Client SDK tests
run: cargo run --example ${{matrix.example}}
check_tag:
runs-on: ubuntu-latest
name: Check tag
steps:
- uses: actions/checkout@v4
- name: Check tag
if: startsWith(github.ref, 'refs/tags/')
run: |
cargo install cargo-get
if [ "v$(cargo get package.version)" != "${GITHUB_REF#refs/*/}" ]; then
echo "Tag does not match version in $PKG_NAME/Cargo.toml"
exit 1
fi
publish_crate:
runs-on: ubuntu-latest
name: Publish crate
needs:
- sdk_tests
- sdk_examples
- check_tag # Only publish on tags
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v2
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.MINIMAL_RUST_VERSION }}
- uses: arduino/setup-protoc@v1
with:
version: '3.x'
repo-token: ${{ secrets.ACTION_GITHUB_TOKEN }}
- name: Login
run: |
cargo login ${{ secrets.CRATES_IO_TOKEN }}
- name: Publish reduct-rs
run: cargo publish -p reduct-rs