Fix #809, #811, #810 and implement #812 (discriminated-union creation… #1453
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 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - '*' | |
| pull_request: | |
| workflow_dispatch: | |
| inputs: | |
| forcePublish: | |
| description: When true the Publish stage will always be run, otherwise it only runs for tagged versions. | |
| required: false | |
| default: false | |
| type: boolean | |
| forcePublicNugetDestination: | |
| description: When true the NuGet Publish destination will always be set to nuget.org. (Force publishing normally publishes to GitHub Packages, if not tagged version) | |
| required: false | |
| default: false | |
| type: boolean | |
| skipCleanup: | |
| description: When true the pipeline clean-up stage will not be run. For example, the cache used between pipeline stages will be retained. | |
| required: false | |
| default: false | |
| type: boolean | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.sha }} | |
| cancel-in-progress: true | |
| permissions: | |
| actions: write # enable cache clean-up | |
| checks: write # enable test result annotations | |
| contents: write # enable creating releases and GitHub Pages branch deployment | |
| id-token: write # enable OIDC authentication | |
| issues: read | |
| packages: write # enable publishing packages | |
| pages: write # enable GitHub Pages environment | |
| pull-requests: write # enable test result annotations and PR preview comments | |
| jobs: | |
| prepareConfig: | |
| name: Prepare Configuration | |
| runs-on: ubuntu-latest | |
| outputs: | |
| RESOLVED_ENV_VARS: ${{ steps.prepareEnvVarsAndSecrets.outputs.environmentVariablesYamlBase64 }} | |
| RESOLVED_SECRETS: ${{ steps.prepareEnvVarsAndSecrets.outputs.secretsYamlBase64 }} | |
| steps: | |
| # Declare any environment variables and/or secrets that need to be available inside the build process | |
| - uses: endjin/Endjin.RecommendedPractices.GitHubActions/actions/prepare-env-vars-and-secrets@main | |
| id: prepareEnvVarsAndSecrets | |
| with: | |
| environmentVariablesYaml: | | |
| ZF_NUGET_PUBLISH_SOURCE: ${{ (startsWith(github.ref, 'refs/tags/') || github.event.inputs.forcePublicNugetDestination == 'true') && 'https://api.nuget.org/v3/index.json' || format('https://nuget.pkg.github.com/{0}/index.json', github.repository_owner) }} | |
| BUILDVAR_BuildWebsite: "false" | |
| BUILDVAR_IsPreviewDeployment: "${{ github.event_name == 'pull_request' }}" | |
| BUILDVAR_BasePathPrefix: "${{ github.event_name == 'pull_request' && format('/{0}/pr-preview/pr-{1}', github.event.repository.name, github.event.pull_request.number) || format('/{0}', github.event.repository.name) }}" | |
| secretsYaml: | | |
| NUGET_API_KEY: "${{ startsWith(github.ref, 'refs/tags/') && secrets.NUGET_APIKEY || secrets.BUILD_PUBLISHER_PAT }}" | |
| # TODO: Review approach to enable Vellum to be downloaded | |
| VELLUM_DOWNLOAD_TOKEN: "${{ secrets.ENDJIN_PACKAGES_TOKEN }}" | |
| secretsEncryptionKey: ${{ secrets.SHARED_WORKFLOW_KEY }} | |
| setCachePathsConfig: | |
| name: Set Cache Paths | |
| runs-on: ubuntu-latest | |
| env: | |
| BASE_CACHE_PATHS: | | |
| .nuget-packages | |
| Solutions | |
| solutions | |
| # The reusable workflow has the above paths built-in so we don't need to pass them | |
| ADDITIONAL_CACHE_PATHS: | | |
| JSON-Schema-Test-Suite | |
| JMESPath-Test-Suite | |
| Jsonata-Test-Suite | |
| yaml-test-suite | |
| tests/json-patch-tests | |
| jsonpath-compliance-test-suite | |
| toon-format-spec | |
| docs/website/.endjin | |
| docs/website/.output | |
| **/bin | |
| **/obj | |
| .zf | |
| outputs: | |
| # This is consumed by the reusable workflow | |
| additionalCachePaths: ${{ steps.additionalCachePaths.outputs.additionalCachePaths }} | |
| # This is consumed by other jobs that need to restore the cache | |
| allCachePaths: ${{ steps.allCachePaths.outputs.allCachePaths }} | |
| steps: | |
| - id: additionalCachePaths | |
| name: Store Additional Cache Paths | |
| run: | | |
| { | |
| echo "additionalCachePaths<<EOF" | |
| echo "$ADDITIONAL_CACHE_PATHS" | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| - id: allCachePaths | |
| name: Store All Cache Paths | |
| run: | | |
| { | |
| echo "allCachePaths<<EOF" | |
| echo "$BASE_CACHE_PATHS" | |
| echo "$ADDITIONAL_CACHE_PATHS" | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| build: | |
| needs: | |
| - prepareConfig | |
| - setCachePathsConfig | |
| uses: endjin/Endjin.RecommendedPractices.GitHubActions/.github/workflows/scripted-build-matrix-pipeline.yml@main | |
| with: | |
| testPhaseMatrixJson: | | |
| { | |
| "os": ["ubuntu-latest", "windows-latest"], | |
| "dotnetFramework": ["net10.0", "net481"], | |
| "exclude": [ | |
| { | |
| "os": "ubuntu-latest", | |
| "dotnetFramework": "net481" | |
| } | |
| ] | |
| } | |
| compilePhaseRunnerOs: ubuntu-latest | |
| packagePhaseRunnerOs: ubuntu-latest | |
| netSdkVersion: '10.0.x' | |
| additionalNetSdkVersion: | | |
| 8.0.x | |
| 9.0.x | |
| # workflow_dispatch inputs are always strings, the type property is just for the UI | |
| forcePublish: ${{ github.event.inputs.forcePublish == 'true' }} | |
| skipCleanup: ${{ github.event.inputs.skipCleanup == 'true' }} | |
| # testArtifactName: '' | |
| # testArtifactPath: '' | |
| compilePhaseEnv: ${{ needs.prepareConfig.outputs.RESOLVED_ENV_VARS }} | |
| testPhaseEnv: ${{ needs.prepareConfig.outputs.RESOLVED_ENV_VARS }} | |
| packagePhaseEnv: ${{ needs.prepareConfig.outputs.RESOLVED_ENV_VARS }} | |
| publishPhaseEnv: ${{ needs.prepareConfig.outputs.RESOLVED_ENV_VARS }} | |
| additionalCachePaths: ${{ needs.setCachePathsConfig.outputs.additionalCachePaths }} | |
| # Build the documentation website in a parallel post-compile job | |
| postCompilePhaseTasks: BuildWebsite | |
| postCompileRunnerOs: ubuntu-latest | |
| postCompilePhaseEnv: ${{ needs.prepareConfig.outputs.RESOLVED_ENV_VARS }} | |
| postCompileArtifactName: website-output | |
| postCompileArtifactPath: docs/website/.output | |
| secrets: | |
| compilePhaseAzureCredentials: ${{ secrets.AZURE_READER_CREDENTIALS }} | |
| compilePhaseSecrets: ${{ needs.prepareConfig.outputs.RESOLVED_SECRETS }} | |
| # testPhaseAzureCredentials: ${{ secrets.TESTS_KV_READER_CREDENTIALS }} | |
| # packagePhaseAzureCredentials: ${{ secrets.AZURE_PUBLISH_CREDENTIALS }} | |
| # publishPhaseAzureCredentials: ${{ secrets.AZURE_PUBLISH_CREDENTIALS }} | |
| # testPhaseSecrets: ${{ needs.prepareConfig.outputs.RESOLVED_SECRETS }} | |
| # packagePhaseSecrets: ${{ needs.prepareConfig.outputs.RESOLVED_SECRETS }} | |
| publishPhaseSecrets: ${{ needs.prepareConfig.outputs.RESOLVED_SECRETS }} | |
| postCompilePhaseSecrets: ${{ needs.prepareConfig.outputs.RESOLVED_SECRETS }} | |
| secretsEncryptionKey: ${{ secrets.SHARED_WORKFLOW_KEY }} | |
| integration-tests: | |
| name: Integration Tests (Docker) | |
| needs: | |
| - build | |
| - setCachePathsConfig | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| submodules: recursive | |
| - name: Setup .NET SDK | |
| uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1 | |
| with: | |
| dotnet-version: | | |
| 10.0.x | |
| 9.0.x | |
| - name: Restore build cache | |
| uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | |
| with: | |
| path: | | |
| .nuget-packages | |
| Solutions | |
| solutions | |
| ${{ needs.setCachePathsConfig.outputs.additionalCachePaths }} | |
| key: build-state-${{ github.run_id }}-compile | |
| enableCrossOsArchive: true | |
| - name: Install dotnet-coverage | |
| run: dotnet tool install --global dotnet-coverage | |
| - name: Run Integration Tests | |
| run: | | |
| dotnet-coverage collect \ | |
| --output integration-tests.cobertura.xml \ | |
| --output-format cobertura \ | |
| -s dotnet-coverage.settings.xml \ | |
| "dotnet test --project tests/Corvus.Text.Json.AsyncApi.Transport.IntegrationTests/Corvus.Text.Json.AsyncApi.Transport.IntegrationTests.csproj \ | |
| -f net10.0 \ | |
| -c Release \ | |
| --no-build \ | |
| --filter TestCategory=integration&TestCategory!=failing \ | |
| --report-trx --report-trx-filename integration-tests.trx" | |
| timeout-minutes: 10 | |
| env: | |
| NUGET_PACKAGES: ${{ github.workspace }}/.nuget-packages | |
| - name: Publish Test Results | |
| uses: dorny/test-reporter@df6247429542221bc30d46a036ee47af1102c451 # v2.7.0 | |
| if: always() | |
| with: | |
| name: Integration Test Results | |
| path: '**/integration-tests.trx' | |
| reporter: dotnet-trx | |
| deploy-docs: | |
| name: Deploy Documentation | |
| needs: | |
| - build | |
| # The prod documentation site should only ever be updated, by this build, from stable release tags | |
| if: github.event_name == 'push' && github.ref_type == 'tag' && !contains(github.ref_name, '-') | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: https://corvus-oss.org/Corvus.JsonSchema/ | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Download website artifact | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: website-output | |
| path: docs/website/.output | |
| - name: Deploy to GitHub Pages | |
| uses: JamesIves/github-pages-deploy-action@d92aa235d04922e8f08b40ce78cc5442fcfbfa2f # v4.8.0 | |
| with: | |
| branch: gh-pages | |
| folder: docs/website/.output | |
| clean-exclude: pr-preview | |
| deploy-preview: | |
| name: Deploy PR Preview | |
| needs: | |
| - build | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| concurrency: preview-${{ github.event.pull_request.number }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Download website artifact | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: website-output | |
| path: docs/website/.output | |
| - name: Ensure .nojekyll on gh-pages | |
| run: | | |
| if ! git fetch origin gh-pages 2>/dev/null || \ | |
| ! git show origin/gh-pages:.nojekyll >/dev/null 2>&1; then | |
| git fetch origin gh-pages:gh-pages 2>/dev/null || git checkout --orphan gh-pages | |
| git worktree add /tmp/gh-pages gh-pages | |
| cd /tmp/gh-pages | |
| rm -f _config.yml | |
| touch .nojekyll | |
| git add -A | |
| git -c user.name="github-actions[bot]" -c user.email="github-actions[bot]@users.noreply.github.com" \ | |
| commit --amend --no-edit | |
| git push origin gh-pages --force-with-lease | |
| cd - | |
| git worktree remove /tmp/gh-pages | |
| fi | |
| - name: Deploy PR preview | |
| uses: rossjrw/pr-preview-action@ffa7509e91a3ec8dfc2e5536c4d5c1acdf7a6de9 # v1.8.1 | |
| with: | |
| source-dir: docs/website/.output | |
| umbrella-dir: pr-preview | |
| pages-base-url: corvus-oss.org/Corvus.JsonSchema |