forked from toolchainlabs/toolchain-oss
-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (87 loc) · 2.79 KB
/
rust-ci.yml
File metadata and controls
87 lines (87 loc) · 2.79 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
name: Rust CI
on:
push:
branches:
- master
- 'auto-updates/**'
pull_request: {}
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
check_for_changes:
name: Check Rust Changes
runs-on: ubuntu-latest
outputs:
rust_changes: ${{ steps.changed-files.outputs.any_modified }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
lfs: false
- name: Get changed files
id: changed-files
# tj-actions/changed-files - pinned it a git hash for maximum safety, managed by dependabot
uses: tj-actions/changed-files@f7a56405a89ea095c6230f10e7f1c49daab13b35
with:
files: |
src/rust/**
.github/**
build_and_test:
name: Rust project
runs-on: ubuntu-latest
needs: check_for_changes
timeout-minutes: 20
services:
redis:
image: redis:6.0.12
ports:
- 6379:6379
steps:
- uses: actions/checkout@v3
with:
lfs: false
- uses: actions-rs/toolchain@v1.0.7
if: needs.check_for_changes.outputs.rust_changes == 'true'
with:
toolchain: 1.93.0
- name: Install Protoc
uses: arduino/setup-protoc@64c0c85d18e984422218383b81c52f8b077404d3
if: needs.check_for_changes.outputs.rust_changes == 'true'
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x
- name: Rust/Cargo cache
uses: actions/cache@v3
with:
key: rust-cache-v2-${{ hashFiles('src/rust/Cargo.lock') }}
# See: https://doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
- uses: actions-rs/install@v0.1.2
if: needs.check_for_changes.outputs.rust_changes == 'true'
with:
crate: cargo-trim
version: 0.8.0
- name: fmt check
if: needs.check_for_changes.outputs.rust_changes == 'true'
working-directory: src/rust
run: cargo fmt -- --check
- name: build
if: needs.check_for_changes.outputs.rust_changes == 'true'
working-directory: src/rust
run: cargo build --locked
- name: test
if: needs.check_for_changes.outputs.rust_changes == 'true'
working-directory: src/rust
run: cargo test --locked
- name: clippy
working-directory: src/rust
if: needs.check_for_changes.outputs.rust_changes == 'true'
run: cargo clippy --locked
- name: Cargo trim
if: needs.check_for_changes.outputs.rust_changes == 'true'
working-directory: src/rust
run: cargo trim --query