Skip to content

Remove IDE1005 suppression #19

Remove IDE1005 suppression

Remove IDE1005 suppression #19

Workflow file for this run

name: Mochi.PhysX
on:
push:
# This prevents tag pushes from triggering this workflow
branches: ['*']
pull_request:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: "Version"
default: ""
will_publish_packages:
description: "Publish packages?"
default: "false"
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
ContinuousIntegrationBuild: true
# This URL will be added to the restore sources if it isn't the official NuGet.org
# (This is mainly intended to allow using the NuGet.org test servers to test CI in forks.)
CiNuGetApiUrl: ${{secrets.NUGET_API_URL}}
jobs:
# =====================================================================================================================================================================
# Build PhysX
# =====================================================================================================================================================================
build-physx:
strategy:
fail-fast: false
matrix:
rid: [win-x64]
configuration:
- name: Debug
id: debug
- name: Checked
id: checked
- name: Profile
id: profile
- name: Release
id: release
include:
- rid: win-x64
name: Windows x64
os: windows-2019
build-command: ./build.cmd
physx-install-path: external/PhysX/physx/install/Mochi.PhysX.Windows.x64
physx-compiler-path: external/PhysX/physx/compiler/mochi-physx-win-x64
name: PhysX ${{matrix.name}} ${{matrix.configuration.name}}
runs-on: ${{matrix.os}}
steps:
# ----------------------------------------------------------------------- Checkout
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
# ----------------------------------------------------------------------- Setup Python
- name: Setup Python 3.8
if: matrix.platform.skip-tool-install != true
uses: actions/setup-python@v2
with:
python-version: '3.8'
# ----------------------------------------------------------------------- Get PhysX revision
- name: Get PhysX revision
id: physx
run: python .github/workflows/get-physx-revision.py
# ----------------------------------------------------------------------- Build PhysX
- name: Load cached PhysX build outputs
id: cached-physx
uses: actions/cache@v2
with:
key: physx-${{matrix.rid}}-${{matrix.configuration.id}}-${{steps.physx.outputs.revision}}-${{hashFiles('build.*', 'tooling/*.cmd', 'tooling/*.sh', 'Mochi.PhysX.Modifications/**')}}
path: physx-${{matrix.rid}}-${{matrix.configuration.id}}.tar.gz
- name: Build PhysX
if: steps.cached-physx.outputs.cache-hit != 'true'
run: ${{matrix.build-command}} ${{matrix.configuration.id}}
# ----------------------------------------------------------------------- Upload artifacts
- name: Collect PhysX binaries
if: steps.cached-physx.outputs.cache-hit != 'true'
run: tar -cvf physx-${{matrix.rid}}-${{matrix.configuration.id}}.tar ${{matrix.physx-install-path}}/bin
# Due to the way PhysX builds and links its internal dependencies, the PDBs it emits don't include some internal object files
# However, the linker will be able to automagically find the debug info for these objects from these PDBs so we include them in our archive
# (Not including these causes LNK4099 to be spammed for all of these objects when Mochi.PhysX.Native is built and presumably causes these objects to be missing debug info.)
- name: Collect extra PhysX PDBs
if: steps.cached-physx.outputs.cache-hit != 'true' && runner.os == 'Windows'
run: tar -rvf physx-${{matrix.rid}}-${{matrix.configuration.id}}.tar ${{matrix.physx-compiler-path}}/sdk_source_bin/${{matrix.configuration.id}}/*.pdb
# We only use the headers from the release build (they should match between all of them)
# (These are the headers we actually use to generate the bindings.)
# This also includes the PhysX license file to let subsequent jobs avoid cloning PhysX for it
- name: Collect PhysX headers
if: steps.cached-physx.outputs.cache-hit != 'true' && matrix.configuration.id == 'release'
run: |
tar -rvf physx-${{matrix.rid}}-${{matrix.configuration.id}}.tar ${{matrix.physx-install-path}}/include
tar -rvf physx-${{matrix.rid}}-${{matrix.configuration.id}}.tar ${{matrix.physx-install-path}}/source
tar -rvf physx-${{matrix.rid}}-${{matrix.configuration.id}}.tar external/PhysX/LICENSE.md
- name: Compress PhysX build artifacts
if: steps.cached-physx.outputs.cache-hit != 'true'
run: gzip physx-${{matrix.rid}}-${{matrix.configuration.id}}.tar
- name: Upload PhysX build artifacts
uses: actions/upload-artifact@v2
with:
name: physx-${{matrix.rid}}
path: physx-${{matrix.rid}}-${{matrix.configuration.id}}.tar.gz
if-no-files-found: error
# =====================================================================================================================================================================
# Build Mochi.PhysX
# =====================================================================================================================================================================
build-mochi-physx:
needs: build-physx
strategy:
fail-fast: false
matrix:
include:
- name: Windows x64
os: windows-2019
rid: win-x64
build-command: ./build.cmd
name: Mochi.PhysX ${{matrix.name}}
runs-on: ${{matrix.os}}
steps:
# ----------------------------------------------------------------------- Checkout
- name: Checkout
# We intentionally don't checkout submodules here, Mochi.PhysX.Generator should only use outputs from building PhysX
uses: actions/checkout@v2
#TODO: Actually we need them for Biohazrd still. Remove this once we switch to NuGet packages for it.
with:
submodules: recursive
# ----------------------------------------------------------------------- Setup .NET
- name: Setup .NET
if: matrix.platform.skip-tool-install != true
uses: actions/setup-dotnet@v1
with:
# We need both the .NET 5 and .NET 6 SDKs because we currently use C# 10 while targeting .NET 5
dotnet-version: |
5.0.x
6.0.x
# ----------------------------------------------------------------------- Download PhysX builds
- name: Download PhysX ${{matrix.name}} builds
uses: actions/download-artifact@v2
with:
name: physx-${{matrix.rid}}
- name: Extract PhysX Builds
run: |
tar --keep-old-files -xvf physx-${{matrix.rid}}-debug.tar.gz
tar --keep-old-files -xvf physx-${{matrix.rid}}-checked.tar.gz
tar --keep-old-files -xvf physx-${{matrix.rid}}-profile.tar.gz
tar --keep-old-files -xvf physx-${{matrix.rid}}-release.tar.gz
# ----------------------------------------------------------------------- Configure build
- name: Configure build
run: python .github/workflows/configure-build.py
env:
github_event_name: ${{github.event_name}}
github_ref: ${{github.ref}}
github_run_number: ${{github.run_number}}
release_version: ${{github.event.release.tag_name}}
workflow_dispatch_version: ${{github.event.inputs.version}}
workflow_dispatch_will_publish_packages: ${{github.event.inputs.will_publish_packages}}
# ----------------------------------------------------------------------- Generate Mochi.PhysX
- name: Restore Mochi.PhysX.Generator
run: dotnet restore Mochi.PhysX.Generator
- name: Build Mochi.PhysX.Generator
run: dotnet build Mochi.PhysX.Generator --configuration Release
- name: Generate Mochi.PhysX
run: ${{matrix.build-command}} generate
# ----------------------------------------------------------------------- Build Mochi.PhysX
- name: Restore Mochi.PhysX.${{matrix.rid}}
# This is a workaround for the fact that the NuGet package name of Mochi.PhysX.Native changes depending on the configuration.
# Ideally we'd just manually specify the dependency but NuGet makes that really annoying to do. See https://github.com/NuGet/Home/issues/8133
env:
Configuration: Release
run: dotnet restore Mochi.PhysX --runtime ${{matrix.rid}}
- name: Build Mochi.PhysX.${{matrix.rid}}
run: dotnet build Mochi.PhysX --no-restore --configuration Release /p:RuntimeIdentifier=${{matrix.rid}}
# ----------------------------------------------------------------------- Pack Mochi.PhysX
- name: Pack Mochi.PhysX.${{matrix.rid}}
run: dotnet pack Mochi.PhysX --no-build --configuration Release /p:RuntimeIdentifier=${{matrix.rid}}
# ----------------------------------------------------------------------- Pack Mochi.PhysX.Native variants
- name: Restore Mochi.PhysX.Native
run: dotnet restore Mochi.PhysX.Native --runtime ${{matrix.rid}}
- name: Pack Mochi.PhysX.Native.${{matrix.rid}}-debug
run: dotnet pack Mochi.PhysX.Native --no-build --configuration Release /p:RuntimeIdentifier=${{matrix.rid}} /p:MochiPhysXNativeBuildVariant=debug
- name: Pack Mochi.PhysX.Native.${{matrix.rid}}-checked
run: dotnet pack Mochi.PhysX.Native --no-build --configuration Release /p:RuntimeIdentifier=${{matrix.rid}} /p:MochiPhysXNativeBuildVariant=checked
- name: Pack Mochi.PhysX.Native.${{matrix.rid}}-profile
run: dotnet pack Mochi.PhysX.Native --no-build --configuration Release /p:RuntimeIdentifier=${{matrix.rid}} /p:MochiPhysXNativeBuildVariant=profile
- name: Pack Mochi.PhysX.Native.${{matrix.rid}}
run: dotnet pack Mochi.PhysX.Native --no-build --configuration Release /p:RuntimeIdentifier=${{matrix.rid}} /p:MochiPhysXNativeBuildVariant=release
# ----------------------------------------------------------------------- Pack Mochi.PhysX.Ref
# (This package is currently just a dummy package which references Mochi.PhysX.win-x64. Eventually it will be a least common denominator reference-only package.)
- name: Restore Mochi.PhysX.Ref
if: matrix.rid == 'win-x64'
run: dotnet restore Mochi.PhysX.Ref --runtime ${{matrix.rid}}
- name: Pack Mochi.PhysX.Ref
if: matrix.rid == 'win-x64'
run: dotnet pack Mochi.PhysX.Ref --no-build --configuration Release /p:RuntimeIdentifier=${{matrix.rid}}
# ----------------------------------------------------------------------- Run the sample as a smoke test
# We do this last so it can't indirectly affect the build process of any packages
- name: Test Mochi.PhysX.Sample (Debug)
run: dotnet run --project Mochi.PhysX.Sample --configuration Debug
- name: Test Mochi.PhysX.Sample (Release)
run: dotnet run --project Mochi.PhysX.Sample --configuration Release
# ----------------------------------------------------------------------- Upload artifacts
# All of these steps ignore failure so that we get what artifacts are available when things are broken
- name: Collect native binaries
if: always()
run: tar -cvzf Mochi.PhysX.Native-${{matrix.rid}}.tar.gz bin/Mochi.PhysX.Native
- name: Upload native binaries
if: always()
uses: actions/upload-artifact@v2
with:
name: Mochi.PhysX.Native-${{matrix.rid}}
path: Mochi.PhysX.Native-${{matrix.rid}}.tar.gz
if-no-files-found: error
- name: Collect NuGet packages
if: always()
run: tar -cvzf Mochi.PhysX-packages-${{matrix.rid}}.tar.gz packages
- name: Upload NuGet packages
if: always()
uses: actions/upload-artifact@v2
with:
name: Packages
if-no-files-found: error
path: Mochi.PhysX-packages-${{matrix.rid}}.tar.gz
- name: Collect generated output
if: always()
#TODO: We should use the Biohazrd file writes log for this
run: tar -cvzf Mochi.PhysX-${{matrix.rid}}-generated.tar.gz Mochi.PhysX/#Generated Mochi.PhysX.Native/*.gen.*
- name: Upload generated output
if: always()
uses: actions/upload-artifact@v2
with:
name: Mochi.PhysX-${{matrix.rid}}-generated
path: Mochi.PhysX-${{matrix.rid}}-generated.tar.gz
if-no-files-found: error
# =====================================================================================================================================================================
# Publish NuGet Packages to GitHub
# =====================================================================================================================================================================
publish-packages-github:
name: Publish to GitHub
runs-on: ubuntu-latest
needs: build-mochi-physx
# Pushes always publish CI packages (configure-build.py will add the branch name to the version string for branches besides main)
# Published releases always publish packages
# A manual workflow only publishes packages if explicitly enabled
if: github.event_name == 'push' || github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.will_publish_packages == 'true')
steps:
# ----------------------------------------------------------------------- Setup .NET
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
# ----------------------------------------------------------------------- Download built packages
- name: Download built packages
uses: actions/download-artifact@v2
with:
name: Packages
- name: Extract built packages
run: for archive in Mochi.PhysX-packages-*.tar.gz; do tar --keep-old-files -xvf "$archive"; done
# ----------------------------------------------------------------------- Push to GitHub Packages
- name: Push to GitHub Packages
run: dotnet nuget push "packages/*.nupkg" --skip-duplicate --no-symbols --api-key ${{secrets.GITHUB_TOKEN}} --source https://nuget.pkg.github.com/${{github.repository_owner}}
env:
# This is a workaround for https://github.com/NuGet/Home/issues/9775
DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER: 0
# =====================================================================================================================================================================
# Publish NuGet Packages to NuGet.org
# =====================================================================================================================================================================
publish-packages-nuget-org:
name: Publish to NuGet.org
runs-on: ubuntu-latest
needs: build-mochi-physx
environment: NuGet.org
# Release builds always publish packages to NuGet.org
# Workflow dispatch builds will only publish packages if enabled and an explicit version number is given
# Make sure this logic matches configure-build.py to ensure we don't accidentally depend on sibling CI pre-release packages
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.will_publish_packages == 'true' && github.event.inputs.version != '')
steps:
# ----------------------------------------------------------------------- Setup .NET
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
# ----------------------------------------------------------------------- Download built packages
- name: Download built packages
uses: actions/download-artifact@v2
with:
name: Packages
- name: Extract built packages
run: for archive in Mochi.PhysX-packages-*.tar.gz; do tar --keep-old-files -xvf "$archive"; done
# ----------------------------------------------------------------------- Push to NuGet.org
- name: Push to NuGet.org
run: dotnet nuget push "packages/*.nupkg" --api-key ${{secrets.NUGET_API_KEY}} --source ${{secrets.NUGET_API_URL}}
env:
# This is a workaround for https://github.com/NuGet/Home/issues/9775
DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER: 0
# =====================================================================================================================================================================
# Publish Release Assets
# =====================================================================================================================================================================
publish-release-assets:
name: Publish Release Assets
runs-on: ubuntu-latest
needs: build-mochi-physx
if: github.event_name == 'release'
steps:
# ----------------------------------------------------------------------- Download all artifacts
- name: Download artifacts
uses: actions/download-artifact@v2
# ----------------------------------------------------------------------- Upload release assets
- name: Upload release assets
uses: actions/github-script@v4
with:
user-agent: actions/github-script for ${{github.repository}}
script: |
const fs = require('fs').promises;
const path = require('path');
const uploadUrl = context.payload.release.upload_url;
if (!uploadUrl) {
throw "Missing release asset upload URL!";
}
async function uploadAssets(directoryPath) {
for (let filePath of await fs.readdir(directoryPath)) {
filePath = path.join(directoryPath, filePath);
const stats = await fs.stat(filePath);
if (stats.isDirectory()) {
console.log(`Entering '${filePath}'`);
await uploadAssets(filePath);
continue;
}
console.log(`Uploading '${filePath}'`);
await github.repos.uploadReleaseAsset({
url: uploadUrl,
headers: {
'content-type': 'application/octet-stream',
'content-length': stats.size
},
name: path.basename(filePath),
data: await fs.readFile(filePath)
});
}
}
await uploadAssets('.');
# =====================================================================================================================================================================
# Send CI Failure Notification
# =====================================================================================================================================================================
send-ci-failure-notification:
name: Send CI Failure Notification
needs: [build-physx, build-mochi-physx, publish-packages-github, publish-packages-nuget-org, publish-release-assets]
if: failure() && github.event_name != 'pull_request'
continue-on-error: true
runs-on: ubuntu-latest
steps:
# ----------------------------------------------------------------------- Checkout
- name: Checkout
uses: actions/checkout@v2
# ----------------------------------------------------------------------- Setup Python
- name: Setup Python 3.8
uses: actions/setup-python@v2
with:
python-version: '3.8'
# ----------------------------------------------------------------------- Send CI Failure Notification
- name: Send Notification
run: python .github/workflows/send-ci-failure-notification.py
env:
webhook_url: ${{secrets.TEAMS_WEBHOOK_URL}}
github_organization: ${{github.repository_owner}}
github_repo: ${{github.repository}}
github_workflow_name: ${{github.workflow}}
github_run_number: ${{github.run_id}}