Add unit tests with secrets #32
Workflow file for this run
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
name: Build and Test | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
pull_request: | |
types: [opened, reopened, synchronize] | |
permissions: | |
actions: read | |
checks: write | |
contents: read | |
packages: write | |
jobs: | |
build: # Test, pack and publish the Open AI nuget package as a build artifact | |
runs-on: ubuntu-latest | |
env: | |
# if we're in a manually queued run, | |
version_suffix_args: ${{ format('--version-suffix="alpha.{0}"', github.run_number) }} | |
steps: | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: 8.x | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Build | |
run: dotnet build | |
-c Release | |
${{ env.version_suffix_args }} | |
working-directory: .dotnet | |
- name: Test | |
run: dotnet test | |
--no-build | |
--configuration Release | |
--filter="TestCategory~GitHub" | |
--logger "trx;LogFileName=${{github.workspace}}/artifacts/test-results/github.trx" | |
env: | |
SECRET_VALUE: ${{ secrets.REPOSITORY_SECRET }} | |
working-directory: .dotnet | |
- name: Test Report | |
uses: dorny/test-reporter@v1 | |
if: success() || failure() # run this step even if previous step failed | |
with: | |
name: dotnet tests # Name of the check run which will be created | |
path: '**/*.trx' # Path to test results | |
reporter: dotnet-trx # Format of test results | |
working-directory: ${{github.workspace}}/artifacts/test-results | |
- name: Pack | |
run: dotnet pack | |
--no-build | |
--configuration Release | |
--output "${{github.workspace}}/artifacts/packages" | |
${{ env.version_suffix_args }} | |
working-directory: .dotnet | |
- name: Upload artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: build-artifacts | |
path: ${{github.workspace}}/artifacts | |
- name: NuGet Autenticate | |
run: dotnet nuget add source | |
"https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" | |
--name "github" | |
--username ${{ github.actor }} | |
--password ${{ secrets.GITHUB_TOKEN }} | |
--store-password-in-clear-text | |
working-directory: .dotnet | |
- name: Publish | |
if: github.event_name != 'pull_request' | |
run: dotnet nuget push | |
${{github.workspace}}/artifacts/packages/*.nupkg | |
--source "github" | |
--api-key ${{ secrets.GITHUB_TOKEN }} | |
--skip-duplicate | |
working-directory: .dotnet |