-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reusable workflow for build and test
- Loading branch information
1 parent
f8ac4e8
commit 7526e2f
Showing
3 changed files
with
85 additions
and
46 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,74 @@ | ||
name: Build & test | ||
on: | ||
workflow_call: | ||
inputs: | ||
version: | ||
description: Assembly and package version | ||
required: true | ||
type: string | ||
package-module: | ||
description: Name of the module | ||
required: true | ||
type: string | ||
namespace: | ||
description: Name of the module namespace | ||
required: true | ||
type: string | ||
target-framework: | ||
description: Compiles for a specific framework | ||
required: true | ||
type: string | ||
skip-target-framework-on-build: | ||
required: false | ||
type: boolean | ||
default: false | ||
collect-code-coverage: | ||
required: false | ||
type: boolean | ||
default: false | ||
secrets: | ||
signing-key-value: | ||
description: Value of the signing key | ||
required: true | ||
env: | ||
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages | ||
Version: ${{ inputs.version }} | ||
jobs: | ||
build-and-test: | ||
runs-on: windows-latest # We are using windows instead of ubuntu becaus it provides support for net472 & net48. | ||
timeout-minutes: 15 | ||
steps: | ||
- name: 📥 checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: 🖊️ materialize signing key | ||
id: signing-key | ||
uses: ./.github/actions/materialize-signing-key | ||
with: | ||
signing-key-value: ${{ secrets.signing-key-value }} | ||
- name: 💾 cache nuget packages | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ env.NUGET_PACKAGES }} | ||
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} | ||
restore-keys: | | ||
${{ runner.os }}-nuget- | ||
- name: 🏗️ build | ||
if: ${{ inputs.skip-target-framework-on-build == true }} | ||
run: dotnet build ./src/${{ inputs.namespace }}.${{ inputs.package-module }}.sln${{ inputs.skip-target-framework-on-build == true && '' || format('-f {0}', inputs.target-framework)}} | ||
env: | ||
CI: true | ||
StrongNameKey: ${{ secrets.SIGNING_KEY }} | ||
StrongNameKeyPath: ${{ steps.signing-key.outputs.file-path }} | ||
- name: 🧪 test ${{ inputs.package-module }} in ${{ inputs.target-framework }} | ||
if: ${{ inputs.collect-code-coverage != true }} | ||
run: dotnet test ./src/${{ inputs.namespace }}.${{ inputs.package-module }}.Tests/ --no-build -f ${{ inputs.target-framework }} | ||
- name: 🧪 test ${{ inputs.package-module }} in ${{ inputs.target-framework }} & collect coverage | ||
if: ${{ inputs.collect-code-coverage == true }} | ||
uses: ./.github/actions/test-module | ||
with: | ||
codecov-token: ${{ secrets.CODECOV_TOKEN }} | ||
module-name: ${{ inputs.package-module }} | ||
module-namespace: ${{ inputs.namespace }} | ||
target-framework: ${{ inputs.target-framework }} |
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