Test wasm32-unknown-unknown in Azure Pipelines (#1903)

* Test wasm32-unknown-unknown in Azure Pipelines

Also gets rid of most of GitHub Actions with only E2E tests remaining.

* Remove GitHub Actions and disable non-functioning e2e testing

* Do not check all features, targets for wasm32

* Resolve PR feedback
This commit is contained in:
Heath Stewart 2024-11-08 14:41:21 -08:00 коммит произвёл GitHub
Родитель 54db2ca594
Коммит d7137b088f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
11 изменённых файлов: 17 добавлений и 257 удалений

143
.github/workflows/build.yml поставляемый
Просмотреть файл

@ -1,143 +0,0 @@
name: Build and Test
on:
pull_request:
push:
schedule:
- cron: "0 0 * * 0"
env:
RUSTFLAGS: -Dwarnings
CARGO_INCREMENTAL: 0
jobs:
msrv:
name: Get minimum supported rust version
runs-on: ubuntu-20.04
outputs:
msrv: ${{ steps.get_msrv.outputs.msrv }}
steps:
- uses: actions/checkout@v4
- id: get_msrv
run: |
MSRV=$(cargo metadata --format-version=1 --no-deps | jq '.packages[] | select(.name == "azure_core").rust_version' -r)
echo setting msrv to ${MSRV}
echo msrv=${MSRV} >> "$GITHUB_OUTPUT"
code-style:
name: Code Style
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
# for code style, we only care about `stable`
- run: eng/scripts/code_style.sh stable
test-sdk:
name: SDK Tests
runs-on: ubuntu-20.04
needs:
- msrv
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
build:
- stable
- ${{ needs.msrv.outputs.msrv }}
experimental:
- false
include:
- build: nightly
experimental: true
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- run: eng/scripts/sdk_tests.sh ${{ matrix.build }}
test-docs-sdk:
name: SDK docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- uses: dtolnay/install@cargo-docs-rs
- run: eng/scripts/verify-docs.sh sdk
test-wasm:
name: WASM Tests
runs-on: ubuntu-20.04
needs:
- msrv
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
build:
- stable
- ${{ needs.msrv.outputs.msrv }}
experimental:
- false
include:
- build: nightly
experimental: true
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- run: eng/scripts/check_wasm.sh ${{ matrix.build }}
# test-integration:
# name: Emulator Tests
# runs-on: ubuntu-20.04
# needs:
# - msrv
# continue-on-error: ${{ matrix.experimental }}
# strategy:
# matrix:
# build:
# - stable
# - ${{ needs.msrv.outputs.msrv }}
# experimental:
# - false
# include:
# - build: nightly
# experimental: true
# steps:
# - uses: actions/checkout@v4
# - uses: Swatinem/rust-cache@v2
# - run: eng/scripts/emulator_tests.sh ${{ matrix.build }}
# - name: display free disk space
# run: df -h /
# if: ${{ always() }}
test-e2e:
name: E2E Tests
runs-on: ubuntu-20.04
needs:
- msrv
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
build:
- stable
- ${{ needs.msrv.outputs.msrv }}
experimental:
- false
include:
- build: nightly
experimental: true
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- run: eng/scripts/e2e_tests.sh ${{ matrix.build }}
- name: display free disk space
run: df -h /
if: ${{ always() }}
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- name: Verify dependencies
run: |
find sdk/ -maxdepth 3 -type f -name Cargo.toml -exec bash -c 'eng/scripts/verify-dependencies.rs {}' \;

12
eng/scripts/Analyze-Code.ps1 Normal file → Executable file
Просмотреть файл

@ -1,8 +1,10 @@
#Requires -Version 7.0
#!/usr/bin/env pwsh
#Requires -Version 7.0
param(
[string]$Toolchain = 'stable',
[string]$PackageInfoPath,
[switch]$CheckWasm = $true,
[switch]$SkipPackageAnalysis
)
@ -18,12 +20,20 @@ Write-Host "Analyzing code with
$env:RUSTDOCFLAGS = "-D warnings"
$env:RUSTFLAGS = "-Dwarnings"
if ($CheckWasm) {
Invoke-LoggedCommand "rustup target add --toolchain $Toolchain wasm32-unknown-unknown"
}
Invoke-LoggedCommand "cargo +$Toolchain check -p azure_core --all-features --all-targets --keep-going"
Invoke-LoggedCommand "cargo +$Toolchain fmt --all -- --check"
Invoke-LoggedCommand "cargo +$Toolchain clippy --workspace --all-features --all-targets --keep-going --no-deps"
if ($CheckWasm) {
Invoke-LoggedCommand "cargo +$Toolchain clippy --target=wasm32-unknown-unknown --workspace --keep-going --no-deps"
}
Invoke-LoggedCommand "cargo +$Toolchain doc --workspace --no-deps"
# Verify package dependencies

11
eng/scripts/Test-Packages.ps1 Normal file → Executable file
Просмотреть файл

@ -1,5 +1,6 @@
#Requires -Version 7.0
#!/usr/bin/env pwsh
#Requires -Version 7.0
param(
[string]$Toolchain = 'stable',
[bool]$UnitTests = $true,
@ -30,12 +31,12 @@ if ($PackageInfoPath) {
| ConvertFrom-Json
}
else {
$packagesToTest = Get-AllPackagesInRepo
$packagesToTest = Get-AllPackageInfoFromRepo
}
Write-Host "Testing packages:"
foreach ($package in $packagesToTest) {
Write-Host " '$($package.Name)'"
Write-Host " '$($package.Name)' in '$($package.DirectoryPath)'"
}
Write-Host "Setting RUSTFLAGS to '-Dwarnings'"
@ -43,9 +44,9 @@ $env:RUSTFLAGS = "-Dwarnings"
foreach ($package in $packagesToTest) {
Push-Location (Join-Path $RepoRoot $package.DirectoryPath)
Push-Location ([System.IO.Path]::Combine($RepoRoot, $package.DirectoryPath))
try {
Write-Host "`n`nTesting package: '$($package.Name)' in directory: '$($package.DirectoryPath)'`n"
Write-Host "`n`nTesting package: '$($package.Name)'`n"
Invoke-LoggedCommand "cargo +$Toolchain build --keep-going"
Write-Host "`n`n"

Просмотреть файл

@ -1,10 +0,0 @@
#!/usr/bin/env bash
set -eux -o pipefail
cd $(dirname ${BASH_SOURCE[0]})/../../
BUILD=${1:-stable}
./eng/scripts/code_style.sh ${BUILD}
./eng/scripts/sdk_tests.sh ${BUILD}
./eng/scripts/e2e_tests.sh ${BUILD}

Просмотреть файл

@ -1,14 +0,0 @@
#!/usr/bin/env bash
set -eux -o pipefail
cd $(dirname ${BASH_SOURCE[0]})/../../
./eng/scripts/github-disk-cleanup.sh
BUILD=${1:-stable}
rustup update --no-self-update ${BUILD}
rustup target add --toolchain ${BUILD} wasm32-unknown-unknown
export RUSTFLAGS="-Dwarnings"
cargo +${BUILD} check --target=wasm32-unknown-unknown

Просмотреть файл

@ -1,17 +0,0 @@
#!/usr/bin/env bash
set -eux -o pipefail
cd $(dirname ${BASH_SOURCE[0]})/../../
./eng/scripts/github-disk-cleanup.sh
BUILD=${1:-stable}
rustup update --no-self-update ${BUILD}
export RUSTFLAGS="-Dwarnings"
export PROJECTS="core/azure_core identity/azure_identity eventhubs/azure_messaging_eventhubs"
for PROJ in ${PROJECTS}; do
cargo check --tests --features test_e2e --manifest-path sdk/$PROJ/Cargo.toml
done

Просмотреть файл

@ -1,50 +0,0 @@
#!/usr/bin/env bash
set -eux -o pipefail
BUILD=${1:-stable}
cd $(dirname ${BASH_SOURCE[0]})/../../
./eng/scripts/github-disk-cleanup.sh
# get the nested list of sub-processes for a given set of pids
function subprocesses {
for P in $@; do
echo ${P}
for C in $(pgrep -P ${P}); do
subprocesses ${C}
done
done
}
# stop all of the subprocesses for a given set of pids
function stop_subprocesses {
# sort pids numerically, and in reverse
PIDS=$(subprocesses $$ | sort -nr)
for P in ${PIDS}; do
if [ ${P} == $$ ]; then
continue
fi
kill -9 ${P} || echo "stopping ${P} failed"
done
}
# at termination, we want to cleanup the temp directory and stop all
# subprocesses (azurite)
TMP=$(mktemp -d)
function cleanup {
stop_subprocesses || true
rm -rf ${TMP} || true
}
trap cleanup EXIT
BASE_DIR=$(pwd)
cd ${TMP}
npm install azurite@3.28.0
npx azurite &
# wait for azurite to start
sleep 5
cd ${BASE_DIR}
rustup update --no-self-update ${BUILD}
cargo +${BUILD} test --features test_integration

Просмотреть файл

@ -1,14 +0,0 @@
#!/usr/bin/env bash
set -eux -o pipefail
cd $(dirname ${BASH_SOURCE[0]})/../../
./eng/scripts/github-disk-cleanup.sh
BUILD=${1:-stable}
rustup update --no-self-update ${BUILD}
export RUSTFLAGS="-Dwarnings"
cargo +${BUILD} check -p azure_core --no-default-features
cargo +${BUILD} test --all --features hmac_rust

Просмотреть файл

@ -47,7 +47,6 @@ reqwest_gzip = ["typespec_client_core/reqwest_gzip"]
reqwest_rustls = ["typespec_client_core/reqwest_rustls"]
hmac_rust = ["dep:sha2", "dep:hmac"]
hmac_openssl = ["dep:openssl"]
test_e2e = []
azurite_workaround = []
xml = ["typespec_client_core/xml"]
tokio_fs = ["typespec_client_core/tokio_fs"]

Просмотреть файл

@ -46,7 +46,6 @@ fe2o3-amqp = [
"serde_bytes",
]
cplusplus = []
test_e2e = []
[package.metadata.docs.rs]
features = ["fe2o3-amqp"]

Просмотреть файл

@ -44,7 +44,6 @@ clap.workspace = true
default = ["reqwest", "old_azure_cli"]
reqwest = ["azure_core/reqwest"]
reqwest_rustls = ["azure_core/reqwest_rustls"]
test_e2e = []
client_certificate = ["openssl"]
# If you are using and Azure CLI version older than 2.54.0 from November 2023,