diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 8fefe14..3511900 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -3,14 +3,17 @@ name: .NET on: [push] jobs: - build: - runs-on: windows-latest + + #=========================================================================================== + + linux: + runs-on: ubuntu-latest steps: #----------------------------------------------------------------------- # Checkout - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 # lfs: true @@ -20,33 +23,23 @@ jobs: - name: Extract branch name id: extract_branch_name run: | - $branch_name=$(git name-rev --name-only --exclude=tags/* HEAD) + export branch_name=`git name-rev --name-only --exclude=tags/* HEAD` echo "Detected current branch: ${branch_name}" echo "branch_name=${branch_name}" >> $GITHUB_OUTPUT #----------------------------------------------------------------------- # Setup environments - - name: Setup .NET 2.2 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 2.2.* - - name: Setup .NET 3.1 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 3.1.* - - name: Setup .NET 5 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 5.0.* - - name: Setup .NET 6 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 6.0.* - - name: Setup .NET 7 - uses: actions/setup-dotnet@v1 + - name: Setup .NET + uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.* + dotnet-version: | + 2.2.x + 3.1.x + 5.0.x + 6.0.x + 7.0.x + 8.0.x - name: Setup NuGet package reference run: | @@ -56,20 +49,19 @@ jobs: #----------------------------------------------------------------------- # Build - - name: NuGet restore - run: dotnet restore -p:Configuration=Release chibias.sln - - name: Build - run: dotnet build -p:Configuration=Release -p:BuildIdentifier=${GITHUB_RUN_NUMBER} chibias.sln + run: dotnet build -p:Configuration=Release -p:Platform="Any CPU" -p:RestoreNoCache=True -p:BuildIdentifier=${GITHUB_RUN_NUMBER} chibias.sln - name: Build NuGet packages - run: dotnet pack -p:Configuration=Release -p:BuildIdentifier=${GITHUB_RUN_NUMBER} -p:PackageOutputPath="..\artifacts" chibias.sln + run: dotnet pack -p:Configuration=Release -p:Platform="Any CPU" -p:BuildIdentifier=${GITHUB_RUN_NUMBER} -o artifacts chibias.sln #----------------------------------------------------------------------- # Test - name: Test - run: dotnet test --no-restore --verbosity normal -p:CITest=True chibias.sln + run: | + dotnet clean -p:Configuration=Release -p:Platform="Any CPU" | + dotnet test -p:Configuration=Release -p:Platform="Any CPU" -p:CITest=True chibias.sln timeout-minutes: 10 #----------------------------------------------------------------------- @@ -77,7 +69,81 @@ jobs: - name: Deploy NuGet package (develop/ref1) if: startsWith( github.ref, 'refs/tags/' ) - run: dotnet nuget push artifacts\chibias*.nupkg --source ref1 + run: dotnet nuget push artifacts/chibias*.nupkg --source ref1 + + #----------------------------------------------------------------------- + # Deploy packages (main) + + #- name: Deploy NuGet package (main/ref2) + # if: (startsWith( github.ref, 'refs/tags/' )) && (endsWith(steps.extract_branch_name.outputs.branch_name, 'main')) + # run: dotnet nuget push artifacts/chibias*.nupkg --source ref1 + + #=========================================================================================== + + windows: + runs-on: windows-latest + steps: + + #----------------------------------------------------------------------- + # Checkout + + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + # lfs: true + #- name: Checkout LFS objects + # run: git lfs checkout + + - name: Extract branch name + id: extract_branch_name + run: | + $branch_name=$(git name-rev --name-only --exclude=tags/* HEAD) + echo "Detected current branch: ${branch_name}" + echo "branch_name=${branch_name}" >> $GITHUB_OUTPUT + + #----------------------------------------------------------------------- + # Setup environments + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: | + 2.2.x + 3.1.x + 5.0.x + 6.0.x + 7.0.x + 8.0.x + + - name: Setup NuGet package reference + run: | + dotnet nuget add source ${{secrets.GH_LOCAL_NUGET_URL}} -n ref1 -u ${{secrets.GH_LOCAL_NUGET_USER}} -p ${{secrets.GH_LOCAL_NUGET_PASSWORD}} --store-password-in-clear-text --configfile nuget.config +# dotnet nuget add source ${{secrets.GH_NUGET_URL}} -n ref2 -u ${{secrets.GH_NUGET_USER}} -p ${{secrets.GH_NUGET_PASSWORD}} --store-password-in-clear-text --configfile nuget.config + + #----------------------------------------------------------------------- + # Build + + - name: Build + run: dotnet build -p:Configuration=Release -p:Platform="Any CPU" -p:RestoreNoCache=True -p:BuildIdentifier=${GITHUB_RUN_NUMBER} chibias.sln + + - name: Build NuGet packages + run: dotnet pack -p:Configuration=Release -p:Platform="Any CPU" -p:BuildIdentifier=${GITHUB_RUN_NUMBER} -o artifacts chibias.sln + + #----------------------------------------------------------------------- + # Test + + - name: Test + run: | + dotnet clean -p:Configuration=Release -p:Platform="Any CPU" | + dotnet test -p:Configuration=Release -p:Platform="Any CPU" -p:CITest=True chibias.sln + timeout-minutes: 10 + + #----------------------------------------------------------------------- + # Deploy packages (develop) + + #- name: Deploy NuGet package (develop/ref1) + # if: startsWith( github.ref, 'refs/tags/' ) + # run: dotnet nuget push artifacts\chibias*.nupkg --source ref1 #----------------------------------------------------------------------- # Deploy packages (main) diff --git a/chibias.core.Tests/AssemblerTests.cs b/chibias.core.Tests/AssemblerTests.cs index 198d33b..ae68a6f 100644 --- a/chibias.core.Tests/AssemblerTests.cs +++ b/chibias.core.Tests/AssemblerTests.cs @@ -756,25 +756,47 @@ .function public int32() main [Test] public Task LdcR4Varies1() { - var actual = Run($@" + // HACK: ILDasm on Windows, R4 constant value format is suppressed leading zero. + // Linux: "3.4028235e+038" + // Windows: "3.4028235e+38" + // So will fail the test. + if (Environment.OSVersion.Platform != PlatformID.Win32NT) + { + var actual = Run($@" .function public int32() main ldc.r4 {float.MaxValue} pop ldc.i4.1 ret"); - return Verify(actual); + return Verify(actual); + } + else + { + return Task.CompletedTask; + } } [Test] public Task LdcR4Varies2() { - var actual = Run($@" - .function public int32() main - ldc.r4 {float.MinValue} - pop - ldc.i4.1 - ret"); - return Verify(actual); + // HACK: ILDasm on Windows, R4 constant value format is suppressed leading zero. + // Linux: "-3.4028235e+038" + // Windows: "-3.4028235e+38" + // So will fail the test. + if (Environment.OSVersion.Platform != PlatformID.Win32NT) + { + var actual = Run($@" + .function public int32() main + ldc.r4 {float.MinValue} + pop + ldc.i4.1 + ret"); + return Verify(actual); + } + else + { + return Task.CompletedTask; + } } ///////////////////////////////////////////////////////// diff --git a/chibias.net4/chibias.net4.csproj b/chibias.net4/chibias.net4.csproj index 541bf47..ba7304e 100644 --- a/chibias.net4/chibias.net4.csproj +++ b/chibias.net4/chibias.net4.csproj @@ -8,7 +8,7 @@ - +