diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index a787383114..1116b75ae4 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -14,12 +14,6 @@ "regitlint" ] }, - "codecov.tool": { - "version": "1.13.0", - "commands": [ - "codecov" - ] - }, "dotnet-reportgenerator-globaltool": { "version": "5.1.20", "commands": [ diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..84fabcc68a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,270 @@ +# General links +# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables +# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context +# https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads +# https://docs.github.com/en/actions/learn-github-actions/expressions +# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net + +name: Build + +on: + push: + branches: [ 'master', 'release/**' ] + pull_request: + branches: [ 'master', 'release/**' ] + tags: + - 'v*' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + # The Windows runner image has PostgreSQL pre-installed and sets the PGPASSWORD environment variable to "root". + # This conflicts with the default password "postgres", which is used by ikalnytskyi/action-setup-postgres. + # Because action-setup-postgres forgets to update the environment variable accordingly, we do so here. + PGPASSWORD: "postgres" + +jobs: + build-and-test: + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Setup PostgreSQL + uses: ikalnytskyi/action-setup-postgres@v4 + with: + username: postgres + password: postgres + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x + - name: Setup PowerShell (Ubuntu) + if: matrix.os == 'ubuntu-latest' + run: | + dotnet tool install --global PowerShell + - name: Setup PowerShell (Windows) + if: matrix.os == 'windows-latest' + shell: cmd + run: | + curl --location --output "%RUNNER_TEMP%\PowerShell-7.3.6-win-x64.msi" https://github.com/PowerShell/PowerShell/releases/download/v7.3.6/PowerShell-7.3.6-win-x64.msi + msiexec.exe /package "%RUNNER_TEMP%\PowerShell-7.3.6-win-x64.msi" /quiet USE_MU=1 ENABLE_MU=1 ADD_PATH=1 DISABLE_TELEMETRY=1 + - name: Setup PowerShell (macOS) + if: matrix.os == 'macos-latest' + run: | + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + brew install --cask powershell + - name: Show installed versions + shell: pwsh + run: | + Write-Host "$(pwsh --version) is installed at $PSHOME" + psql --version + Write-Host "Active .NET SDK: $(dotnet --version)" + - name: Git checkout + uses: actions/checkout@v3 + - name: Restore tools + run: | + dotnet tool restore + - name: Restore packages + run: | + dotnet restore + - name: Calculate version suffix + shell: pwsh + run: | + if ($env:GITHUB_REF_TYPE -eq 'tag') { + # Get the version prefix/suffix from the git tag. For example: 'v1.0.0-preview1-final' => '1.0.0' and 'preview1-final' + $segments = $env:GITHUB_REF_NAME -split "-" + $versionPrefix = $segments[0].TrimStart('v') + $versionSuffix = $segments[1..-1] -join "-" + + [xml]$xml = Get-Content Directory.Build.props + $configuredVersionPrefix = $xml.Project.PropertyGroup[0].JsonApiDotNetCoreVersionPrefix + if ($configuredVersionPrefix -ne $versionPrefix) { + Write-Error "Version prefix from git release tag '$versionPrefix' does not match version prefix '$configuredVersionPrefix' stored in Directory.Build.props." + # To recover from this: + # - Delete the GitHub release + # - Run: git push --delete the-invalid-tag-name + # - Adjust JsonApiDotNetCoreVersionPrefix in Directory.Build.props, commit and push + # - Recreate the GitHub release + } + } + else { + # Get the version suffix from the auto-incrementing build number. For example: '123' => 'master-00123' + $revision = "{0:D5}" -f [convert]::ToInt32($env:GITHUB_RUN_NUMBER, 10) + $versionSuffix = "$($env:GITHUB_HEAD_REF ?? $env:GITHUB_REF_NAME)-$revision" + } + Write-Output "Using version suffix: $versionSuffix" + Write-Output "PACKAGE_VERSION_SUFFIX=$versionSuffix" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + - name: Build + shell: pwsh + run: | + dotnet build --no-restore --configuration Release --version-suffix=$env:PACKAGE_VERSION_SUFFIX + - name: Test + run: | + dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --logger "GitHubActions;summary.includeSkippedTests=true" -- RunConfiguration.CollectSourceInformation=true DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.DeterministicReport=true + - name: Upload coverage to codecov.io + if: matrix.os == 'ubuntu-latest' + uses: codecov/codecov-action@v3 + - name: Generate packages + shell: pwsh + run: | + dotnet pack --no-build --configuration Release --output $env:GITHUB_WORKSPACE/artifacts/packages --version-suffix=$env:PACKAGE_VERSION_SUFFIX + - name: Upload packages to artifacts + if: matrix.os == 'ubuntu-latest' + uses: actions/upload-artifact@v3 + with: + name: packages + path: artifacts/packages + - name: Generate documentation + shell: pwsh + env: + # This contains the git tag name on release; in that case we build the docs without publishing them. + DOCFX_SOURCE_BRANCH_NAME: ${{ github.base_ref || github.ref_name }} + run: | + cd docs + & ./generate-examples.ps1 + dotnet docfx docfx.json + if ($LastExitCode -ne 0) { + Write-Error "docfx failed with exit code $LastExitCode." + } + Copy-Item CNAME _site/CNAME + Copy-Item home/*.html _site/ + Copy-Item home/*.ico _site/ + New-Item -Force _site/styles -ItemType Directory | Out-Null + Copy-Item -Recurse home/assets/* _site/styles/ + - name: Upload documentation to artifacts + if: matrix.os == 'ubuntu-latest' + uses: actions/upload-artifact@v3 + with: + name: documentation + path: docs/_site + + inspect-code: + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Git checkout + uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x + - name: Restore tools + run: | + dotnet tool restore + - name: InspectCode + shell: pwsh + run: | + $inspectCodeOutputPath = Join-Path $env:RUNNER_TEMP 'jetbrains-inspectcode-results.xml' + Write-Output "INSPECT_CODE_OUTPUT_PATH=$inspectCodeOutputPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + dotnet jb inspectcode JsonApiDotNetCore.sln --build --output="$inspectCodeOutputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --properties:ContinuousIntegrationBuild=false --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal + - name: Verify outcome + shell: pwsh + run: | + [xml]$xml = Get-Content $env:INSPECT_CODE_OUTPUT_PATH + if ($xml.report.Issues -and $xml.report.Issues.Project) { + foreach ($project in $xml.report.Issues.Project) { + if ($project.Issue.Count -gt 0) { + $project.ForEach({ + Write-Output "`nProject $($project.Name)" + $failed = $true + + $_.Issue.ForEach({ + $issueType = $xml.report.IssueTypes.SelectSingleNode("IssueType[@Id='$($_.TypeId)']") + $severity = $_.Severity ?? $issueType.Severity + + Write-Output "[$severity] $($_.File):$($_.Line) $($_.TypeId): $($_.Message)" + }) + }) + } + } + + if ($failed) { + Write-Error "One or more projects failed code inspection." + } + } + + cleanup-code: + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Git checkout + uses: actions/checkout@v3 + with: + fetch-depth: 2 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x + - name: Restore tools + run: | + dotnet tool restore + - name: Restore packages + run: | + dotnet restore + - name: CleanupCode (on PR diff) + if: github.event_name == 'pull_request' + shell: pwsh + run: | + # Not using the environment variables for SHAs, because they may be outdated. This may happen on force-push after the build is queued, but before it starts. + # The below works because HEAD is detached (at the merge commit), so HEAD~1 is at the base branch. When a PR contains no commits, this job will not run. + $headCommitHash = git rev-parse HEAD + $baseCommitHash = git rev-parse HEAD~1 + + Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash in pull request." + dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --max-runs=5 --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN -f commits -a $headCommitHash -b $baseCommitHash --fail-on-diff --print-diff + - name: CleanupCode (on branch) + if: github.event_name == 'push' + shell: pwsh + run: | + Write-Output "Running code cleanup on all files." + dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN --fail-on-diff --print-diff + + publish: + timeout-minutes: 60 + runs-on: ubuntu-latest + needs: [ build-and-test, inspect-code, cleanup-code ] + if: ${{ !github.event.pull_request.head.repo.fork }} + permissions: + packages: write + contents: write + steps: + - name: Download artifacts + uses: actions/download-artifact@v3 + - name: Publish to GitHub Packages + if: github.event_name == 'push' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: pwsh + run: | + dotnet nuget add source --username 'json-api-dotnet' --password "$env:GITHUB_TOKEN" --store-password-in-clear-text --name 'github' 'https://nuget.pkg.github.com/json-api-dotnet/index.json' + dotnet nuget push "$env:GITHUB_WORKSPACE/packages/*.nupkg" --api-key "$env:GITHUB_TOKEN" --source 'github' + - name: Publish documentation + if: github.event_name == 'push' && github.ref == 'refs/heads/master' + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_branch: gh-pages + publish_dir: ./documentation + commit_message: 'Auto-generated documentation from' + - name: Publish to NuGet + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + env: + NUGET_ORG_API_KEY: ${{ secrets.NUGET_ORG_API_KEY }} + shell: pwsh + run: | + dotnet nuget push "$env:GITHUB_WORKSPACE/packages/*.nupkg" --api-key "$env:NUGET_ORG_API_KEY" --source 'nuget.org' diff --git a/Build.ps1 b/Build.ps1 index 2a143dd168..a1b640bdc0 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -1,115 +1,23 @@ -function CheckLastExitCode { - param ([int[]]$SuccessCodes = @(0), [scriptblock]$CleanupScript=$null) - - if ($SuccessCodes -notcontains $LastExitCode) { - throw "Executable returned exit code $LastExitCode" - } -} - -function RunInspectCode { - $outputPath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'jetbrains-inspectcode-results.xml') - dotnet jb inspectcode JsonApiDotNetCore.sln --no-build --output="$outputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal - CheckLastExitCode - - [xml]$xml = Get-Content "$outputPath" - if ($xml.report.Issues -and $xml.report.Issues.Project) { - foreach ($project in $xml.report.Issues.Project) { - if ($project.Issue.Count -gt 0) { - $project.ForEach({ - Write-Output "`nProject $($project.Name)" - $failed = $true - - $_.Issue.ForEach({ - $issueType = $xml.report.IssueTypes.SelectSingleNode("IssueType[@Id='$($_.TypeId)']") - $severity = $_.Severity ?? $issueType.Severity - - Write-Output "[$severity] $($_.File):$($_.Line) $($_.TypeId): $($_.Message)" - }) - }) - } - } - - if ($failed) { - throw "One or more projects failed code inspection."; - } - } -} - -function RunCleanupCode { - # When running in cibuild for a pull request, this reformats only the files changed in the PR and fails if the reformat produces changes. - - if ($env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT) { - # In the past, we used $env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT for the merge commit hash. That is the pinned hash at the time the build is enqueued. - # When a force-push happens after that, while the build hasn't yet started, this hash becomes invalid during the build, resulting in a lookup error. - # To prevent failing the build for unobvious reasons we use HEAD, which is always a detached head (the PR merge result). - - $headCommitHash = git rev-parse HEAD - CheckLastExitCode - - $baseCommitHash = git rev-parse "$env:APPVEYOR_REPO_BRANCH" - CheckLastExitCode - - if ($baseCommitHash -ne $headCommitHash) { - Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash in pull request." - dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --max-runs=5 --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN -f commits -a $headCommitHash -b $baseCommitHash --fail-on-diff --print-diff - CheckLastExitCode - } +function VerifySuccessExitCode { + if ($LastExitCode -ne 0) { + throw "Command failed with exit code $LastExitCode." } } -function ReportCodeCoverage { - if ($env:APPVEYOR) { - if ($IsWindows) { - dotnet codecov -f "**\coverage.cobertura.xml" - } - } - else { - dotnet reportgenerator -reports:**\coverage.cobertura.xml -targetdir:artifacts\coverage - } - - CheckLastExitCode -} - -function CreateNuGetPackage { - if ($env:APPVEYOR_REPO_TAG -eq $true) { - # Get the version suffix from the repo tag. Example: v1.0.0-preview1-final => preview1-final - $segments = $env:APPVEYOR_REPO_TAG_NAME -split "-" - $suffixSegments = $segments[1..2] - $versionSuffix = $suffixSegments -join "-" - } - else { - # Get the version suffix from the auto-incrementing build number. Example: "123" => "master-0123". - if ($env:APPVEYOR_BUILD_NUMBER) { - $revision = "{0:D4}" -f [convert]::ToInt32($env:APPVEYOR_BUILD_NUMBER, 10) - $versionSuffix = "$($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH ?? $env:APPVEYOR_REPO_BRANCH)-$revision" - } - else { - $versionSuffix = "pre-0001" - } - } - - if ([string]::IsNullOrWhitespace($versionSuffix)) { - dotnet pack --no-restore --no-build --configuration Release --output .\artifacts - } - else { - dotnet pack --no-restore --no-build --configuration Release --output .\artifacts --version-suffix=$versionSuffix - } - - CheckLastExitCode -} +Write-Host "$(pwsh --version)" +Write-Host "Active .NET SDK: $(dotnet --version)" dotnet tool restore -CheckLastExitCode - -dotnet build -c Release -CheckLastExitCode +VerifySuccessExitCode -RunInspectCode -RunCleanupCode +dotnet build --configuration Release --version-suffix="pre" +VerifySuccessExitCode -dotnet test -c Release --no-build --collect:"XPlat Code Coverage" -CheckLastExitCode +dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.DeterministicReport=true +VerifySuccessExitCode -ReportCodeCoverage +dotnet reportgenerator -reports:**\coverage.cobertura.xml -targetdir:artifacts\coverage +VerifySuccessExitCode -CreateNuGetPackage +dotnet pack --no-build --configuration Release --output artifacts/packages --version-suffix="pre" +VerifySuccessExitCode diff --git a/Directory.Build.props b/Directory.Build.props index 294c7d656f..af83e22b27 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -21,6 +21,10 @@ + + true + + $(NoWarn);1591 true @@ -34,6 +38,7 @@ 6.0.* + 2.3.* 4.18.* 17.6.* diff --git a/README.md b/README.md index b3ffb5db90..2aa2490106 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ # JsonApiDotNetCore A framework for building [JSON:API](http://jsonapi.org/) compliant REST APIs using .NET Core and Entity Framework Core. Includes support for [Atomic Operations](https://jsonapi.org/ext/atomic/). -[![Build](https://ci.appveyor.com/api/projects/status/t8noo6rjtst51kga/branch/master?svg=true)](https://ci.appveyor.com/project/json-api-dotnet/jsonapidotnetcore/branch/master) +[![Build](https://github.com/json-api-dotnet/JsonApiDotNetCore/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/json-api-dotnet/JsonApiDotNetCore/actions/workflows/build.yml) [![Coverage](https://codecov.io/gh/json-api-dotnet/JsonApiDotNetCore/branch/master/graph/badge.svg?token=pn036tWV8T)](https://codecov.io/gh/json-api-dotnet/JsonApiDotNetCore) [![NuGet](https://img.shields.io/nuget/v/JsonApiDotNetCore.svg)](https://www.nuget.org/packages/JsonApiDotNetCore/) [![Chat](https://badges.gitter.im/json-api-dotnet-core/Lobby.svg)](https://gitter.im/json-api-dotnet-core/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) @@ -95,15 +95,24 @@ Have a question, found a bug or want to submit code changes? See our [contributi ## Trying out the latest build -After each commit to the master branch, a new prerelease NuGet package is automatically published to AppVeyor at https://ci.appveyor.com/nuget/jsonapidotnetcore. To try it out, follow the next steps: - -* In Visual Studio: **Tools**, **NuGet Package Manager**, **Package Manager Settings**, **Package Sources** - * Click **+** - * Name: **AppVeyor JADNC**, Source: **https://ci.appveyor.com/nuget/jsonapidotnetcore** - * Click **Update**, **Ok** -* Open the NuGet package manager console (**Tools**, **NuGet Package Manager**, **Package Manager Console**) - * Select **AppVeyor JADNC** as package source - * Run command: `Install-Package JonApiDotNetCore -pre` +After each commit to the master branch, a new pre-release NuGet package is automatically published to [GitHub Packages](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry). +To try it out, follow the steps below: + +1. [Create a Personal Access Token (classic)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic) with at least `read:packages` scope. +1. Add our package source to your local user-specific `nuget.config` file by running: + ```bash + dotnet nuget add source https://nuget.pkg.github.com/json-api-dotnet/index.json --name github-json-api --username YOUR-GITHUB-USERNAME --password YOUR-PAT-CLASSIC + ``` + In the command above: + - Replace YOUR-GITHUB-USERNAME with the username you use to login your GitHub account. + - Replace YOUR-PAT-CLASSIC with the token your created above. + + :warning: If the above command doesn't give you access in the next step, remove the package source by running: + ```bash + dotnet nuget remove source github-json-api + ``` + and retry with the `--store-password-in-clear-text` switch added. +1. Restart your IDE, open your project, and browse the list of packages from the github-json-api feed (make sure pre-release packages are included). ## Development @@ -125,7 +134,7 @@ And then to run the tests: dotnet test ``` -Alternatively, to build and validate the code, run all tests, generate code coverage and produce the NuGet package: +Alternatively, to build, run all tests, generate code coverage and NuGet packages: ```bash pwsh Build.ps1 diff --git a/appveyor.yml b/appveyor.yml index 4b0196904d..1ad1455837 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,115 +1,12 @@ -image: - - Ubuntu2004 - - Visual Studio 2022 +image: Visual Studio 2022 version: '{build}' -stack: postgresql 15 - -environment: - PGUSER: postgres - PGPASSWORD: Password12! - GIT_ACCESS_TOKEN: - secure: WPzhuEyDE7yuHeEgLi3RoGJ8we+AHU6nMksbFoWQ0AmI/HJLh4bjOR0Jnnzc6aaG - branches: only: - master - - develop - - unstable - /release\/.+/ -pull_requests: - do_not_increment_build_number: true - -nuget: - disable_publish_on_pr: true - -matrix: - fast_finish: true - -for: -- - matrix: - only: - - image: Visual Studio 2022 - services: - - postgresql15 - install: - # Temporary workaround for https://help.appveyor.com/discussions/questions/60488-postgresql-version - - net start postgresql-x64-15 - # REF: https://github.com/docascode/docfx-seed/blob/master/appveyor.yml - before_build: - - pwsh: | - if (-Not $env:APPVEYOR_PULL_REQUEST_TITLE) { - # https://dotnet.github.io/docfx/tutorial/docfx_getting_started.html - git checkout $env:APPVEYOR_REPO_BRANCH -q - } - after_build: - - pwsh: | - CD ./docs - & ./generate-examples.ps1 - & dotnet docfx docfx.json - if ($LastExitCode -ne 0) { - throw "docfx failed with exit code $LastExitCode." - } - - # https://www.appveyor.com/docs/how-to/git-push/ - git config --global credential.helper store - Set-Content -Path "$HOME\.git-credentials" -Value "https://$($env:GIT_ACCESS_TOKEN):x-oauth-basic@github.com`n" -NoNewline - git config --global user.email "cibuild@jsonapi.net" - git config --global user.name "json-api-cibuild" - git config --global core.autocrlf false - git config --global core.safecrlf false - git clone https://github.com/json-api-dotnet/JsonApiDotNetCore.git -b gh-pages origin_site -q - Copy-Item origin_site/.git _site -recurse - Copy-Item CNAME _site/CNAME - Copy-Item home/*.html _site/ - Copy-Item home/*.ico _site/ - New-Item -Force _site/styles -ItemType Directory | Out-Null - Copy-Item -Recurse home/assets/* _site/styles/ - CD _site - git add -A 2>&1 - git commit -m "Automated commit from cibuild" -q - if (-Not $env:APPVEYOR_PULL_REQUEST_TITLE) { - git push origin gh-pages -q - echo "Documentation updated successfully." - } - artifacts: - - path: .\**\artifacts\**\*.nupkg - name: NuGet - deploy: - - provider: NuGet - skip_symbols: false - api_key: - secure: hlP/zkfkHzmutSXPYAiINmPdv+QEj3TpAjKewHEkCtQnHnA2tSo+Xey0g6FVM6S5 - on: - branch: master - appveyor_repo_tag: true - - provider: NuGet - skip_symbols: false - api_key: - secure: hlP/zkfkHzmutSXPYAiINmPdv+QEj3TpAjKewHEkCtQnHnA2tSo+Xey0g6FVM6S5 - on: - branch: /release\/.+/ - appveyor_repo_tag: true - -build_script: -- pwsh: | - Write-Output ".NET version:" - dotnet --version - - Write-Output "PowerShell version:" - pwsh --version - - Write-Output "PostgreSQL version:" - if ($IsWindows) { - . "${env:ProgramFiles}\PostgreSQL\15\bin\psql" --version - } - else { - psql --version - } - - .\Build.ps1 - +build: off test: off +deploy: off diff --git a/cleanupcode.ps1 b/cleanupcode.ps1 index 5740ab5a90..ba1b0ca4c0 100644 --- a/cleanupcode.ps1 +++ b/cleanupcode.ps1 @@ -39,6 +39,6 @@ if ($revision) { } else { Write-Output "Running code cleanup on all files." - dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --max-runs=5 --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN + dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN VerifySuccessExitCode } diff --git a/docs/generate-examples.ps1 b/docs/generate-examples.ps1 index cbe7d13e9d..4b13408460 100644 --- a/docs/generate-examples.ps1 +++ b/docs/generate-examples.ps1 @@ -1,28 +1,28 @@ #Requires -Version 7.3 -# This script generates response documents for ./request-examples +# This script generates HTTP response files (*.json) for .ps1 files in ./request-examples function Get-WebServer-ProcessId { - $processId = $null - if ($IsMacOs || $IsLinux) { - $processId = $(lsof -ti:14141) + $webProcessId = $null + if ($IsMacOS -Or $IsLinux) { + $webProcessId = $(lsof -ti:14141) } elseif ($IsWindows) { - $processId = $(Get-NetTCPConnection -LocalPort 14141 -ErrorAction SilentlyContinue).OwningProcess?[0] + $webProcessId = $(Get-NetTCPConnection -LocalPort 14141 -ErrorAction SilentlyContinue).OwningProcess?[0] } else { - throw [System.Exception] "Unsupported operating system." + throw "Unsupported operating system." } - return $processId + return $webProcessId } -function Kill-WebServer { - $processId = Get-WebServer-ProcessId +function Stop-WebServer { + $webProcessId = Get-WebServer-ProcessId - if ($processId -ne $null) { + if ($webProcessId -ne $null) { Write-Output "Stopping web server" - Get-Process -Id $processId | Stop-Process -ErrorVariable stopErrorMessage + Get-Process -Id $webProcessId | Stop-Process -ErrorVariable stopErrorMessage if ($stopErrorMessage) { throw "Failed to stop web server: $stopErrorMessage" @@ -32,16 +32,28 @@ function Kill-WebServer { function Start-WebServer { Write-Output "Starting web server" - Start-Job -ScriptBlock { dotnet run --project ..\src\Examples\GettingStarted\GettingStarted.csproj } | Out-Null + $startTimeUtc = Get-Date -AsUTC + $job = Start-Job -ScriptBlock { + dotnet run --project ..\src\Examples\GettingStarted\GettingStarted.csproj --configuration Debug --property:TreatWarningsAsErrors=True --urls=http://0.0.0.0:14141 + } $webProcessId = $null + $timeout = [timespan]::FromSeconds(30) + Do { Start-Sleep -Seconds 1 + $hasTimedOut = ($(Get-Date -AsUTC) - $startTimeUtc) -gt $timeout $webProcessId = Get-WebServer-ProcessId - } While ($webProcessId -eq $null) + } While ($webProcessId -eq $null -and -not $hasTimedOut) + + if ($hasTimedOut) { + Write-Host "Failed to start web server, dumping output." + Receive-Job -Job $job + throw "Failed to start web server." + } } -Kill-WebServer +Stop-WebServer Start-WebServer try { @@ -55,10 +67,10 @@ try { & $scriptFile.FullName > .\request-examples\$jsonFileName if ($LastExitCode -ne 0) { - throw [System.Exception] "Example request from '$($scriptFile.Name)' failed with exit code $LastExitCode." + throw "Example request from '$($scriptFile.Name)' failed with exit code $LastExitCode." } } } finally { - Kill-WebServer + Stop-WebServer } diff --git a/src/JsonApiDotNetCore.Annotations/JsonApiDotNetCore.Annotations.csproj b/src/JsonApiDotNetCore.Annotations/JsonApiDotNetCore.Annotations.csproj index 0adaf34f74..119d295b35 100644 --- a/src/JsonApiDotNetCore.Annotations/JsonApiDotNetCore.Annotations.csproj +++ b/src/JsonApiDotNetCore.Annotations/JsonApiDotNetCore.Annotations.csproj @@ -23,10 +23,6 @@ embedded - - true - - diff --git a/src/JsonApiDotNetCore.SourceGenerators/JsonApiDotNetCore.SourceGenerators.csproj b/src/JsonApiDotNetCore.SourceGenerators/JsonApiDotNetCore.SourceGenerators.csproj index 738ba46976..6d79d8c893 100644 --- a/src/JsonApiDotNetCore.SourceGenerators/JsonApiDotNetCore.SourceGenerators.csproj +++ b/src/JsonApiDotNetCore.SourceGenerators/JsonApiDotNetCore.SourceGenerators.csproj @@ -23,10 +23,6 @@ https://github.com/json-api-dotnet/JsonApiDotNetCore - - true - - diff --git a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj index 7ffea227e0..6a1b8517e6 100644 --- a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj +++ b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj @@ -21,10 +21,6 @@ embedded - - true - - diff --git a/test/AnnotationTests/AnnotationTests.csproj b/test/AnnotationTests/AnnotationTests.csproj index 7b221a9a42..b712b1bb67 100644 --- a/test/AnnotationTests/AnnotationTests.csproj +++ b/test/AnnotationTests/AnnotationTests.csproj @@ -1,13 +1,9 @@ - $(TargetFrameworkName);netstandard1.0 + $(TargetFrameworkName);netstandard2.0 latest - - - - diff --git a/test/DiscoveryTests/DiscoveryTests.csproj b/test/DiscoveryTests/DiscoveryTests.csproj index abbec3ed98..0eae11e850 100644 --- a/test/DiscoveryTests/DiscoveryTests.csproj +++ b/test/DiscoveryTests/DiscoveryTests.csproj @@ -10,6 +10,7 @@ + diff --git a/test/JsonApiDotNetCoreTests/JsonApiDotNetCoreTests.csproj b/test/JsonApiDotNetCoreTests/JsonApiDotNetCoreTests.csproj index 8c4822b67a..e66fbaeacc 100644 --- a/test/JsonApiDotNetCoreTests/JsonApiDotNetCoreTests.csproj +++ b/test/JsonApiDotNetCoreTests/JsonApiDotNetCoreTests.csproj @@ -12,6 +12,7 @@ + diff --git a/test/MultiDbContextTests/MultiDbContextTests.csproj b/test/MultiDbContextTests/MultiDbContextTests.csproj index 5ec0b1400c..0f5f5f2cff 100644 --- a/test/MultiDbContextTests/MultiDbContextTests.csproj +++ b/test/MultiDbContextTests/MultiDbContextTests.csproj @@ -10,6 +10,7 @@ + diff --git a/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj index b0c4838b1a..f651f73c0e 100644 --- a/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj +++ b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj @@ -10,6 +10,7 @@ + diff --git a/test/SourceGeneratorTests/SourceGeneratorTests.csproj b/test/SourceGeneratorTests/SourceGeneratorTests.csproj index f9af731411..707de9b8c5 100644 --- a/test/SourceGeneratorTests/SourceGeneratorTests.csproj +++ b/test/SourceGeneratorTests/SourceGeneratorTests.csproj @@ -11,6 +11,7 @@ + diff --git a/test/TestBuildingBlocks/IntegrationTest.cs b/test/TestBuildingBlocks/IntegrationTest.cs index 69776e7b5d..73ced10d8d 100644 --- a/test/TestBuildingBlocks/IntegrationTest.cs +++ b/test/TestBuildingBlocks/IntegrationTest.cs @@ -18,7 +18,7 @@ public abstract class IntegrationTest : IAsyncLifetime static IntegrationTest() { - int maxConcurrentTestRuns = Environment.GetEnvironmentVariable("APPVEYOR") != null ? 32 : 64; + int maxConcurrentTestRuns = OperatingSystem.IsWindows() && Environment.GetEnvironmentVariable("CI") != null ? 32 : 64; ThrottleSemaphore = new SemaphoreSlim(maxConcurrentTestRuns); } diff --git a/test/TestBuildingBlocks/TestBuildingBlocks.csproj b/test/TestBuildingBlocks/TestBuildingBlocks.csproj index 674c2674a4..885b339783 100644 --- a/test/TestBuildingBlocks/TestBuildingBlocks.csproj +++ b/test/TestBuildingBlocks/TestBuildingBlocks.csproj @@ -10,6 +10,7 @@ + diff --git a/test/UnitTests/UnitTests.csproj b/test/UnitTests/UnitTests.csproj index 3166fe27e1..35ceca88a4 100644 --- a/test/UnitTests/UnitTests.csproj +++ b/test/UnitTests/UnitTests.csproj @@ -9,6 +9,7 @@ +