Run unit and ui tests, deploy samplesite #435
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: Run unit and ui tests, deploy samplesite | |
on: | |
workflow_run: | |
workflows: ["Dev", "Uat"] | |
types: | |
- completed | |
env: | |
dotnetVersion: | | |
6.x | |
8.x | |
jobs: | |
test-unit-ui: | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
runs-on: ubuntu-latest | |
environment: ${{ github.event.workflow_run.name }} | |
outputs: | |
sourceHeadRepo: ${{ steps.source-run-info.outputs.sourceHeadRepo }} | |
sourceHeadBranch: ${{ steps.source-run-info.outputs.sourceHeadBranch }} | |
sourceHeadSha: ${{ steps.source-run-info.outputs.sourceHeadSha }} | |
mergeCommitSha: ${{ steps.source-run-info.outputs.mergeCommitSha }} | |
targetCommitSha: ${{ steps.source-run-info.outputs.targetCommitSha }} | |
pullRequestNumber: ${{ steps.source-run-info.outputs.pullRequestNumber }} | |
pullRequestLabels: ${{ steps.source-run-info.outputs.pullRequestLabels }} | |
targetBranch: ${{ steps.source-run-info.outputs.targetBranch }} | |
sourceEvent: ${{ steps.source-run-info.outputs.sourceEvent }} | |
steps: | |
- name: "Get information about the origin 'CI' run" | |
uses: potiuk/get-workflow-origin@v1_1 | |
id: source-run-info | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
sourceRunId: ${{ github.event.workflow_run.id }} | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.dotnetVersion }} | |
- name: Run SDK Integration Tests | |
run: | | |
export SwedbankPay__PayeeId=${{ secrets.MERCHANT_PAYEEID }} | |
export SwedbankPay__Token=${{ secrets.MERCHANT_TOKEN }} | |
dotnet test ./src/SwedbankPay.Sdk.IntegrationTests/SwedbankPay.Sdk.IntegrationTests.csproj | |
- name: Run SDK Unit Tests | |
run: | | |
export SwedbankPay__PayeeId=${{ secrets.MERCHANT_PAYEEID }} | |
export SwedbankPay__Token=${{ secrets.MERCHANT_TOKEN }} | |
dotnet test ./src/SwedbankPay.Sdk.Tests/SwedbankPay.Sdk.Tests.csproj | |
- name: Cypress run | |
uses: cypress-io/github-action@v6 | |
with: | |
working-directory: ./src/Samples/Sample.AspNetCore.UiTests | |
start: dotnet run --project ../Sample.AspNetCore/Sample.AspNetCore.csproj --urls https://localhost:5001 --SwedbankPay:PayeeId ${{ secrets.MERCHANT_PAYEEID }} --SwedbankPay:Token ${{ secrets.MERCHANT_TOKEN }} | |
wait-on: 'https://localhost:5001' | |
browser: chrome | |
env: | |
NODE_TLS_REJECT_UNAUTHORIZED: 0 | |
- name: Upload Cypress artifact | |
uses: actions/upload-artifact@v4 | |
if: ${{ always() }} | |
with: | |
name: cypress-screenshots | |
path: ./src/Samples/Sample.AspNetCore.UiTests/cypress/screenshots | |
if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn` | |
- name: Commit Action Status | |
if: ${{ always() }} | |
uses: LouisBrunner/[email protected] | |
with: | |
sha: ${{ steps.source-run-info.outputs.sourceHeadSha }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: Run Unit and UI tests | |
conclusion: ${{ job.status }} | |
publish_alpha_nuget: | |
needs: [test-unit-ui] | |
if: ${{ needs.test-unit-ui.outputs.sourceEvent != 'pull_request' && github.event.workflow_run.name == 'Dev' }} | |
name: Publish alpha nuget | |
runs-on: ubuntu-latest | |
environment: ${{ github.event.workflow_run.name }} | |
steps: | |
- name: Download artifact | |
id: download-artifact | |
uses: dawidd6/action-download-artifact@v3 | |
with: | |
workflow_conclusion: success | |
run_id: ${{ github.event.workflow_run.id }} | |
name: packages | |
path: packages | |
- name: Publish test package to GitHub Package Registry | |
run: dotnet nuget push "packages/*.nupkg" --api-key ${{secrets.GITHUB_TOKEN}} --source https://nuget.pkg.github.com/swedbankpay/index.json --skip-duplicate | |
publish_sample_site: | |
needs: [test-unit-ui] | |
if: ${{ needs.test-unit-ui.outputs.sourceEvent != 'pull_request' }} | |
uses: ./.github/workflows/template_publish_webapp.yml | |
secrets: inherit | |
with: | |
Environment: ${{ github.event.workflow_run.name }} | |
WorkflowRunId: ${{ github.event.workflow_run.id }} |