[Random, Alignment] Refactor np.random.* to match NumPy parity #111
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release | |
| on: | |
| push: | |
| branches: [ "master", "main" ] | |
| tags: [ "v*" ] | |
| pull_request: | |
| branches: [ "master", "main" ] | |
| workflow_dispatch: | |
| permissions: write-all | |
| env: | |
| # Suppress noisy build warnings that clutter CI annotations. | |
| # Uses %3B (URL-encoded semicolon) because MSBuild CLI treats raw ; and , as property separators. | |
| # XML doc warnings (CS15xx, CS17xx): ~7,200 of ~8,700 total — malformed/missing doc comments | |
| # CS8981: 'np' only contains lowercase chars — intentional for NumPy API compat | |
| # NU5048: PackageIconUrl deprecated — cosmetic NuGet warning | |
| DOTNET_NOWARN: CS1570%3BCS1571%3BCS1572%3BCS1573%3BCS1574%3BCS1587%3BCS1591%3BCS1711%3BCS1734%3BCS8981%3BNU5048 | |
| jobs: | |
| test: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ windows-latest, ubuntu-latest, macos-latest ] | |
| runs-on: ${{ matrix.os }} | |
| # Ubuntu has intermittent OOM issues - allow failure while investigating | |
| continue-on-error: ${{ matrix.os == 'ubuntu-latest' }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: | | |
| 8.0.x | |
| 10.0.x | |
| dotnet-quality: 'preview' | |
| - name: Build | |
| run: dotnet build test/NumSharp.UnitTest/NumSharp.UnitTest.csproj --configuration Release -p:NoWarn=${{ env.DOTNET_NOWARN }} | |
| # NOTE: Test project currently only targets net10.0. See TODO in NumSharp.UnitTest.csproj | |
| # to re-enable net8.0 when TUnit compatibility is resolved. | |
| # | |
| # Test filtering: | |
| # - OpenBugs: excluded (known-failing bug reproductions) | |
| # - HighMemory: excluded (requires 8GB+ RAM, too much for CI runners) | |
| # - WindowsOnly: auto-skipped at runtime via [SkipOnNonWindows] attribute | |
| - name: Test (net10.0) | |
| shell: bash | |
| timeout-minutes: 10 | |
| run: | | |
| echo "Starting test run..." | |
| echo "dotnet version: $(dotnet --version)" | |
| echo "Available memory: $(free -h 2>/dev/null || echo 'N/A')" | |
| # Note: TUnit --treenode-filter doesn't seem to exclude class-level categories. | |
| # The HighMemory filter was attempted but didn't reduce test count. | |
| # Ubuntu failures are allowed via continue-on-error while investigating. | |
| dotnet run --project test/NumSharp.UnitTest/NumSharp.UnitTest.csproj \ | |
| --configuration Release --no-build --framework net10.0 \ | |
| -- --treenode-filter '/*/*/*/*[Category!=OpenBugs]' --report-trx | |
| - name: Upload Test Results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results-${{ matrix.os }} | |
| path: ${{ github.workspace }}/**/TestResults/**/*.trx | |
| retention-days: 5 | |
| build-nuget: | |
| needs: test | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: | | |
| 8.0.x | |
| 10.0.x | |
| dotnet-quality: 'preview' | |
| - name: Get version info | |
| id: version | |
| shell: bash | |
| run: | | |
| VERSION="${GITHUB_REF#refs/tags/v}" | |
| ASSEMBLY_VERSION="${VERSION%%-*}" | |
| COMMIT_SHA="${GITHUB_SHA:0:7}" | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "ASSEMBLY_VERSION=$ASSEMBLY_VERSION" >> $GITHUB_OUTPUT | |
| echo "COMMIT_SHA=$COMMIT_SHA" >> $GITHUB_OUTPUT | |
| echo "Building version $VERSION (assembly: $ASSEMBLY_VERSION) +$COMMIT_SHA" | |
| - name: Build | |
| run: | | |
| dotnet build src/NumSharp.Core/NumSharp.Core.csproj \ | |
| --configuration Release \ | |
| -p:NoWarn=${{ env.DOTNET_NOWARN }} \ | |
| -p:Version=${{ steps.version.outputs.VERSION }} \ | |
| -p:AssemblyVersion=${{ steps.version.outputs.ASSEMBLY_VERSION }} \ | |
| -p:FileVersion=${{ steps.version.outputs.ASSEMBLY_VERSION }} \ | |
| -p:PackageVersion=${{ steps.version.outputs.VERSION }} \ | |
| -p:SourceRevisionId=${{ steps.version.outputs.COMMIT_SHA }} | |
| dotnet build src/NumSharp.Bitmap/NumSharp.Bitmap.csproj \ | |
| --configuration Release \ | |
| -p:NoWarn=${{ env.DOTNET_NOWARN }} \ | |
| -p:Version=${{ steps.version.outputs.VERSION }} \ | |
| -p:AssemblyVersion=${{ steps.version.outputs.ASSEMBLY_VERSION }} \ | |
| -p:FileVersion=${{ steps.version.outputs.ASSEMBLY_VERSION }} \ | |
| -p:PackageVersion=${{ steps.version.outputs.VERSION }} \ | |
| -p:SourceRevisionId=${{ steps.version.outputs.COMMIT_SHA }} | |
| - name: Pack | |
| run: | | |
| mkdir -p artifacts/nuget | |
| dotnet pack src/NumSharp.Core/NumSharp.Core.csproj \ | |
| --configuration Release \ | |
| --no-build \ | |
| --output artifacts/nuget \ | |
| -p:NoWarn=${{ env.DOTNET_NOWARN }} \ | |
| -p:Version=${{ steps.version.outputs.VERSION }} \ | |
| -p:AssemblyVersion=${{ steps.version.outputs.ASSEMBLY_VERSION }} \ | |
| -p:FileVersion=${{ steps.version.outputs.ASSEMBLY_VERSION }} \ | |
| -p:PackageVersion=${{ steps.version.outputs.VERSION }} | |
| dotnet pack src/NumSharp.Bitmap/NumSharp.Bitmap.csproj \ | |
| --configuration Release \ | |
| --no-build \ | |
| --output artifacts/nuget \ | |
| -p:NoWarn=${{ env.DOTNET_NOWARN }} \ | |
| -p:Version=${{ steps.version.outputs.VERSION }} \ | |
| -p:AssemblyVersion=${{ steps.version.outputs.ASSEMBLY_VERSION }} \ | |
| -p:FileVersion=${{ steps.version.outputs.ASSEMBLY_VERSION }} \ | |
| -p:PackageVersion=${{ steps.version.outputs.VERSION }} | |
| echo "Packages built:" | |
| ls -la artifacts/nuget/ | |
| - name: Upload NuGet Packages | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nuget-packages | |
| path: artifacts/nuget/*.nupkg | |
| retention-days: 5 | |
| create-release: | |
| needs: build-nuget | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Extract version | |
| id: version | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
| - name: Download NuGet Packages | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: nuget-packages | |
| path: artifacts | |
| - name: Generate checksums | |
| run: | | |
| cd artifacts | |
| for f in *.nupkg; do | |
| sha256sum "$f" | cut -d' ' -f1 > "${f}.sha256" | |
| echo "${f}: $(cat ${f}.sha256)" | |
| done | |
| - name: Check if prerelease | |
| id: prerelease | |
| run: | | |
| if [[ "${{ steps.version.outputs.VERSION }}" == *"-"* ]]; then | |
| echo "IS_PRERELEASE=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "IS_PRERELEASE=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| artifacts/*.nupkg | |
| artifacts/*.sha256 | |
| draft: false | |
| prerelease: ${{ steps.prerelease.outputs.IS_PRERELEASE }} | |
| generate_release_notes: true | |
| body: | | |
| ## NumSharp v${{ steps.version.outputs.VERSION }} | |
| ### Install via NuGet | |
| ``` | |
| dotnet add package NumSharp --version ${{ steps.version.outputs.VERSION }} | |
| dotnet add package NumSharp.Bitmap --version ${{ steps.version.outputs.VERSION }} | |
| ``` | |
| ### Packages | |
| | Package | NuGet | | |
| |---------|-------| | |
| | NumSharp | [](https://www.nuget.org/packages/NumSharp/${{ steps.version.outputs.VERSION }}) | | |
| | NumSharp.Bitmap | [](https://www.nuget.org/packages/NumSharp.Bitmap/${{ steps.version.outputs.VERSION }}) | | |
| publish-nuget: | |
| needs: build-nuget | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download NuGet Packages | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: nuget-packages | |
| path: artifacts | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Push to NuGet | |
| run: | | |
| for package in artifacts/*.nupkg; do | |
| echo "Pushing $package..." | |
| dotnet nuget push "$package" \ | |
| --api-key ${{ secrets.NUGETAPIKEY }} \ | |
| --source https://api.nuget.org/v3/index.json \ | |
| --skip-duplicate | |
| done |