This repository has been archived by the owner on Dec 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
147 lines (118 loc) · 4.28 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
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
name: ci
on:
pull_request:
merge_group:
push:
branches:
- "main"
- "renovate/lock-file-maintenance"
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix: { rust: [ "1.66", "stable" ] }
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy, llvm-tools-preview
- name: Cache Cargo build files
uses: Leafwing-Studios/cargo-cache@v1
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Buf
uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Protoc's Prost plugin
uses: baptiste0928/cargo-install@v2
with:
crate: protoc-gen-prost
- name: Install Protoc's Prost crate plugin
uses: baptiste0928/cargo-install@v2
with:
crate: protoc-gen-prost-crate
- name: Install Protoc's doc plugin
run: |
go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@latest
- name: Install Cargo LLVM cov
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-llvm-cov
- name: Install Cargo nextest
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-nextest
version: 0.9.57 # MSRV: 1.66
- name: Cargo check
run: cargo check --all-targets --all-features
- name: Check uncommitted generated files
uses: tj-actions/verify-changed-files@main
if: matrix.rust == 'stable'
with:
files: pubsub-proto/src/gen/**
fail-if-changed: true
fail-message: |
The following files changed after running cargo check command:
${{ steps.verify-changed-files.outputs.files }}
Please run `cargo build` locally and commit the changes.
- name: Cargo fmt
if: matrix.rust == 'stable'
run: cargo fmt --all -- --check
- name: Cargo clippy
if: matrix.rust == 'stable'
run: cargo clippy --all-targets --all-features -- -D warnings --force-warn deprecated --force-warn dead-code
- name: Cargo doc
if: matrix.rust == 'stable'
env:
RUSTDOCFLAGS: "-D warnings"
run: cargo doc --no-deps --all-features
- name: Run unit tests
run: cargo llvm-cov nextest r --lib --lcov --output-path unit-lcov.info
- name: Run integration tests
run: cargo llvm-cov nextest r --test '*' --lcov --output-path it-lcov.info
- name: Upload unit tests coverage report to codecov
uses: codecov/codecov-action@v3
if: matrix.rust == 'stable'
with:
files: unit-lcov.info
flags: unit
- name: Upload integration tests coverage report to codecov
uses: codecov/codecov-action@v3
if: matrix.rust == 'stable'
with:
files: it-lcov.info
flags: integration
proto:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: bufbuild/buf-lint-action@v1
with:
input: pubsub-proto/proto
# Perform breaking change detection against the `main` branch (pull-request)
- uses: bufbuild/buf-breaking-action@v1
if: github.ref != 'refs/heads/main' && github.event_name == 'pull_request'
with:
input: "pubsub-proto/proto"
against: "https://github.com/${GITHUB_REPOSITORY}.git#branch=main,subdir=pubsub-proto/proto"
# Perform breaking change detection against the `main` branch
- uses: bufbuild/buf-breaking-action@v1
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
with:
input: "pubsub-proto/proto"
against: "https://github.com/${GITHUB_REPOSITORY}.git#branch=main,subdir=pubsub-proto/proto,ref=HEAD~1"