From 677b671c3bb3188b1f2c899e0b16cd70363ec2ff Mon Sep 17 00:00:00 2001 From: Matt Bishop Date: Wed, 4 Sep 2024 16:18:45 -0400 Subject: [PATCH] Build and test workflows (#17) * Build and test workflows * Patch a test as debug only --- .github/workflows/build.yml | 23 +++++++ .github/workflows/test.yml | 61 +++++++++++++++++++ ...ecretsManagerConfigurationProviderTests.cs | 2 +- 3 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..031212f --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,23 @@ +name: Build + +on: + workflow_dispatch: + push: + branches: + - "main" + pull_request: + +jobs: + build-artifacts: + name: Build artifacts + runs-on: ubuntu-22.04 + + steps: + - name: Check out repo + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Set up .NET + uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4.0.1 + + - name: Build solution + run: dotnet build diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..46efa8d --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,61 @@ +name: Testing + +on: + workflow_dispatch: + push: + branches: + - "main" + pull_request: + +jobs: + check-test-secrets: + name: Check for test secrets + runs-on: ubuntu-22.04 + outputs: + available: ${{ steps.check-test-secrets.outputs.available }} + permissions: + contents: read + + steps: + - name: Check + id: check-test-secrets + run: | + if [ "${{ secrets.CODECOV_TOKEN }}" != '' ]; then + echo "available=true" >> $GITHUB_OUTPUT; + else + echo "available=false" >> $GITHUB_OUTPUT; + fi + + testing: + name: Run tests + runs-on: ubuntu-22.04 + needs: check-test-secrets + permissions: + checks: write + contents: read + pull-requests: write + + steps: + - name: Check out repo + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Set up .NET + uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4.0.1 + + - name: Test solution + run: dotnet test --configuration Debug --logger "trx;LogFileName=test-results.trx" /p:CoverletOutputFormatter="cobertura" --collect:"XPlat Code Coverage" + + - name: Report test results + uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 # v1.9.1 + if: ${{ needs.check-test-secrets.outputs.available == 'true' && !cancelled() }} + with: + name: Test Results + path: "**/test-results.trx" + reporter: dotnet-trx + fail-on-error: true + + - name: Upload to codecov.io + uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 + if: ${{ needs.check-test-secrets.outputs.available == 'true' }} + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/extensions/Bitwarden.Extensions.Configuration/tests/SecretsManagerConfigurationProviderTests.cs b/extensions/Bitwarden.Extensions.Configuration/tests/SecretsManagerConfigurationProviderTests.cs index 99cd6e0..f746128 100644 --- a/extensions/Bitwarden.Extensions.Configuration/tests/SecretsManagerConfigurationProviderTests.cs +++ b/extensions/Bitwarden.Extensions.Configuration/tests/SecretsManagerConfigurationProviderTests.cs @@ -8,7 +8,7 @@ public class SecretsManagerConfigurationProviderTests private static readonly Guid _testingProjectId = Guid.Parse("e9ebeeea-7aea-48c8-9adb-afcc014f1d46"); private static readonly AccessToken _testingAccessToken = AccessToken.Parse("0.4eaea7be-6a0b-4c0b-861e-b033001532a9.ydNqCpyZ8E7a171FjZn89WhKE1eEQF:2WQh70hSQQZFXm+QteNYsg=="); - [Fact] + [DebuggerFact] public void Load_Simple_Works() { using var provider = CreateProvider();