From 98f2c9a214cbbce46175a8cffd7f0bd8854b170f Mon Sep 17 00:00:00 2001 From: Florian Bernd Date: Sat, 10 Dec 2022 15:07:03 +0100 Subject: [PATCH] Replace actions from `flobernd/actions` with `zyactions` --- .github/workflows/cd.yaml | 72 ++++++++++++++-------- .github/workflows/ci.yaml | 120 +++++++++++++++++++++--------------- .github/workflows/test.yaml | 2 +- test/README.md | 4 +- 4 files changed, 119 insertions(+), 79 deletions(-) diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index b1d3b3d..8fd879d 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -2,12 +2,21 @@ name: CD on: workflow_call: + inputs: + path: + description: The path where to look for a Visual Studio Solution file (without a trailing slash). + type: string + required: false + default: '' secrets: NUGET_API_KEY: required: true env: BUILD_CONFIG: Release + DOTNET_GLOBAL_JSON: ${{ inputs.path != '' && format('{0}/global.json', inputs.path) || 'global.json' }} + RESTORE_PATTERN: ${{ inputs.path != '' && format('{0}/**/packages.lock.json', inputs.path) || '**/packages.lock.json' }} + ARTIFACTS_PATH: ${{ inputs.path != '' && format('{0}/nupkg', inputs.path) || 'nupkg' }} jobs: release: @@ -15,21 +24,22 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3.1.0 + uses: actions/checkout@v3 with: # Required by NBGV fetch-depth: 0 - name: .NET Setup - uses: flobernd/actions/dotnet/setup@master + uses: zyactions/dotnet-setup@v1 with: - # Use version defined in 'global.json' - dotnet-version: '' - disable-problem-matcher: true + global-json-file: ${{ env.DOTNET_GLOBAL_JSON }} + problem-matcher: false - name: Detect Version - uses: dotnet/nbgv@master id: nbgv + uses: dotnet/nbgv@master + with: + path: ${{ inputs.path }} - name: Create Release uses: flobernd/actions/github/create-release@master @@ -41,9 +51,11 @@ jobs: build: name: Build runs-on: ubuntu-latest + env: + FILTERED_SOLUTION: ${{ inputs.path != '' && format('{0}/Packages.slnf', inputs.path) || 'Packages.slnf' }} steps: - name: Checkout - uses: actions/checkout@v3.1.0 + uses: actions/checkout@v3 with: # Required by NBGV fetch-depth: 0 @@ -51,42 +63,51 @@ jobs: - name: Find Solution id: find uses: flobernd/actions/dotnet/find-solution@master + with: + directory: ${{ inputs.path }} - uses: flobernd/actions/dotnet/filter-solution@master name: Filter Solution with: solution: ${{ steps.find.outputs.solution }} + # This pattern is relative to the solution file and does not need to be prefixed with + # the 'directory' input value pattern: | **/*.csproj !**/*.Test*.csproj !**/*.Examples*.csproj - output: ./Packages.slnf + output: ${{ env.FILTERED_SOLUTION }} - name: .NET Setup - uses: flobernd/actions/dotnet/setup@master + uses: zyactions/dotnet-setup@v1 + with: + global-json-file: ${{ env.DOTNET_GLOBAL_JSON }} + problem-matcher: true + + - name: .NET Cache Packages + uses: actions/cache@v3 with: - # Use version defined in 'global.json' - dotnet-version: '' - disable-problem-matcher: false + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles(env.RESTORE_PATTERN) }} + restore-keys: ${{ runner.os }}-nuget- - name: .NET Restore - uses: flobernd/actions/dotnet/restore@master + uses: zactions/dotnet-restore@v1 with: - workspace: ./Packages.slnf - cache-key: ${{ hashFiles('**/packages.lock.json') }} + workspace: ${{ env.FILTERED_SOLUTION }} - name: .NET Pack uses: flobernd/actions/dotnet/pack@master with: - workspace: ./Packages.slnf + workspace: ${{ env.FILTERED_SOLUTION }} configuration: ${{ env.BUILD_CONFIG }} - output: ./nupkg + output: ${{ env.ARTIFACTS_PATH }} - name: Upload Artifact - uses: actions/upload-artifact@v3.1.1 + uses: actions/upload-artifact@v3 with: name: packages - path: ./nupkg + path: ${{ env.ARTIFACTS_PATH }} publish: name: Publish to ${{ matrix.feed.name }} @@ -100,21 +121,20 @@ jobs: needs: build steps: - name: .NET Setup - uses: flobernd/actions/dotnet/setup@master + uses: zyactions/dotnet-setup@v1 with: - # Use version defined in 'global.json' - dotnet-version: '' - disable-problem-matcher: true + global-json-file: ${{ env.DOTNET_GLOBAL_JSON }} + problem-matcher: false - name: Download Packages - uses: actions/download-artifact@v3.0.1 + uses: actions/download-artifact@v3 with: name: packages - path: ./nupkg + path: ${{ env.ARTIFACTS_PATH }} - name: .NET NuGet Push uses: flobernd/actions/dotnet/nuget-push@master with: - packages: ./nupkg/*.nupkg + packages: ${{ format('{0}/*.nupkg', env.ARTIFACTS_PATH) }} nuget-source: ${{ matrix.feed.source }} nuget-api-key: ${{ secrets[matrix.feed.key] }} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 06baffb..bc8b461 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,10 +3,8 @@ name: CI on: workflow_call: inputs: - directory: - description: > - The directory in which a Visual Studio Solution file is to be searched for. - Do not add a trailing slash. + path: + description: The path where to look for a Visual Studio Solution file (without a trailing slash). type: string required: false default: '' @@ -16,57 +14,73 @@ on: env: BUILD_CONFIG: Debug + DOTNET_GLOBAL_JSON: ${{ inputs.path != '' && format('{0}/global.json', inputs.path) || 'global.json' }} + RESTORE_PATTERN: ${{ inputs.path != '' && format('{0}/**/packages.lock.json', inputs.path) || '**/packages.lock.json' }} + TESTS_PATTERN: ${{ inputs.path != '' && format('{0}/**/*.Test*.csproj', inputs.path) || '**/*.Test*.csproj' }} jobs: lint: name: Lint runs-on: ubuntu-latest steps: + - name: .NET Setup (SDK 8) + uses: zyactions/dotnet-setup@v1 + with: + dotnet-version: '8.x.x' + + - name: Install latest .NET Format tool + shell: bash + run: | + dotnet tool install -g dotnet-format --version "8.*" --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json + - name: Checkout - uses: actions/checkout@v3.1.0 + uses: actions/checkout@v3 with: # Retrieve the preceding commit to enable 'changed-files' to create a diff. fetch-depth: 2 - name: Get Changed Files id: changed-files - uses: tj-actions/changed-files@932dad31974f07bd23cab5870d45c6e5ad5c8b73 - # TODO: This step should honor the directory input - - - name: Find Solution - id: find - uses: flobernd/actions/dotnet/find-solution@master + uses: tj-actions/changed-files@f569b77fb1d9ad9f1a125757d7e9e07b1f320199 with: - directory: ${{ inputs.directory }} + files: ${{ inputs.path != '' && format('{0}/**', inputs.path) || '' }} - name: .NET Setup - uses: flobernd/actions/dotnet/setup@master + uses: zyactions/dotnet-setup@v1 with: - # Use version defined in 'global.json' - dotnet-version: '' - disable-problem-matcher: true + global-json-file: ${{ env.DOTNET_GLOBAL_JSON }} + problem-matcher: false + + - name: .NET Cache Packages + uses: actions/cache@v3 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles(env.RESTORE_PATTERN) }} + restore-keys: ${{ runner.os }}-nuget- - name: .NET Restore - uses: flobernd/actions/dotnet/restore@master + uses: zyactions/dotnet-restore@v1 with: - workspace: ${{ steps.find.outputs.solution }} - cache-key: ${{ hashFiles('**/packages.lock.json') }} + working-directory: ${{ inputs.path }} # TODO: Add additional generic '.editorconfig' linting, e.g. for `*.csproj` files - name: .NET Lint - uses: flobernd/actions/dotnet/lint@master + uses: zyactions/dotnet-lint@v1 with: - workspace: ${{ steps.find.outputs.solution }} + working-directory: ${{ inputs.path }} # This list is empty for the initial commit. NET Lint will lint all files in this case. include: ${{ steps.changed-files.outputs.all_changed_files }} + use-standalone-tool: true test: name: Run Tests runs-on: ubuntu-latest + env: + FILTERED_SOLUTION: ${{ inputs.path != '' && format('{0}/Tests.slnf', inputs.path) || 'Tests.slnf' }} steps: - name: Checkout - uses: actions/checkout@v3.1.0 + uses: actions/checkout@v3 with: # Required by NBGV fetch-depth: 0 @@ -75,52 +89,55 @@ jobs: id: find uses: flobernd/actions/dotnet/find-solution@master with: - directory: ${{ inputs.directory }} + directory: ${{ inputs.path }} - name: Filter Solution uses: flobernd/actions/dotnet/filter-solution@master with: solution: ${{ steps.find.outputs.solution }} - pattern: | - **/*.Test*.csproj - output: ./Tests.slnf - # TODO: This step should honor the directory input for outputting the Solution Filter + # This pattern is relative to the solution file and does not need to be prefixed with + # the 'directory' input value + pattern: '**/*.Test*.csproj' + output: ${{ env.FILTERED_SOLUTION }} - name: .NET Setup - uses: flobernd/actions/dotnet/setup@master + uses: zyactions/dotnet-setup@v1 with: - # Use version defined in 'global.json' - dotnet-version: '' - disable-problem-matcher: true + global-json-file: ${{ env.DOTNET_GLOBAL_JSON }} + problem-matcher: false + + - name: .NET Cache Packages + uses: actions/cache@v3 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles(env.RESTORE_PATTERN) }} + restore-keys: ${{ runner.os }}-nuget- - name: .NET Restore - uses: flobernd/actions/dotnet/restore@master + uses: zyactions/dotnet-restore@v1 with: - workspace: ./Tests.slnf - cache-key: ${{ hashFiles('**/packages.lock.json') }} - # TODO: This step should honor the directory input for hashing + workspace: ${{ env.FILTERED_SOLUTION }} - name: .NET Build uses: flobernd/actions/dotnet/build@master with: - workspace: ./Tests.slnf + workspace: ${{ env.FILTERED_SOLUTION }} configuration: ${{ env.BUILD_CONFIG }} - name: .NET Test uses: flobernd/actions/dotnet/test@master with: - projects: '**/*.Test*.csproj' + projects: ${{ env.TESTS_PATTERN }} fail-on-error: false log-results: true collect-coverage: false maxdop: 4 - # TODO: This step should honor the directory input for test discovery - name: Generate Test Report uses: zyactions/test-reporter@main with: name: Test Results - path: '**/TestResults/*.trx' + path: ${{ inputs.path != '' && format('{0}/**/TestResults/*.trx', inputs.path) || '**/TestResults/*.trx' }} reporter: dotnet-trx fail-on-error: true only-summary: false @@ -131,7 +148,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3.1.0 + uses: actions/checkout@v3 with: # Required by NBGV and SonarCloud scanner fetch-depth: 0 @@ -140,21 +157,25 @@ jobs: id: find uses: flobernd/actions/dotnet/find-solution@master with: - directory: ${{ inputs.directory }} + directory: ${{ inputs.path }} - name: .NET Setup - uses: flobernd/actions/dotnet/setup@master + uses: zyactions/dotnet-setup@v1 + with: + global-json-file: ${{ env.DOTNET_GLOBAL_JSON }} + problem-matcher: true + + - name: .NET Cache Packages + uses: actions/cache@v3 with: - # Use version defined in 'global.json' - dotnet-version: '' - disable-problem-matcher: false + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles(env.RESTORE_PATTERN) }} + restore-keys: ${{ runner.os }}-nuget- - name: .NET Restore - uses: flobernd/actions/dotnet/restore@master + uses: zyactions/dotnet-restore@v1 with: workspace: ${{ steps.find.outputs.solution }} - cache-key: ${{ hashFiles('**/packages.lock.json') }} - # TODO: This step should honor the directory input for hashing - name: SonarCloud Names id: sonarcloud-names @@ -185,11 +206,10 @@ jobs: - name: .NET Test uses: flobernd/actions/dotnet/test@master with: - projects: '**/*.Test*.csproj' + projects: ${{ env.TESTS_PATTERN }} log-results: true collect-coverage: true maxdop: 4 - # TODO: This step should honor the directory input for test discovery - name: SonarCloud End uses: flobernd/actions/sonarcloud/end@master diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a07e2eb..1c58fdc 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ jobs: name: CI uses: ./.github/workflows/ci.yaml with: - directory: test + path: test secrets: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/test/README.md b/test/README.md index 9b17023..3572e6a 100644 --- a/test/README.md +++ b/test/README.md @@ -1,7 +1,7 @@ -# ZySharp Template +# ZySharp Workflows To be replaced by a meaningful description. ## License -ZySharp Template is licensed under the MIT license. +ZySharp Workflows is licensed under the MIT license.