-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A bit of cleanup for consistency (#79)
This PR includes some cleanup to make this repo consistent with my learnings in other repos and some other trivial changes. - Simplified common attributes and MSBuild properties and excluded generated code from code coverage. - Reconfigured workflows to reuse common portions.
- Loading branch information
1 parent
f2eed67
commit a93f99e
Showing
11 changed files
with
193 additions
and
165 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Install tools | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: | | ||
6.x | ||
7.x | ||
- name: Install .NET tools | ||
shell: pwsh | ||
run: dotnet tool restore |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Set version variables | ||
|
||
outputs: | ||
package_version: | ||
description: The package version. | ||
value: ${{ steps.version.outputs.package_version }} | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Set version | ||
id: version | ||
shell: pwsh | ||
run: | | ||
$packageVersion = dotnet nbgv get-version --variable NuGetPackageVersion | ||
"package_version=$packageVersion" >> $env:GITHUB_OUTPUT |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,16 @@ | ||
name: 'Treasure.Utils-PR' | ||
name: Treasure.Utils-PR | ||
|
||
on: pull_request | ||
|
||
env: | ||
# Stop wasting time caching packages | ||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | ||
|
||
jobs: | ||
build: | ||
name: 'Build Treasure.Utils' | ||
build_pr: | ||
name: Build Treasure.Utils | ||
strategy: | ||
max-parallel: 3 | ||
fail-fast: false | ||
matrix: | ||
platform: [ windows, ubuntu, macos ] | ||
runs-on: ${{ matrix.platform }}-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: | | ||
6.x | ||
7.x | ||
- name: Patch global.json if necessary | ||
shell: pwsh | ||
run: ./scripts/PatchGlobalJson.ps1 | ||
|
||
- name: Install dependencies | ||
run: dotnet restore | ||
|
||
- name: DotNet Format | ||
run: dotnet format --no-restore --verify-no-changes | ||
|
||
- name: Build | ||
run: dotnet build --configuration Release --no-restore | ||
|
||
- name: Test | ||
run: dotnet test --configuration Release --no-build --verbosity normal --collect:"XPlat Code Coverage" | ||
|
||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
name: codecov-${{ matrix.platform }} | ||
directory: __test-results | ||
fail_ci_if_error: true | ||
verbose: true | ||
|
||
- name: Upload output artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: __output_${{ matrix.platform }} | ||
path: __output | ||
|
||
- name: Upload packages artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: __packages_${{ matrix.platform }} | ||
path: __packages | ||
uses: ./.github/workflows/workflow_build.yml | ||
secrets: inherit | ||
with: | ||
platform: ${{ matrix.platform }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Build Workflow | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
checkFormat: | ||
type: boolean | ||
default: true | ||
platform: | ||
type: string | ||
default: ubuntu | ||
outputs: | ||
package_version: | ||
description: 'The version of the package that was built.' | ||
value: ${{ jobs.build.outputs.package_version }} | ||
|
||
env: | ||
# Stop wasting time caching packages | ||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ${{ inputs.platform }}-latest | ||
|
||
outputs: | ||
package_version: ${{steps.version.outputs.package_version}} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install tools | ||
uses: ./.github/actions/install-tools | ||
|
||
- name: Set version variables | ||
id: version | ||
uses: ./.github/actions/version-vars | ||
|
||
- name: Restore | ||
run: dotnet restore | ||
|
||
- name: Format validation | ||
if: ${{ inputs.checkFormat }} | ||
run: dotnet format --no-restore --verify-no-changes | ||
|
||
- name: Build | ||
run: dotnet build --configuration Release --no-restore | ||
|
||
- name: Test | ||
run: dotnet test --configuration Release --no-build --verbosity normal /p:CollectCoverage=true | ||
|
||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
name: codecov | ||
directory: __test-results | ||
fail_ci_if_error: true | ||
verbose: true | ||
|
||
- name: Upload output artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: output_${{ inputs.platform }} | ||
path: __output | ||
|
||
- name: Upload package artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: packages_${{ inputs.platform }} | ||
path: __packages |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Release Workflow | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
package-version: | ||
type: string | ||
required: true | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: NuGet.org | ||
url: https://www.nuget.org | ||
|
||
steps: | ||
- name: Setup NuGet | ||
uses: NuGet/setup-nuget@v1 | ||
with: | ||
nuget-version: latest | ||
|
||
- name: Download packages artifact | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: packages_ubuntu | ||
path: __packages | ||
|
||
- name: Push ${{ inputs.package-version }} to NuGet.org | ||
run: nuget push __packages/NuGet/Release/Treasure.Utils.*.nupkg -ApiKey ${{ secrets.NUGET_API_KEY }} -Source https://api.nuget.org/v3/index.json |
This file contains 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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.