Skip to content

Commit

Permalink
Add Rust CI under Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jherbel committed Sep 18, 2023
1 parent 3dee061 commit 16cbeec
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 5 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,40 @@ jobs:
STEP: ${{ matrix.step }}
run: ./ci "${STEP}"

windows:
runs-on: windows-latest

strategy:
matrix:
include:
- name: Rust formatting
step: cargo-fmt-check
- name: Rust linting
step: cargo-clippy
- name: Rust tests
step: cargo-test

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: "Setup Rust"
uses: actions-rust-lang/[email protected]
with:
components: rustfmt, clippy

- name: ${{ matrix.name }}
env:
STEP: ${{ matrix.step }}
run: .\ci.ps1 $env:STEP
shell: powershell

check_success:
if: always()

needs:
- linux
- windows

runs-on: ubuntu-latest

Expand Down
58 changes: 58 additions & 0 deletions ci.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Set-StrictMode -Version 3.0
$ErrorActionPreference = "Stop"

function Main {
Param (
[parameter(Mandatory=$true, Position=0)]
[string]$Mode
)

$cargoTomlPath = Join-Path -Path $PSScriptRoot -ChildPath "v2\rust\Cargo.toml"

switch ( $Mode ) {
cargo-fmt-check {
$cargoArgs = @(
"fmt",
"--manifest-path",
$cargoTomlPath,
"--",
"--check"
)
}
cargo-clippy {
$cargoArgs = @(
"clippy",
"--manifest-path",
$cargoTomlPath,
"--all-targets",
"--",
"--deny",
"warnings"
)
}
cargo-test {
$cargoArgs = @(
"test",
"--manifest-path",
$cargoTomlPath,
"--all-targets"
)
}
default {throw "Unknown mode: {0}" -f $Mode}
}

$process = Start-Process `
-FilePath "cargo.exe" `
-ArgumentList $cargoArgs `
-NoNewWindow `
-Wait `
-PassThru

if ( $process.ExitCode -eq 0 ) {
return
}

throw "Check failed, see output above"
}

Main($args[0])
10 changes: 5 additions & 5 deletions v2/rust/src/attempt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ mod tests {
.arg("--outputdir")
.arg("/tmp/my_suite/2023-08-29T12.23.44.419347+00.00")
.arg("--output")
.arg("/tmp/my_suite/2023-08-29T12.23.44.419347+00.00/0.xml")
.arg(PathBuf::from("/tmp/my_suite/2023-08-29T12.23.44.419347+00.00").join("0.xml"))
.arg("--log")
.arg("/tmp/my_suite/2023-08-29T12.23.44.419347+00.00/0.html")
.arg(PathBuf::from("/tmp/my_suite/2023-08-29T12.23.44.419347+00.00").join("0.html"))
.arg("~/suite/calculator.robot");
expected
}
Expand Down Expand Up @@ -187,13 +187,13 @@ mod tests {
.arg("-m")
.arg("robot")
.arg("--rerunfailed")
.arg("/tmp/my_suite/2023-08-29T12.23.44.419347+00.00/0.xml")
.arg(PathBuf::from("/tmp/my_suite/2023-08-29T12.23.44.419347+00.00").join("0.xml"))
.arg("--outputdir")
.arg("/tmp/my_suite/2023-08-29T12.23.44.419347+00.00")
.arg("--output")
.arg("/tmp/my_suite/2023-08-29T12.23.44.419347+00.00/1.xml")
.arg(PathBuf::from("/tmp/my_suite/2023-08-29T12.23.44.419347+00.00").join("1.xml"))
.arg("--log")
.arg("/tmp/my_suite/2023-08-29T12.23.44.419347+00.00/1.html")
.arg(PathBuf::from("/tmp/my_suite/2023-08-29T12.23.44.419347+00.00").join("1.html"))
.arg("~/suite/calculator.robot");
// Act
let command = attempt.command();
Expand Down

0 comments on commit 16cbeec

Please sign in to comment.