mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
feat(xtask): consolidate CI workflows onto xtask helpers (#542)
- split the xtask crate into structured modules for - bindings - ci - dev - util - no-std - Adding commands for - ci-release/ci-debug - MUSL/no-std - per- binding language smoke tests - developer tasks (fmt, clippy, pre-commit, pre-push) - refresh Cargo manifests/locks, binding readmes, and shared FFI helpers so every binding reuses the same preparation steps - refactor GitHub Actions (release/debug, extensions, CodeQL, clippy, bindings) to call the new xtask commands - Use rust-cache in ci workflows (microsoft qdk also does this) - extend README with a contributor workflow section describing how xtask mirrors CI expectations - update pre-commit and pre-push hooks to use the xtask dev commands WORKAROUND: When dotnet is run from an xtask, codeql tracer intercepts it an routes to a nonexistent binary. Therefore in codeql workflow, xtask is not used for c# and instead dotnet is directly invoked. Tracked by #545 closes #475 Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
committed by
GitHub
parent
2b1434b3ac
commit
e68e852ee3
95
.github/workflows/test-csharp.yml
vendored
95
.github/workflows/test-csharp.yml
vendored
@@ -11,7 +11,7 @@ on:
|
||||
- cron: "0 8 * * *"
|
||||
|
||||
env:
|
||||
VersionSuffix: ${{ github.run_id }}
|
||||
VersionSuffix: ${{ github.event_name == 'workflow_dispatch' && 'manualtrigger' || null }}
|
||||
|
||||
jobs:
|
||||
build-ffi:
|
||||
@@ -42,22 +42,18 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: ./.github/actions/toolchains/rust
|
||||
|
||||
- name: Fetch crates
|
||||
run: cargo fetch
|
||||
working-directory: ./bindings/ffi
|
||||
- name: Cache cargo
|
||||
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
|
||||
with:
|
||||
shared-key: ${{ runner.os }}-regorus
|
||||
- name: Fetch dependencies
|
||||
run: cargo fetch --locked
|
||||
|
||||
- name: Check Regorus binding formatting
|
||||
run: cargo fmt --check
|
||||
working-directory: ./bindings/ffi
|
||||
- name: Fetch FFI crate dependencies
|
||||
run: cargo fetch --locked --manifest-path bindings/ffi/Cargo.toml --target ${{ matrix.runtime.target }}
|
||||
|
||||
- name: Check Clippy linting for Regorus binding
|
||||
run: cargo clippy --frozen -- -D warnings
|
||||
working-directory: ./bindings/ffi
|
||||
|
||||
- name: Build Regorus binding
|
||||
run: cargo build -r --target ${{ matrix.runtime.target }} --locked
|
||||
working-directory: ./bindings/ffi
|
||||
- name: Build Regorus FFI via xtask
|
||||
run: cargo xtask build-ffi --release --target ${{ matrix.runtime.target }}
|
||||
|
||||
- name: Upload regorus ffi shared library
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
@@ -68,7 +64,7 @@ jobs:
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
build-nuget:
|
||||
build-csharp:
|
||||
name: 'Build Regorus nuget'
|
||||
runs-on: ubuntu-latest
|
||||
needs: build-ffi
|
||||
@@ -77,12 +73,21 @@ jobs:
|
||||
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: ./.github/actions/toolchains/rust
|
||||
- uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # v4.1.0
|
||||
with:
|
||||
global-json-file: ./bindings/csharp/global.json
|
||||
|
||||
- run: echo '${{ steps.stepid.outputs.dotnet-version }}'
|
||||
|
||||
- name: Cache cargo
|
||||
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
|
||||
with:
|
||||
shared-key: ${{ runner.os }}-regorus
|
||||
|
||||
- name: Fetch dependencies
|
||||
run: cargo fetch --locked
|
||||
|
||||
- name: Download regorus ffi shared libraries
|
||||
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
|
||||
with:
|
||||
@@ -93,14 +98,8 @@ jobs:
|
||||
- name: Display regorus ffi artifacts
|
||||
run: ls -R ./bindings/csharp/Regorus/tmp
|
||||
|
||||
# Note that we need to supply the target folder within the folder where artifacts are downloaded.
|
||||
- name: Build Regorus binding
|
||||
run: dotnet build /p:Configuration=Release /p:RegorusFFIArtifactsDir=./tmp/bindings/ffi/target /p:VersionSuffix=${{ env.VersionSuffix }}
|
||||
working-directory: ./bindings/csharp/Regorus
|
||||
|
||||
- name: Pack
|
||||
run: dotnet pack /p:RegorusFFIArtifactsDir=./tmp/bindings/ffi/target /p:VersionSuffix=${{ env.VersionSuffix }}
|
||||
working-directory: ./bindings/csharp/Regorus
|
||||
- name: Build Regorus nuget via xtask
|
||||
run: cargo xtask build-csharp --release --clean --artifacts-dir ./bindings/csharp/Regorus/tmp/bindings/ffi/target --enforce-artifacts
|
||||
|
||||
- name: Upload Regorus nuget
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
@@ -112,7 +111,7 @@ jobs:
|
||||
|
||||
test-nuget:
|
||||
name: 'Test Regorus Nuget: (${{ matrix.runtime.target }})'
|
||||
needs: build-nuget
|
||||
needs: build-csharp
|
||||
runs-on: ${{ matrix.runtime.os }}
|
||||
strategy:
|
||||
# let us get failures from other jobs even if one fails
|
||||
@@ -131,46 +130,32 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: ./.github/actions/toolchains/rust
|
||||
|
||||
- uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # v4.1.0
|
||||
with:
|
||||
global-json-file: ./bindings/csharp/global.json
|
||||
|
||||
- run: echo '${{ steps.stepid.outputs.dotnet-version }}'
|
||||
|
||||
- name: Cache cargo
|
||||
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
|
||||
with:
|
||||
shared-key: ${{ runner.os }}-regorus
|
||||
|
||||
- name: Fetch dependencies
|
||||
run: cargo fetch --locked
|
||||
|
||||
- name: Download regorus nuget
|
||||
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
|
||||
with:
|
||||
name: regorus-nuget
|
||||
path: ./bindings/csharp/regorus-nuget/
|
||||
path: ./bindings/csharp/Regorus/bin/Release
|
||||
|
||||
- name: Restore Regorus.Tests
|
||||
run: dotnet restore /p:UseLocalRegorus=false /p:VersionSuffix=${{ env.VersionSuffix }} /p:RestoreAdditionalProjectSources=../regorus-nuget
|
||||
working-directory: ./bindings/csharp/Regorus.Tests
|
||||
- name: Display regorus nuget
|
||||
run: ls -R ./bindings/csharp/Regorus/bin/Release
|
||||
|
||||
- name: Run Regorus.Tests
|
||||
run: dotnet test --no-restore /p:UseLocalRegorus=false /p:VersionSuffix=${{ env.VersionSuffix }}
|
||||
working-directory: ./bindings/csharp/Regorus.Tests
|
||||
- name: Run C# tests via xtask
|
||||
run: cargo xtask test-csharp --release --clean --nuget-dir bindings/csharp/Regorus/bin/Release
|
||||
|
||||
- name: Restore TestApp
|
||||
run: dotnet restore /p:VersionSuffix=${{ env.VersionSuffix }} /p:RestoreAdditionalProjectSources=../regorus-nuget
|
||||
working-directory: ./bindings/csharp/TestApp
|
||||
|
||||
- name: Build TestApp
|
||||
run: dotnet build --no-restore
|
||||
working-directory: ./bindings/csharp/TestApp
|
||||
|
||||
- name: Run TestApp
|
||||
run: dotnet run --no-build --framework net8.0
|
||||
working-directory: ./bindings/csharp/TestApp
|
||||
|
||||
- name: Restore TargetExampleApp
|
||||
run: dotnet restore /p:VersionSuffix=${{ env.VersionSuffix }} /p:RestoreAdditionalProjectSources=../regorus-nuget
|
||||
working-directory: ./bindings/csharp/TargetExampleApp
|
||||
|
||||
- name: Build TargetExampleApp
|
||||
run: dotnet build --no-restore
|
||||
working-directory: ./bindings/csharp/TargetExampleApp
|
||||
|
||||
- name: Run TargetExampleApp
|
||||
run: dotnet run --no-build --framework net8.0
|
||||
working-directory: ./bindings/csharp/TargetExampleApp
|
||||
|
||||
|
||||
Reference in New Issue
Block a user