Skip to content

Add end-to-end testing with Playwright and TypeScript and developer CLI command #556

Add end-to-end testing with Playwright and TypeScript and developer CLI command

Add end-to-end testing with Playwright and TypeScript and developer CLI command #556

Workflow file for this run

name: App Gateway
on:
push:
branches:
- main
paths:
- "application/*"
- "application/shared-kernel/**"
- "application/AppGateway/**"
- ".github/workflows/app-gateway.yml"
- ".github/workflows/_deploy-container.yml"
- "!**.md"
pull_request:
paths:
- "application/*"
- "application/shared-kernel/**"
- "application/AppGateway/**"
- ".github/workflows/app-gateway.yml"
- ".github/workflows/_deploy-container.yml"
- "!**.md"
workflow_dispatch:
permissions:
id-token: write
contents: read
jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-24.04
outputs:
version: ${{ steps.generate_version.outputs.version }}
deploy_staging: ${{ steps.determine_deployment.outputs.deploy_staging }}
deploy_production: ${{ steps.determine_deployment.outputs.deploy_production }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Generate Version
id: generate_version
run: |
# Strip leading 0s of Hours and Minutes after midnight
MINUTE=$(printf "%s" $(date +"%-H%M") | sed 's/^0*//')
VERSION=$(date +"%Y.%-m.%-d.")$MINUTE
echo "Generated version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Determine Deployment Conditions
id: determine_deployment
run: |
deploy_staging="${{ github.ref == 'refs/heads/main' && vars.STAGING_CLUSTER_ENABLED == 'true' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'Deploy to Staging')) }}"
echo "deploy_staging=$deploy_staging" >> $GITHUB_OUTPUT
deploy_production="${{ github.ref == 'refs/heads/main' && vars.PRODUCTION_CLUSTER1_ENABLED == 'true' }}"
echo "deploy_production=$deploy_production" >> $GITHUB_OUTPUT
- name: Setup Node.js Environment
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Node Modules
working-directory: application
run: npm ci
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v4
with:
global-json-file: application/global.json
- name: Restore .NET Tools
working-directory: application
run: dotnet tool restore
- name: Restore .NET Dependencies
working-directory: application
run: dotnet restore
- name: Build Backend Solution
if: ${{ steps.determine_deployment.outputs.deploy_staging == 'true' }}
working-directory: application
run: |
dotnet build PlatformPlatform.slnx --no-restore /p:Version=${{ steps.generate_version.outputs.version }}
- name: Publish Build
if: ${{ steps.determine_deployment.outputs.deploy_staging == 'true' }}
working-directory: application
run: |
dotnet publish ./AppGateway/AppGateway.csproj --no-restore --configuration Release --output ./AppGateway/publish /p:Version=${{ steps.generate_version.outputs.version }}
- name: Save Artifacts
if: ${{ steps.determine_deployment.outputs.deploy_staging == 'true' }}
uses: actions/upload-artifact@v4
with:
name: app-gateway
path: application/AppGateway/publish/**/*
code-style-and-linting:
name: Code Style and Linting
if: github.event_name == 'pull_request'
runs-on: ubuntu-24.04
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Node.js Environment
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Node Modules
working-directory: application
run: npm ci
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Restore .NET Tools
working-directory: application
run: dotnet tool restore
- name: Restore .NET Dependencies
working-directory: application
run: dotnet restore
- name: Build Backend Solution
working-directory: application
run: dotnet build PlatformPlatform.slnx --no-restore
- name: Run Code Inspections
working-directory: developer-cli
run: |
dotnet run inspect --backend | tee inspection-output.log
if ! grep -q "No backend issues found!" inspection-output.log; then
echo "Code inspection issues found."
exit 1
fi
- name: Check for Code Formatting Issues
working-directory: developer-cli
run: |
dotnet run format --backend
# Check for any changes made by the code formatter
git diff --exit-code || {
echo "Formatting issues detected. Please run 'dotnet run format --backend' from /developer-cli folder locally and commit the formatted code."
exit 1
}
api-stage:
name: Staging
if: ${{ needs.build-and-test.outputs.deploy_staging == 'true' }}
needs: build-and-test
uses: ./.github/workflows/_deploy-container.yml
secrets: inherit
with:
image_name: app-gateway
version: ${{ needs.build-and-test.outputs.version }}
artifacts_name: app-gateway
artifacts_path: application/AppGateway/publish
docker_context: ./application
docker_file: ./AppGateway/Dockerfile
azure_environment: "stage"
cluster_location_acronym: ${{ vars.STAGING_CLUSTER_LOCATION_ACRONYM }}
service_principal_id: ${{ vars.STAGING_SERVICE_PRINCIPAL_ID }}
subscription_id: ${{ vars.STAGING_SUBSCRIPTION_ID }}
api-prod1:
name: Production
if: ${{ needs.build-and-test.outputs.deploy_production == 'true' }}
needs: [build-and-test, api-stage]
uses: ./.github/workflows/_deploy-container.yml
secrets: inherit
with:
image_name: app-gateway
version: ${{ needs.build-and-test.outputs.version }}
artifacts_name: app-gateway
artifacts_path: application/AppGateway/publish
docker_context: ./application
docker_file: ./AppGateway/Dockerfile
azure_environment: "prod"
cluster_location_acronym: ${{ vars.PRODUCTION_CLUSTER1_LOCATION_ACRONYM }}
service_principal_id: ${{ vars.PRODUCTION_SERVICE_PRINCIPAL_ID }}
subscription_id: ${{ vars.PRODUCTION_SUBSCRIPTION_ID }}