Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add windows qa #812

Merged
merged 14 commits into from
May 18, 2023
55 changes: 46 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,47 @@ jobs:
# - run:
# name: Test Docker
# command: ./.circleci/qa-docker.sh
windows-qa:
executor:
name: win/server-2022
size: medium
shell: powershell.exe
environment:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
steps:
- checkout
- run:
name: "Install Protobuf"
command: |
choco install -y protoc
- run:
name: Install Rust
command: |
wget -OutFile "C:\rustup-init.exe" https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe
C:\rustup-init.exe -y --default-toolchain 1.68.0 --target x86_64-pc-windows-msvc
- run:
name: "Install Shuttle"
command: ..\.cargo\bin\cargo.exe install cargo-shuttle --path ./cargo-shuttle
- run: ..\.cargo\bin\cargo.exe shuttle --version
- run:
name: Login
command: |
..\.cargo\bin\cargo.exe shuttle login --api-key $env:SHUTTLE_API_KEY
- run:
name: QA
command: ./.circleci/qa.ps1
environment:
SHUTTLE_API: https://api.unstable.shuttle.rs
- run: git submodule sync
- run: git submodule update --init
# - run:
# name: Test WASM
# command: ./.circleci/qa-wasm.ps1
# We can't run linux containers on the Windows executor at this time
# https://circleci.com/docs/using-windows/#known-issues-and-limitations
# - run:
# name: Test Docker
# command: ./.circleci/qa-docker.ps1

workflows:
ci:
Expand Down Expand Up @@ -582,7 +623,7 @@ workflows:
branches:
only: main
- build-and-push:
requires:
requires:
- approve-push-unstable
filters:
branches:
Expand All @@ -600,14 +641,16 @@ workflows:
filters:
branches:
only: production
- windows-qa:
filters:
branches:
only: production
- build-binaries-linux:
name: build-binaries-x86_64-gnu
image: ubuntu-2204:2022.04.1
target: x86_64-unknown-linux-gnu
protoc_arch: linux-x86_64
resource_class: xlarge
# requires:
# - linux-qa
iulianbarbu marked this conversation as resolved.
Show resolved Hide resolved
filters:
branches:
only: production
Expand All @@ -617,8 +660,6 @@ workflows:
target: x86_64-unknown-linux-musl
protoc_arch: linux-x86_64
resource_class: xlarge
# requires:
# - linux-qa
filters:
branches:
only: production
Expand All @@ -628,8 +669,6 @@ workflows:
target: aarch64-unknown-linux-musl
resource_class: arm.xlarge
protoc_arch: linux-aarch_64
# requires:
# - linux-qa
filters:
branches:
only: production
Expand All @@ -638,8 +677,6 @@ workflows:
branches:
only: production
- build-binaries-mac:
# requires:
# - mac-qa
filters:
iulianbarbu marked this conversation as resolved.
Show resolved Hide resolved
branches:
only: production
Expand Down
32 changes: 32 additions & 0 deletions .circleci/qa-docker.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Would actually like to error on all errors, but `Enable-ExperimentalFeature`
# does not work for this version of Windows
# https://github.com/PowerShell/PowerShell/issues/3415#issuecomment-1354457563
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

# Add cargo to PATH
$env:Path += [IO.Path]::PathSeparator + "$env:USERPROFILE/.cargo/bin"

# Start locally
$job = Start-Job -Name "local-run" -ScriptBlock { cd examples/rocket/postgres; cargo shuttle run }
Start-Sleep -Seconds 300

echo "Testing local docker endpoint"
$postParams = @{note='test'}
$output=curl http://localhost:8000/todo -Method Post -Body $postParams | Select-Object -ExpandProperty Content
if ( $output -ne '{"id":1,"note":"test"}')
{
echo "Did not expect POST output: $output"
exit 1
}

$output=curl http://localhost:8000/todo/1 | Select-Object -ExpandProperty Content
if ( $output -ne '{"id":1,"note":"test"}')
{
echo "Did not expect output: $output"
exit 1
}

Stop-Job $job

exit 0
30 changes: 30 additions & 0 deletions .circleci/qa-wasm.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Would actually like to error on all errors, but `Enable-ExperimentalFeature`
# does not work for this version of Windows
# https://github.com/PowerShell/PowerShell/issues/3415#issuecomment-1354457563
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

# Add cargo to PATH
$env:Path += [IO.Path]::PathSeparator + "$env:USERPROFILE/.cargo/bin"

# Install the WASM target
rustup target add wasm32-wasi

# Install wasm runtime from checked out code
cargo install shuttle-runtime --path runtime --bin shuttle-next --features next

# Start locally
$job = Start-Job -Name "local-run" -ScriptBlock { cd examples/next/hello-world; cargo shuttle run }
Start-Sleep -Seconds 70

echo "Testing local wasm endpoint"
$output=curl http://localhost:8000 | Select-Object -ExpandProperty Content
if ( $output -ne "Hello, world!")
{
echo "Did not expect output: $output"
exit 1
}

Stop-Job $job

exit 0
45 changes: 45 additions & 0 deletions .circleci/qa.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Would actually like to error on all errors, but `Enable-ExperimentalFeature`
# does not work for this version of Windows
# https://github.com/PowerShell/PowerShell/issues/3415#issuecomment-1354457563
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

# Prepare directory
mkdir -p /tmp/qa-windows
cd /tmp/qa-windows

# Add cargo to PATH
$env:Path += [IO.Path]::PathSeparator + "$env:USERPROFILE/.cargo/bin"

# Init app
cargo shuttle init --name qa-windows --template axum

# # Start locally
$job = Start-Job -Name "local-run" -ScriptBlock { cd /tmp/qa-windows; cargo shuttle run }
Start-Sleep -Seconds 270

echo "Testing local hello endpoint"
$output=curl http://localhost:8000 | Select-Object -ExpandProperty Content
if ( $output -ne "Hello, world!")
{
echo "Did not expect output: $output"
exit 1
}

Stop-Job $job

cargo shuttle project start

cargo shuttle deploy --allow-dirty

echo "Testing remote hello endpoint"
$output=curl https://qa-windows.unstable.shuttleapp.rs | Select-Object -ExpandProperty Content
if ( $output -ne "Hello, world!")
{
echo "Did not expect output: $output"
exit 1
}

cargo shuttle project stop

exit 0
2 changes: 1 addition & 1 deletion .circleci/qa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mkdir -p /tmp/qa-$1
cd /tmp/qa-$1

# Init app
cargo shuttle init --name qa-$1 --axum
cargo shuttle init --name qa-$1 --template axum

# Start locally
cargo shuttle run &
Expand Down