Run unit and ui tests, deploy samplesite #242
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 | |
7.x | |
jobs: | |
test-unit-ui: | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
runs-on: ubuntu-latest | |
environment: ${{ github.event.workflow_run.name }} | |
env: | |
uitestUrlSubdomain: uitest-${{ github.event.workflow_run.id }}-svea-webpay-sdk | |
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 }} | |
- name: Download artifact | |
id: download-artifact | |
uses: dawidd6/action-download-artifact@v2 | |
with: | |
workflow_conclusion: success | |
run_id: ${{ github.event.workflow_run.id }} | |
- name: Variable Substitution | |
uses: microsoft/variable-substitution@v1 | |
with: | |
# comma separated list of XML/JSON/YAML files in which tokens are to be substituted. Files names must be specified relative to the folder-path. | |
files: 'Sample.AspNetCore/ngrok.yml' | |
env: | |
authtoken: ${{ secrets.NGROK_AUTHTOKEN }} | |
tunnels.uitestGithub.subdomain: ${{ env.uitestUrlSubdomain }} | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: ${{ env.dotnetVersion }} | |
- name: Run Unit Tests | |
run: dotnet test Sdk.UnitTests/Svea.WebPay.SDK.Tests.dll | |
env: | |
Credentials:0:MerchantId: ${{ secrets.SWEDEN_MERCHANT_ID}} | |
Credentials:0:Secret: ${{ secrets.SWEDEN_MERCHANT_SECRET }} | |
Credentials:1:MerchantId: ${{ secrets.NORWAY_MERCHANT_ID}} | |
Credentials:1:Secret: ${{ secrets.NORWAY_MERCHANT_SECRET }} | |
Credentials:2:MerchantId: ${{ secrets.FINNISH_MERCHANT_ID }} | |
Credentials:2:Secret: ${{ secrets.FINNISH_MERCHANT_SECRET }} | |
# - name: Setup ngrok | |
# run: | | |
# wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip | |
# jar xvf ngrok-stable-linux-amd64.zip | |
# chmod +x ngrok | |
# | |
# - name: Start ngrok | |
# run: ./ngrok start -config Sample.AspNetCore/ngrok.yml uitestGithub & | |
# | |
# - name: Start SDK Sample project | |
# working-directory: Sample.AspNetCore | |
# run: | |
# dotnet Sample.AspNetCore.dll & | |
# env: | |
# Credentials:0:MerchantId: ${{ secrets.SWEDEN_MERCHANT_ID}} | |
# Credentials:0:Secret: ${{ secrets.SWEDEN_MERCHANT_SECRET }} | |
# Credentials:1:MerchantId: ${{ secrets.NORWAY_MERCHANT_ID}} | |
# Credentials:1:Secret: ${{ secrets.NORWAY_MERCHANT_SECRET }} | |
# Credentials:2:MerchantId: ${{ secrets.FINNISH_MERCHANT_ID }} | |
# Credentials:2:Secret: ${{ secrets.FINNISH_MERCHANT_SECRET }} | |
# MerchantSettings:PushUri: https://${{ env.uitestUrlSubdomain }}.eu.ngrok.io/api/svea/push/{checkout.order.uri}/?marketId={marketId} | |
# MerchantSettings:TermsUri: https://${{ env.uitestUrlSubdomain }}.eu.ngrok.io/terms | |
# MerchantSettings:CheckoutUri: https://${{ env.uitestUrlSubdomain }}.eu.ngrok.io/CheckOut/LoadPaymentMenu | |
# MerchantSettings:ConfirmationUri: https://${{ env.uitestUrlSubdomain }}.eu.ngrok.io/checkout/thankyou | |
# MerchantSettings:CheckoutValidationCallbackUri: https://${{ env.uitestUrlSubdomain }}.eu.ngrok.io/api/svea/validation/{checkout.order.uri}/?marketId={marketId} | |
# MerchantSettings:WebhookUri: https://${{ env.uitestUrlSubdomain }}.eu.ngrok.io/api/svea/shippingvalidation/?marketId={marketId} | |
# | |
# - name: Run SDK UI tests | |
# run: dotnet test Sample.AspNetCore.SystemTests/Sample.AspNetCore.SystemTests.dll | |
# env: | |
# Credentials:0:MerchantId: ${{ secrets.SWEDEN_MERCHANT_ID}} | |
# Credentials:0:Secret: ${{ secrets.SWEDEN_MERCHANT_SECRET }} | |
# Credentials:1:MerchantId: ${{ secrets.NORWAY_MERCHANT_ID}} | |
# Credentials:1:Secret: ${{ secrets.NORWAY_MERCHANT_SECRET }} | |
# Credentials:2:MerchantId: ${{ secrets.FINNISH_MERCHANT_ID }} | |
# Credentials:2:Secret: ${{ secrets.FINNISH_MERCHANT_SECRET }} | |
# SampleWebsite:Url: https://localhost:5001 | |
- 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@v2 | |
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/sveawebpay/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 }} |