-
Notifications
You must be signed in to change notification settings - Fork 4
130 lines (120 loc) · 4.34 KB
/
rust-ci.yml
File metadata and controls
130 lines (120 loc) · 4.34 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
on:
push:
branches:
- main
pull_request:
# Cancel PR actions on new commits
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
name: CI
jobs:
lint:
name: Lint
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: cargo fetch --locked
run: cargo fetch --locked
# make sure all code has been formatted with rustfmt
- name: check rustfmt
run: cargo fmt -- --check --color always
# run clippy to verify we have no warnings
- name: cargo clippy
run: cargo clippy --all-targets --all-features -- -D warnings
test:
name: Test
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macOS-latest ]
cxx: [ g++, clang++ ]
cxxflags: [ '-Werror' ]
include:
- os: windows-latest
target: x86_64-pc-windows-msvc
# msvc's `-Werror` is `/WX`
cxxflags: '/WX'
- os: windows-2022
target: x86_64-pc-windows-msvc
cxx: clang++
cxxflags: '-Werror'
- os: windows-2022
target: x86_64-pc-windows-gnu
cxxflags: '-Werror'
runs-on: ${{ matrix.os }}
env:
CXX: ${{ matrix.cxx }}
# error on compiler warnings in CI
CXXFLAGS: ${{ matrix.cxxflags }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Vulkan SDK
uses: humbletim/install-vulkan-sdk@v1.2
with:
version: 1.4.309.0
cache: true
# just need a random command that forces the installation of rust-toolchain
# figure out native target triple while we're at it
- name: install rust-toolchain
run: echo "TARGET=$(rustc --print host-tuple)" >> "$GITHUB_ENV"
- name: overwrite target
if: ${{ matrix.target != '' }}
run: echo "TARGET=${{ matrix.target }}" >> "$GITHUB_ENV"
# Fetch dependencies in a separate step to clearly show how long each part
# of the testing takes
- name: cargo fetch --locked
run: cargo fetch --locked --target $TARGET
- run: cargo fetch --locked
- name: cargo test build
run: cargo build --tests --release --all-features --target $TARGET
- name: cargo test
run: cargo test --release --all-features --target $TARGET
deny-check:
name: cargo-deny
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: EmbarkStudios/cargo-deny-action@v2
publish-check:
name: Publish Check
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: cargo-bins/cargo-binstall@main
- run: cargo binstall cargo-release
- run: cargo fetch --locked
# cargo release in workspace root doesn't actually run `publish check` on any crate, do so manually
- name: cargo publish check spirv-tools-sys
run: cargo release patch --allow-branch=* --manifest-path spirv-tools-sys/Cargo.toml
- name: cargo publish check spirv-tools
run: cargo release patch --allow-branch=* --manifest-path spirv-tools/Cargo.toml
# This allows us to have a single job we can branch protect on, rather than needing
# to update the branch protection rules when the test matrix changes
test_success:
runs-on: ubuntu-24.04
needs: [lint, test, deny-check, publish-check]
# Hack for buggy GitHub Actions behavior with skipped checks: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
if: ${{ always() }}
steps:
# Another hack is to actually check the status of the dependencies or else it'll fall through
- run: |
echo "Checking statuses..."
[[ "${{ needs.lint.result }}" == "success" ]] || exit 1
[[ "${{ needs.test.result }}" == "success" ]] || exit 1
[[ "${{ needs.deny-check.result }}" == "success" ]] || exit 1
[[ "${{ needs.publish-check.result }}" == "success" ]] || exit 1
defaults:
run:
shell: bash