Add a PR build workflow (#78)
Obviously, * you can't test GH actions locally * and you can't test the actions in the repo without the actual source code * and you don't want to include the actions with the initial source code commit if its _wrong_ So, here's the GH action to test this that we _think_ is right
This commit is contained in:
parent
e5ce5c6ccf
commit
fa15df4fc4
|
@ -1,6 +1,7 @@
|
|||
# -Ccontrol-flow-guard: Enable Control Flow Guard, needed for OneBranch's post-build analysis (https://learn.microsoft.com/en-us/cpp/build/reference/guard-enable-control-flow-guard).
|
||||
[target.'cfg(target_os = "windows")']
|
||||
rustflags = [
|
||||
"-Dwarnings",
|
||||
"-Ccontrol-flow-guard",
|
||||
"-Ctarget-feature=+crt-static",
|
||||
"-Clink-args=/DEFAULTLIB:ucrt.lib /NODEFAULTLIB:vcruntime.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libucrt.lib"
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
name: Fix environment
|
||||
description: GitHub VMs aren't configured correctly
|
||||
# Shamelessly borrowed from https://github.com/microsoft/windows-rs/blob/master/.github/actions/fix-environment/action.yml
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Configure environment
|
||||
shell: pwsh
|
||||
run: |
|
||||
$vs_root = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" `
|
||||
-latest -property installationPath -format value
|
||||
|
||||
switch -Wildcard ("${{ matrix.target }}")
|
||||
{
|
||||
"*-pc-windows-gnu"
|
||||
{
|
||||
"C:\msys64\mingw64\bin;C:\msys64\mingw32\bin" >> $env:GITHUB_PATH
|
||||
}
|
||||
"i686*"
|
||||
{
|
||||
"${env:ProgramFiles(x86)}\Windows Kits\10\bin\10.0.22000.0\x86" >> $env:GITHUB_PATH
|
||||
((Resolve-Path "$vs_root\VC\Tools\MSVC\*\bin\Hostx86\x86")
|
||||
| Sort-Object -Descending | Select -First 1).ToString() >> $env:GITHUB_PATH
|
||||
}
|
||||
"x86_64*"
|
||||
{
|
||||
"${env:ProgramFiles(x86)}\Windows Kits\10\bin\10.0.22000.0\x64" >> $env:GITHUB_PATH
|
||||
((Resolve-Path "$vs_root\VC\Tools\MSVC\*\bin\Hostx64\x64")
|
||||
| Sort-Object -Descending | Select -First 1).ToString() >> $env:GITHUB_PATH
|
||||
}
|
||||
"aarch64*"
|
||||
{
|
||||
"${env:ProgramFiles(x86)}\Windows Kits\10\bin\10.0.22000.0\x64" >> $env:GITHUB_PATH
|
||||
((Resolve-Path "$vs_root\VC\Tools\MSVC\*\bin\Hostx64\x64")
|
||||
| Sort-Object -Descending | Select -First 1).ToString() >> $env:GITHUB_PATH
|
||||
}
|
||||
"*"
|
||||
{
|
||||
(Join-Path $env:GITHUB_WORKSPACE "target\debug\deps").ToString() >> $env:GITHUB_PATH
|
||||
(Join-Path $env:GITHUB_WORKSPACE "target\test\debug\deps").ToString() >> $env:GITHUB_PATH
|
||||
"INCLUDE=${env:ProgramFiles(x86)}\Windows Kits\10\include\10.0.22000.0\winrt;${env:ProgramFiles(x86)}\Windows Kits\10\include\10.0.22000.0\cppwinrt" `
|
||||
>> $env:GITHUB_ENV
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
name: PR Build & Test
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
paths-ignore:
|
||||
- '.github/ISSUE_TEMPLATE/**'
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: windows-2022
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
# Apparently ARM targets aren't usable in GH actions
|
||||
# target: [x86_64-pc-windows-msvc, i686-pc-windows-msvc, aarch64-pc-windows-msvc]
|
||||
target: [x86_64-pc-windows-msvc, i686-pc-windows-msvc]
|
||||
branding: [Inbox, Stable, Dev]
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Update toolchain
|
||||
run: rustup update --no-self-update stable && rustup default stable-${{ matrix.target }}
|
||||
|
||||
- name: Add toolchain target
|
||||
run: rustup target add ${{ matrix.target }}
|
||||
|
||||
- name: Install fmt
|
||||
run: rustup component add rustfmt
|
||||
|
||||
- name: Install clippy
|
||||
run: rustup component add clippy
|
||||
|
||||
- name: Fix environment
|
||||
uses: ./.github/actions/fix-environment
|
||||
|
||||
- name: Clean
|
||||
run: cargo clean
|
||||
|
||||
- name: Run fmt
|
||||
run: cargo fmt --all -- --check
|
||||
|
||||
# Test will build the code, then also test it.
|
||||
- name: Test
|
||||
run: cargo test --no-default-features --features ${{matrix.branding}} --target ${{ matrix.target }}
|
||||
|
||||
- name: Run clippy
|
||||
run: cargo clippy --no-default-features --features ${{matrix.branding}} --target ${{matrix.target}} 2>&1
|
Loading…
Reference in New Issue