diff --git a/.github/actions/setup-bc-devtools/action.yml b/.github/actions/setup-bc-devtools/action.yml index e85c7f0..5f80b27 100644 --- a/.github/actions/setup-bc-devtools/action.yml +++ b/.github/actions/setup-bc-devtools/action.yml @@ -13,13 +13,13 @@ inputs: runs: using: composite steps: - - name: Get source for BC Dev Tools + - name: Get BC Dev Tools for Marketplace id: get-bc-devtools shell: pwsh run: | # Retrieve source Uri from Marketplace $sourceUri = ${{github.action_path}}/Marketplace.ps1 -Version ${{ inputs.version-number }} - echo "source-uri=$($sourceUri)" >> $env:GITHUB_OUTPUT + "source-uri=$sourceUri" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8 - name: Download BC DevTools asset id: download-bc-devtools-asset @@ -28,7 +28,7 @@ runs: env: ASSET_URI: ${{ steps.get-bc-devtools.outputs.source-uri }} run: | - # Download BC DevTools asset + # Download BC DevTools asset $downloadPath = ${{github.action_path}}/Download-BcDevToolsAsset.ps1 -AssetUri $env:ASSET_URI "download-path=$downloadPath" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8 @@ -39,6 +39,7 @@ runs: TARGET_PATH: ${{ inputs.target-path }} ACTION_PATH: ${{ github.action_path }} run: | - Write-Output "Extracting $env:ARCHIVE_PATH ..." + # Extract BC DevTools asset + Write-Output "Extracting $($env:ARCHIVE_PATH)..." & "$env:ACTION_PATH\Extract-RequiredFiles.ps1" -DestinationPath $env:TARGET_PATH -ArchivePath $env:ARCHIVE_PATH -PathInArchive 'extension/bin/Analyzers' diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml new file mode 100644 index 0000000..2b4f8c1 --- /dev/null +++ b/.github/workflows/build-and-release.yml @@ -0,0 +1,114 @@ +name: CI/CD + +on: + push: + branches: [ main, master ] + paths: + - 'src/**' + - '**/*.sln' + - '**/*.csproj' + - '**/*.props' + - '**/*.targets' + - 'Directory.Packages.props' + - 'global.json' + - 'nuget.config' + - '.config/dotnet-tools.json' + - '.github/workflows/**' + - '!**/*.md' + +permissions: + contents: read + packages: write + +env: + DOTNET_NOLOGO: true + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + + - name: Setup .NET SDK + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.0.x' + cache: true + cache-dependency-path: | + **/*.csproj + **/packages.lock.json + nuget.config + + - name: Setup BC DevTools - netstandard2.1 + uses: ./.github/actions/setup-bc-devtools + with: + version-number: '12.0.875970' + target-path: 'Microsoft.Dynamics.BusinessCentral.Development.Tools/netstandard2.1' + + - name: Setup BC DevTools - net8.0 + uses: ./.github/actions/setup-bc-devtools + with: + version-number: '16.0.1463980' + target-path: 'Microsoft.Dynamics.BusinessCentral.Development.Tools/net8.0' + + - name: Restore + run: dotnet restore src/RoslynTestKit.sln + + - name: GitVersion - Setup + uses: gittools/actions/gitversion/setup@v3 + with: + versionSpec: '5.x' + + - name: GitVersion - Determine + id: gitversion + uses: gittools/actions/gitversion/execute@v3 + with: + useConfigFile: true + + - name: Pack + run: > + dotnet pack src/RoslynTestKit/RoslynTestKit.csproj + --configuration Release + --no-restore + --include-symbols + --output ./artifacts + /p:ContinuousIntegrationBuild=true + /p:EmbedUntrackedSources=true + /p:SymbolPackageFormat=snupkg + /p:RepositoryType=git + /p:RepositoryUrl=https://github.com/${{ github.repository }} + /p:RepositoryCommit=${{ steps.gitversion.outputs.Sha }} + /p:PackageVersion=${{ steps.gitversion.outputs.NuGetVersionV2 }} + /p:AssemblyVersion=${{ steps.gitversion.outputs.AssemblySemVer }} + /p:FileVersion=${{ steps.gitversion.outputs.AssemblySemFileVer }} + /p:InformationalVersion="${{ steps.gitversion.outputs.InformationalVersion }}" + + - name: Validate + run: | + dotnet tool install --global dotnet-validate --version 0.0.1-preview.537 + dotnet-validate package local ./artifacts/*.nupkg + + - name: Publish to GitHub Packages + run: > + dotnet nuget push "./artifacts/*.nupkg" + --no-symbols + --api-key ${{ secrets.GITHUB_TOKEN }} + --source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json + --skip-duplicate + + - name: Publish to NuGet.org + env: + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + run: | + if [ -z "$NUGET_API_KEY" ]; then + echo "NUGET_API_KEY not configured"; exit 1 + fi + dotnet nuget push ./packages/*.nupkg \ + --api-key "$NUGET_API_KEY" \ + --source https://api.nuget.org/v3/index.json \ + --skip-duplicate \ No newline at end of file diff --git a/.github/workflows/pr-validation.yml b/.github/workflows/pr-validation.yml deleted file mode 100644 index 2a9a16a..0000000 --- a/.github/workflows/pr-validation.yml +++ /dev/null @@ -1,102 +0,0 @@ -name: Pull Request Validation - -on: - pull_request: - branches: [ main, master ] - paths: - - 'src/**' - - '*.sln' - - '*.props' - - '*.targets' - - 'global.json' - - 'nuget.config' - - '.github/workflows/**' - -permissions: - contents: read - -env: - DOTNET_NOLOGO: true - DOTNET_CLI_TELEMETRY_OPTOUT: true - -jobs: - build-pack-validate: - name: Build, Pack and Validate - runs-on: ubuntu-latest - if: ${{ github.event.pull_request.draft == false }} - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup .NET SDKs - uses: actions/setup-dotnet@v4 - with: - dotnet-version: | - 6.0.x - 8.0.x - cache: true - cache-dependency-path: | - **/*.csproj - **/packages.lock.json - nuget.config - - - name: GitVersion - Setup - uses: gittools/actions/gitversion/setup@v3 - with: - versionSpec: '5.x' - - - name: GitVersion - Determine - id: gitversion - uses: gittools/actions/gitversion/execute@v3 - with: - useConfigFile: true - - - name: Setup BC DevTools (netstandard2.1) - uses: ./.github/actions/setup-bc-devtools - with: - version-number: '12.0.875970' - target-path: 'Microsoft.Dynamics.BusinessCentral.Development.Tools/netstandard2.1' - - - name: Setup BC DevTools (net8.0) - uses: ./.github/actions/setup-bc-devtools - with: - version-number: '16.0.1463980' - target-path: 'Microsoft.Dynamics.BusinessCentral.Development.Tools/net8.0' - - - name: Restore - run: dotnet restore src/RoslynTestKit.sln - - - name: Pack - run: > - dotnet pack src/RoslynTestKit/RoslynTestKit.csproj - --configuration Release - --no-restore - /p:ContinuousIntegrationBuild=true - /p:PublishRepositoryUrl=true - /p:RepositoryType=git - /p:RepositoryUrl=${{ github.server_url }}/${{ github.repository }} - /p:RepositoryBranch=${{ github.ref }} - /p:RepositoryCommit=${{ steps.gitversion.outputs.sha }} - /p:EmbedUntrackedSources=true - /p:IncludeSymbols=true - /p:SymbolPackageFormat=snupkg - /p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersionV2 }} - /p:AssemblyVersion=${{ steps.gitversion.outputs.assemblySemVer }} - /p:FileVersion=${{ steps.gitversion.outputs.assemblySemFileVer }} - /p:InformationalVersion=${{ steps.gitversion.outputs.informationalVersion }} - --output ./packages - - - name: Validate package manifest - if: false - run: | - dotnet tool install --global dotnet-validate --version 0.0.1-preview.537 - dotnet-validate package local ./packages/*.nupkg - - - name: Upload package - uses: actions/upload-artifact@v4 - with: - name: nuget-package - path: ./packages/*.nupkg - retention-days: 7 \ No newline at end of file diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..99e3df1 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,82 @@ +name: Pull Request + +on: + pull_request: + branches: [ main, master ] + paths: + - 'src/**' + - '**/*.sln' + - '**/*.csproj' + - '**/*.props' + - '**/*.targets' + - 'Directory.Packages.props' + - 'global.json' + - 'nuget.config' + - '.config/dotnet-tools.json' + - '.github/workflows/**' + - '!**/*.md' + +permissions: + contents: read + +env: + DOTNET_NOLOGO: true + +jobs: + build-pack-validate: + name: Build, Pack and Validate + runs-on: ubuntu-latest + if: ${{ github.event.pull_request.draft == false }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET SDK + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.0.x' + cache: true + cache-dependency-path: | + **/*.csproj + **/packages.lock.json + nuget.config + + - name: Setup BC DevTools (netstandard2.1) + uses: ./.github/actions/setup-bc-devtools + with: + version-number: '12.0.875970' + target-path: 'Microsoft.Dynamics.BusinessCentral.Development.Tools/netstandard2.1' + + - name: Setup BC DevTools (net8.0) + uses: ./.github/actions/setup-bc-devtools + with: + version-number: '16.0.1463980' + target-path: 'Microsoft.Dynamics.BusinessCentral.Development.Tools/net8.0' + + - name: Restore + run: dotnet restore src/RoslynTestKit.sln + + - name: Build + # Disabled as 'dotnet pack' also builds the project + if: false + run: > + dotnet build src/RoslynTestKit.sln + --configuration Release + --no-restore + + - name: Pack + run: > + dotnet pack src/RoslynTestKit/RoslynTestKit.csproj + --configuration Release + --no-restore + --include-symbols + --output ./artifacts + /p:ContinuousIntegrationBuild=true + /p:EmbedUntrackedSources=true + /p:SymbolPackageFormat=snupkg + + - name: Validate + run: | + dotnet tool install --global dotnet-validate --version 0.0.1-preview.537 + dotnet-validate package local ./artifacts/*.nupkg \ No newline at end of file diff --git a/.github/workflows/release-and-publish.yml b/.github/workflows/release-and-publish.yml deleted file mode 100644 index 3c51263..0000000 --- a/.github/workflows/release-and-publish.yml +++ /dev/null @@ -1,153 +0,0 @@ -name: Release and Publish - -on: - push: - branches: [ main, master ] - paths: - - 'src/**' - - '*.sln' - - '*.props' - - '*.targets' - - 'global.json' - - 'nuget.config' - tags: - - 'v*' - workflow_dispatch: - inputs: - version_increment: - description: Version increment type (auto|major|minor|patch) - required: false - default: auto - type: choice - options: [ auto, major, minor, patch ] - -permissions: - contents: write - packages: write - -concurrency: - group: release-${{ github.ref }} - cancel-in-progress: false - -env: - DOTNET_NOLOGO: true - DOTNET_CLI_TELEMETRY_OPTOUT: true - -jobs: - release: - name: Build, Tag, Publish - runs-on: ubuntu-latest - outputs: - version: ${{ steps.gitversion.outputs.nuGetVersionV2 }} - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup .NET SDKs - uses: actions/setup-dotnet@v4 - with: - dotnet-version: | - 6.0.x - 8.0.x - cache: true - cache-dependency-path: | - **/*.csproj - **/packages.lock.json - nuget.config - - - name: GitVersion - Setup - uses: gittools/actions/gitversion/setup@v3 - with: - versionSpec: '5.x' - - - name: Determine GitVersion override - id: gv - run: | - if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ inputs.version_increment }}" != "auto" ]; then - echo "override=increment=${{ inputs.version_increment }}" >> "$GITHUB_OUTPUT" - else - echo "override=" >> "$GITHUB_OUTPUT" - fi - - - name: GitVersion - Determine - id: gitversion - uses: gittools/actions/gitversion/execute@v3 - with: - useConfigFile: true - overrideConfig: ${{ steps.gv.outputs.override }} - - - name: Setup BC DevTools (netstandard2.1) - uses: ./.github/actions/setup-bc-devtools - with: - version-number: '12.0.875970' - target-path: 'Microsoft.Dynamics.BusinessCentral.Development.Tools/netstandard2.1' - - - name: Setup BC DevTools (net8.0) - uses: ./.github/actions/setup-bc-devtools - with: - version-number: '16.0.1463980' - target-path: 'Microsoft.Dynamics.BusinessCentral.Development.Tools/net8.0' - - - name: Restore - run: dotnet restore src/RoslynTestKit.sln - - - name: Pack - run: > - dotnet pack src/RoslynTestKit/RoslynTestKit.csproj - --configuration Release - --no-restore - /p:ContinuousIntegrationBuild=true - /p:PublishRepositoryUrl=true - /p:RepositoryType=git - /p:RepositoryUrl=${{ github.server_url }}/${{ github.repository }} - /p:RepositoryBranch=${{ github.ref }} - /p:RepositoryCommit=${{ steps.gitversion.outputs.sha }} - /p:EmbedUntrackedSources=true - /p:IncludeSymbols=true - /p:SymbolPackageFormat=snupkg - /p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersionV2 }} - /p:AssemblyVersion=${{ steps.gitversion.outputs.assemblySemVer }} - /p:FileVersion=${{ steps.gitversion.outputs.assemblySemFileVer }} - /p:InformationalVersion=${{ steps.gitversion.outputs.informationalVersion }} - --output ./packages - - - name: Validate package manifest - if: false - run: | - dotnet tool install --global dotnet-validate --version 0.0.1-preview.537 - dotnet-validate package local ./packages/*.nupkg - - - name: Create GitHub Release - uses: softprops/action-gh-release@v2 - with: - tag_name: v${{ steps.gitversion.outputs.nuGetVersionV2 }} - name: v${{ steps.gitversion.outputs.nuGetVersionV2 }} - generate_release_notes: true - prerelease: ${{ contains(steps.gitversion.outputs.nuGetVersionV2, '-') }} - files: | - ./packages/*.nupkg - ./packages/*.snupkg - - - name: Publish to GitHub Packages - env: - NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - dotnet nuget push ./packages/*.nupkg \ - --api-key "$NUGET_AUTH_TOKEN" \ - --source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json \ - --skip-duplicate - - - name: Publish to NuGet.org (stable only) - if: ${{ !contains(steps.gitversion.outputs.nuGetVersionV2, '-') }} - env: - NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} - run: | - if [ -z "$NUGET_API_KEY" ]; then - echo "NUGET_API_KEY not configured"; exit 1 - fi - dotnet nuget push ./packages/*.nupkg ./packages/*.snupkg \ - --api-key "$NUGET_API_KEY" \ - --source https://api.nuget.org/v3/index.json \ - --skip-duplicate diff --git a/GitVersion.yml b/GitVersion.yml index 9237c0d..0093d88 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -1,47 +1 @@ -mode: ContinuousDelivery - -branches: - main: - regex: ^(main|master)$ - tag: "" - increment: Patch - prevent-increment-of-merged-branch-version: true - - develop: - regex: ^dev(elop)?(ment)?$ - tag: alpha - increment: Minor - - release: - regex: ^releases?[/-] - tag: beta - increment: None - is-release-branch: true - - feature: - regex: ^features?[/-] - tag: useBranchName - increment: Inherit - - hotfix: - regex: ^hotfix(es)?[/-] - tag: "" - increment: Patch - - support: - regex: ^support[/-] - tag: "" - increment: Patch - - pull-request: - regex: ^(pull|pull\-requests|pr)[/-] - tag: PullRequest - increment: Inherit - tag-number-pattern: '[/-](?\d+)[-/]' - -tag-prefix: v -commit-message-incrementing: Enabled -major-version-bump-message: '\+semver:\s?(breaking|major)' -minor-version-bump-message: '\+semver:\s?(feature|minor)' -patch-version-bump-message: '\+semver:\s?(fix|patch)' -no-bump-message: '\+semver:\s?(none|skip)' +mode: Mainline diff --git a/README.md b/README.md index 5abab4e..50a1209 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,15 @@ # RoslynTestKit -![Build Status](https://github.com/ALCops/RoslynTestKit/workflows/PR%20Validation/badge.svg) -![Release](https://github.com/ALCops/RoslynTestKit/workflows/Release/badge.svg) + +![CI/CD](https://github.com/ALCops/RoslynTestKit/actions/workflows/build-and-release.yml/badge.svg?branch=master) + + [![NuGet Version](https://img.shields.io/nuget/v/ALCops.RoslynTestKit.svg)](https://www.nuget.org/packages/ALCops.RoslynTestKit/) [![NuGet Downloads](https://img.shields.io/nuget/dt/ALCops.RoslynTestKit.svg)](https://www.nuget.org/packages/ALCops.RoslynTestKit/) + +![TFMs](https://img.shields.io/badge/TFMs-netstandard2.1%20%7C%20net8.0-blue) + A lightweight framework for writing unit tests for Roslyn diagnostic analyzers, code fixes, refactorings, and completion providers targeting the [AL Language](https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-programming-in-al) of Microsoft Dynamics 365 Business Central. This project is a fork of [RoslynTestKit](https://github.com/cezarypiatek/RoslynTestKit), created to support the specific CodeAnalysis assemblies required by the AL language. |CSharp|AL| diff --git a/src/RoslynTestKit/RoslynTestKit.csproj b/src/RoslynTestKit/RoslynTestKit.csproj index 7eb3790..46afce3 100644 --- a/src/RoslynTestKit/RoslynTestKit.csproj +++ b/src/RoslynTestKit/RoslynTestKit.csproj @@ -1,16 +1,17 @@  netstandard2.1;net8.0 + ALCops.RoslynTestKit RoslynTestKit A lightweight framework for creating unit tests for Roslyn diagnostic analyzers, code fixes and refactorings. Dustin Campbell, Ivan Yochev, Cezary Piątek, Christoph Stuber, Ansgar Barthel, Arthur van de Vondervoort - Copyright 2015-2025 by Dustin Campbell, Ivan Yochev, Cezary Piątek, Christoph Stuber, Ansgar Barthel, Arthur van de Vondervoort - true - https://github.com/ALCops/RoslynTestKit/blob/master/License.txt - https://github.com/ALCops/RoslynTestKit - Roslyn CodeAnalysis test testing tdd analyzer fixes refactor refactoring AL BusinessCentral - ALCops.RoslynTestKit RoslynTestKit + https://github.com/ALCops/RoslynTestKit + true + MIT + Roslyn CodeAnalysis test testing tdd analyzer fixes refactor refactoring AL Business Central + en + en-US enable @@ -21,7 +22,9 @@ - + False @@ -37,7 +40,9 @@ - + False