Skip to content

Commit

Permalink
Replace actions from flobernd/actions with zyactions
Browse files Browse the repository at this point in the history
  • Loading branch information
flobernd committed Dec 10, 2022
1 parent d96890f commit 8bc1f37
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 60 deletions.
56 changes: 35 additions & 21 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -21,15 +30,16 @@ jobs:
fetch-depth: 0

- name: .NET Setup
uses: flobernd/actions/dotnet/setup@master
uses: zyactions/dotnet-setup@v1.0.0
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
Expand All @@ -41,6 +51,8 @@ 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/[email protected]
Expand All @@ -51,42 +63,45 @@ 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.0.0
with:
# Use version defined in 'global.json'
dotnet-version: ''
disable-problem-matcher: false
global-json-file: ${{ env.DOTNET_GLOBAL_JSON }}
problem-matcher: true

- name: .NET Restore
uses: flobernd/actions/dotnet/restore@master
with:
workspace: ./Packages.slnf
cache-key: ${{ hashFiles('**/packages.lock.json') }}
workspace: ${{ env.FILTERED_SOLUTION }}
cache-key: ${{ hashFiles(env.RESTORE_PATTERN) }}

- 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/[email protected]
with:
name: packages
path: ./nupkg
path: ${{ env.ARTIFACTS_PATH }}

publish:
name: Publish to ${{ matrix.feed.name }}
Expand All @@ -100,21 +115,20 @@ jobs:
needs: build
steps:
- name: .NET Setup
uses: flobernd/actions/dotnet/setup@master
uses: zyactions/dotnet-setup@v1.0.0
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/[email protected]
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] }}
69 changes: 33 additions & 36 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ''
Expand All @@ -16,6 +14,9 @@ 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:
Expand All @@ -31,26 +32,26 @@ jobs:
- name: Get Changed Files
id: changed-files
uses: tj-actions/changed-files@932dad31974f07bd23cab5870d45c6e5ad5c8b73
# TODO: This step should honor the directory input
with:
files: ${{ inputs.path != '' && format('{0}/**', inputs.path) || '' }}

- name: Find Solution
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.0.0
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 Restore
uses: flobernd/actions/dotnet/restore@master
with:
workspace: ${{ steps.find.outputs.solution }}
cache-key: ${{ hashFiles('**/packages.lock.json') }}
cache-key: ${{ hashFiles(env.RESTORE_PATTERN) }}

# TODO: Add additional generic '.editorconfig' linting, e.g. for `*.csproj` files

Expand All @@ -64,6 +65,8 @@ jobs:
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/[email protected]
Expand All @@ -75,52 +78,49 @@ 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.0.0
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 Restore
uses: flobernd/actions/dotnet/restore@master
with:
workspace: ./Tests.slnf
cache-key: ${{ hashFiles('**/packages.lock.json') }}
# TODO: This step should honor the directory input for hashing
workspace: ${{ env.FILTERED_SOLUTION }}
cache-key: ${{ hashFiles(env.RESTORE_PATTERN) }}

- 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
Expand All @@ -140,21 +140,19 @@ 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.0.0
with:
# Use version defined in 'global.json'
dotnet-version: ''
disable-problem-matcher: false
global-json-file: ${{ env.DOTNET_GLOBAL_JSON }}
problem-matcher: true

- name: .NET Restore
uses: flobernd/actions/dotnet/restore@master
with:
workspace: ${{ steps.find.outputs.solution }}
cache-key: ${{ hashFiles('**/packages.lock.json') }}
# TODO: This step should honor the directory input for hashing
cache-key: ${{ hashFiles(env.RESTORE_PATTERN) }}

- name: SonarCloud Names
id: sonarcloud-names
Expand Down Expand Up @@ -185,11 +183,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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
name: CI
uses: ./.github/workflows/ci.yaml
with:
directory: test
path: test
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

Expand Down
4 changes: 2 additions & 2 deletions test/README.md
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 8bc1f37

Please sign in to comment.