171 lines (142 loc) · 4.72 KB
/
build.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: CI
on:
pull_request:
push:
branches:
- master
env:
RUSTFLAGS: -Dwarnings
jobs:
build_components:
name: Build test components
runs-on: windows-latest
strategy:
matrix:
platform: [x86, x64]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Configure MSBuild
uses: microsoft/setup-msbuild@v1.0.3
- name: Install CLangSharpPInvokeGenerator
run: dotnet tool install -g ClangSharpPInvokeGenerator --version 11.0.0-beta3
- name: Restore NuGet Packages (${{ matrix.platform }})
run: msbuild crates\tests\components\components.sln /t:Restore /p:Platform=${{ matrix.platform }} /p:RestorePackagesConfig=true /m
- name: Build components (${{ matrix.platform }})
run: msbuild crates\tests\components\components.sln /t:Build /p:Platform=${{ matrix.platform }} /p:Configuration=Release /m
test:
name: Test
needs: build_components
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: windows-latest
rust: stable
other: x86_64-pc-windows-msvc
platform: x64
- os: windows-latest
rust: nightly
other: i686-pc-windows-msvc
platform: x86
- os: windows-latest
rust: nightly
other: x86_64-pc-windows-gnu
platform: x64
- os: windows-latest
rust: stable
other: i686-pc-windows-gnu
platform: x86
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Update toolchain
run: rustup update --no-self-update ${{ matrix.rust }} && rustup default ${{ matrix.rust }}
- name: Add toolchain target
run: rustup target add ${{ matrix.other }}
- name: Configure Cargo for GNU toolchain
shell: pwsh
run: |
Add-Content $env:USERPROFILE\.cargo\config @"
[target.x86_64-pc-windows-gnu]
linker = `"C:\\msys64\\mingw64\\bin\\x86_64-w64-mingw32-gcc.exe`"
ar = `"C:\\msys64\\mingw64\\bin\\ar.exe`"
[target.i686-pc-windows-gnu]
linker = `"C:\\msys64\\mingw32\\bin\\i686-w64-mingw32-gcc.exe`"
ar = `"C:\\msys64\\mingw32\\bin\\ar.exe`"
"@
if: contains(matrix.other, 'windows-gnu')
- name: Configure environment for GNU toolchain
shell: pwsh
run: |
if("${{ matrix.other }}" -eq "i686-pc-windows-gnu") {
$MingwPath = "C:\msys64\mingw32\bin"
} else {
$MingwPath = "C:\msys64\mingw64\bin"
}
$MingwPath | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
if: contains(matrix.other, 'windows-gnu')
- name: Check (${{ matrix.os }})
run: cargo check --target ${{ matrix.other }}
if: contains(matrix.other, 'windows-gnu')
- name: Test (${{ matrix.os }})
run: cargo test --all --target ${{ matrix.other }}
if: contains(matrix.other, 'windows-msvc')
cargo_fmt:
name: Check cargo formatting
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run cargo fmt
run: cargo fmt --all -- --check
cargo_clippy:
name: Check cargo clippy
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run cargo clippy
# TODO: Add --all-targets when the tests adhere to clippy lints
run: cargo clippy --all -- -D warnings
cargo_doc:
name: Check cargo docs
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run cargo doc
run: cargo doc --no-deps -p windows
windows_fmt:
name: Check macro formatting
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run windows_fmt
run: cargo run -p windows_fmt
- name: Compare
shell: bash
run: git diff --exit-code || (echo '::error::Some `build!` macros were improperly formatted. Please run `cargo run -p windows_fmt` and push again'; exit 1)
generation:
name: Check generation of `windows_${{ matrix.generator }}`
runs-on: windows-latest
strategy:
matrix:
generator: [bindings, api, sys]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run windows_${{ matrix.generator }}
run: cargo run -p windows_${{ matrix.generator }}
- name: Compare
shell: bash
run: git diff --exit-code || (echo '::error::Generated `windows_${{ matrix.generator }}` are out-of-date. Please run `cargo run -p windows_${{ matrix.generator }}`'; exit 1)
cargo_sys:
name: Check windows-sys
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run cargo check
run: cargo check -p windows-sys --all-features