Skip to content

Remove prometheus metrics endpoint #1027

Remove prometheus metrics endpoint

Remove prometheus metrics endpoint #1027

Workflow file for this run

name: Pull request build
on:
pull_request:
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false # temporary - can corrupt PAAS Terraform state if deployments are cancelled
permissions:
checks: write
deployments: write
packages: write
pull-requests: write
jobs:
build:
name: Build & test
runs-on: ubuntu-latest
outputs:
run_crm_integration_tests: ${{ steps.check_changed_files.outputs.run_crm_integration_tests }}
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: trs
POSTGRES_DB: trs
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: extractions/setup-just@v1
- name: Install tools
run: just install-tools
- name: Restore
run: dotnet restore
working-directory: TeachingRecordSystem
- name: Lint
run: |
git fetch origin main --quiet --depth=1
CHANGED_FILES=$(git diff --name-only origin/main $GITHUB_SHA | { grep -oP '^TeachingRecordSystem\/\K.*\.cs$' || true; })
if [ "$CHANGED_FILES" == "" ]; then
echo "::notice::No changes to lint"
exit 0
fi
INCLUDE_ARG="--include $(echo "$CHANGED_FILES" | tr '\n' ' ')"
echo "::notice::Linting changed files only"
dotnet format --no-restore --verify-no-changes $INCLUDE_ARG
working-directory: TeachingRecordSystem
- name: Build
run: dotnet build --configuration Release --no-restore
working-directory: TeachingRecordSystem
- name: Check changed files
id: check_changed_files
run: |
# If no CRM integration files (or their tests) have been changed in this PR then skip CRM integration tests
RUN_CRM_INTEGRATION_TESTS=true
git fetch origin main --quiet --depth=1
CHANGED_FILES=$(git diff --name-only origin/main $GITHUB_SHA)
if [[ $(echo "$CHANGED_FILES" | grep -EL "TeachingRecordSystem.Core.Dqt") ]]; then
RUN_CRM_INTEGRATION_TESTS=false
fi
echo run_crm_integration_tests=$RUN_CRM_INTEGRATION_TESTS >> $GITHUB_OUTPUT
shell: bash
- name: Core tests
uses: ./.github/workflows/actions/test
with:
test_project_path: TeachingRecordSystem/tests/TeachingRecordSystem.Core.Tests
report_name: "Core test results"
dotnet_test_args: >-
--no-build
-e ConnectionStrings__DefaultConnection="Host=localhost;Username=postgres;Password=trs;Database=trs"
- name: API Tests
uses: ./.github/workflows/actions/test
with:
test_project_path: TeachingRecordSystem/tests/TeachingRecordSystem.Api.Tests
report_name: "API test results"
dotnet_test_args: >-
--no-build
-e ConnectionStrings__DefaultConnection="Host=localhost;Username=postgres;Password=trs;Database=trs"
- name: Support UI Tests
uses: ./.github/workflows/actions/test
with:
test_project_path: TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests
report_name: "Support UI test results"
dotnet_test_args: >-
--no-build
-e ConnectionStrings__DefaultConnection="Host=localhost;Username=postgres;Password=trs;Database=trs"
- name: Install Playwright
run: pwsh ./tests/TeachingRecordSystem.SupportUi.EndToEndTests/bin/Release/net7.0/playwright.ps1 install
working-directory: TeachingRecordSystem
- name: Support UI end-to-end tests
uses: ./.github/workflows/actions/test
with:
test_project_path: TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.EndToEndTests
report_name: "Support UI end-to-end test results"
dotnet_test_args: >-
--no-build
-e ConnectionStrings__DefaultConnection="Host=localhost;Username=postgres;Password=trs;Database=trs"
validate_terraform:
name: Validate Terraform
runs-on: ubuntu-latest
strategy:
matrix:
platform: [paas, aks]
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.5.0
- name: Check formatting
run: terraform fmt -check -diff
working-directory: terraform/${{ matrix.platform }}
- name: Validate
run: |
terraform init -backend=false
terraform validate -no-color
working-directory: terraform/${{ matrix.platform }}
- name: Lint
uses: reviewdog/action-tflint@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tflint_rulesets: azurerm
working_directory: terraform/${{ matrix.platform }}
continue-on-error: true # temporary- we're getting sporadic 503 errors here in action setup
dqt_tests:
name: DQT tests
runs-on: ubuntu-latest
needs: [build]
if: ${{ needs.build.outputs.run_crm_integration_tests == 'true' }}
env:
MSSQL_DB: dqtreports
MSSQL_PASSWORD: SuperS3cretPassw0rd
services:
mssql:
image: mcr.microsoft.com/mssql/server:2022-latest
env:
ACCEPT_EULA: Y
SA_PASSWORD: ${{ env.MSSQL_PASSWORD }}
ports:
- 1433:1433
options: >-
--health-cmd "/opt/mssql-tools/bin/sqlcmd -U sa -P $SA_PASSWORD -Q 'select 1' -b -o /dev/null"
--health-interval 60s
--health-timeout 30s
--health-start-period 20s
--health-retries 3
steps:
- uses: actions/checkout@v4
- uses: extractions/setup-just@v1
- uses: Azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- uses: Azure/get-keyvault-secrets@v1
name: Get secrets
id: get_secrets
with:
keyvault: s165d01-dqtapi-dv-kv
secrets: INTEGRATION-TEST-CONFIG
- name: Install tools
run: just install-tools
- name: Create test reporting database
run: docker exec $(docker ps --latest --quiet) /opt/mssql-tools/bin/sqlcmd -U "sa" -P "$MSSQL_PASSWORD" -Q "create database $MSSQL_DB; alter database $MSSQL_DB set ALLOW_SNAPSHOT_ISOLATION on;"
- name: Build
run: dotnet build --configuration Release
working-directory: TeachingRecordSystem/tests/TeachingRecordSystem.Core.Dqt.Tests
- name: Run tests
uses: ./.github/workflows/actions/test
with:
test_project_path: TeachingRecordSystem/tests/TeachingRecordSystem.Core.Dqt.Tests
report_name: "DQT test results"
dotnet_test_args: >-
--no-build
-e DqtReporting__ReportingDbConnectionString="Data Source=(local); Initial Catalog=${{ env.MSSQL_DB }}; User=sa; Password=${{ env.MSSQL_PASSWORD }}; TrustServerCertificate=True"
config_json: ${{ steps.get_secrets.outputs.INTEGRATION-TEST-CONFIG }}
package:
name: Package application
needs: [build, validate_terraform]
uses: ./.github/workflows/package.yml
secrets: inherit
deploy_dev:
name: Deploy dev environment
needs: package
uses: ./.github/workflows/deploy-dev.yml
with:
api_docker_image: ${{ needs.package.outputs.api_docker_image }}
cli_docker_image: ${{ needs.package.outputs.cli_docker_image }}
ui_docker_image: ${{ needs.package.outputs.ui_docker_image }}
secrets: inherit