diff --git a/.github/actions/verify-dotnet-consolidation/action.yml b/.github/actions/verify-dotnet-consolidation/action.yml new file mode 100644 index 000000000..1ae2af42d --- /dev/null +++ b/.github/actions/verify-dotnet-consolidation/action.yml @@ -0,0 +1,27 @@ +name: Verify that .NET packages are consolidated +description: > + Verifies that the NuGet packages of a .NET solution are consolidated, i.e. the same version of a given package is used + in all projects. + +inputs: + directory: + required: false + default: . + description: Path to the directory where a solution file can be found. + solution-path: + required: false + default: "*.sln" + description: > + The path of the solution file to be processed. The value is given to PowerShell's `Get-ChildItem` cmdlet as-is, so + grepping is still possible but a name with spaces must be escaped separately. + +runs: + using: "composite" + steps: + - name: Setup + shell: pwsh + run: dotnet tool install dotnet-consolidate --global --version 2.0.0 + - name: Verify consolidation status + shell: pwsh + working-directory: ${{ inputs.directory }} + run: dotnet consolidate -s (Get-ChildItem ${{ inputs.solution-path }}).FullName diff --git a/.github/workflows/build-and-test-orchard-core.yml b/.github/workflows/build-and-test-orchard-core.yml index 356786833..ecce33e52 100644 --- a/.github/workflows/build-and-test-orchard-core.yml +++ b/.github/workflows/build-and-test-orchard-core.yml @@ -68,6 +68,13 @@ on: type: number default: 360 description: Configuration for the timeout-minutes parameter of the workflow. The 360 is GitHub's default. + verify-dotnet-consolidation: + required: false + type: boolean + default: true + description: > + When set to true, it will be verified whether the NuGet packages of the .NET solution are consolidated, i.e. + the same version of a given package is used in all projects. jobs: build-and-test: @@ -91,6 +98,12 @@ jobs: with: dotnet-version: ${{ inputs.dotnet-version }} + - name: Verify that .NET packages are consolidated + if: ${{ inputs.verify-dotnet-consolidation }} + uses: Lombiq/GitHub-Actions/.github/actions/verify-dotnet-consolidation@issue/OSOE-172 + with: + directory: ${{ inputs.build-directory }} + - name: Enable Node corepack uses: Lombiq/GitHub-Actions/.github/actions/enable-corepack@dev diff --git a/.github/workflows/build-dotnet.yml b/.github/workflows/build-dotnet.yml index 7ea6bbc10..357d0d9ec 100644 --- a/.github/workflows/build-dotnet.yml +++ b/.github/workflows/build-dotnet.yml @@ -1,4 +1,4 @@ -name: Build .NET solution +name: Build .NET solution on: workflow_call: @@ -59,6 +59,13 @@ on: type: number default: 360 description: Configuration for the timeout-minutes parameter of the workflow. The 360 is GitHub's default. + verify-dotnet-consolidation: + required: false + type: boolean + default: true + description: > + When set to true, it will be verified whether the NuGet packages of the .NET solution are consolidated, i.e. + the same version of a given package is used in all projects. jobs: # While the below steps seem suitable to DRY with build-and-test-orchard-core, since reusable workflows can't call @@ -85,6 +92,12 @@ jobs: with: dotnet-version: ${{ inputs.dotnet-version }} + - name: Verify that .NET packages are consolidated + if: ${{ inputs.verify-dotnet-consolidation }} + uses: Lombiq/GitHub-Actions/.github/actions/verify-dotnet-consolidation@issue/OSOE-172 + with: + directory: ${{ inputs.build-directory }} + - name: Build and Static Code Analysis uses: Lombiq/GitHub-Actions/.github/actions/build-dotnet@dev with: diff --git a/Docs/Actions.md b/Docs/Actions.md index 8f188cadd..3346dd0e2 100644 --- a/Docs/Actions.md +++ b/Docs/Actions.md @@ -11,4 +11,5 @@ In addition to the below short explanations, check out the inline documentation - `setup-dotnet`: Sets up the .NET SDK. - `setup-sql-server`: Sets up SQL Server with Lombiq-recommended defaults. - `test-dotnet`: Runs .NET unit and UI tests (with the [Lombiq UI Testing Toolbox for Orchard Core](https://github.com/Lombiq/UI-Testing-Toolbox)), generates a test report, and uploads UI testing failure dumps to artifacts. +- `verify-dotnet-consolidation`: Verifies that the NuGet packages of a .NET solution are consolidated, i.e. the same version of a given package is used in all projects. - `verify-submodule-pull-request`: Assuming that the current repository is a submodule in another repository, this action verifies that a pull request with a matching issue code has been opened there as well.