[DMS-639] Add audit data to dmscs tables
#135
This file contains hidden or 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
| # SPDX-License-Identifier: Apache-2.0 | |
| # Licensed to the Ed-Fi Alliance under one or more agreements. | |
| # The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. | |
| # See the LICENSE and NOTICES files in the project root for more information. | |
| name: Scheduled Smoke Test | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "30 8 * * 6" # Scheduled the job to run every Saturday at 8 AM UTC | |
| pull_request: | |
| paths: # Only run on PRs that change relevant files | |
| - 'src/Directory.Packages.props' | |
| - '**/OpenApiDocument.cs' | |
| permissions: | |
| contents: write | |
| actions: read | |
| id-token: write | |
| jobs: | |
| build-populated-template: | |
| name: Build Populated Template Package | |
| uses: ./.github/workflows/build-populated-template.yml | |
| with: | |
| standard_version: "5.2.0" | |
| package_name: "EdFi.Dms.Populated.Template.PostgreSQL.5.2.0" | |
| manifest_file: "_manifest/spdx_2.2/manifest.spdx.json" | |
| provenance_file: "populated.template.intoto.jsonl" | |
| secrets: | |
| AZURE_ARTIFACTS_PERSONAL_ACCESS_TOKEN: ${{ secrets.AZURE_ARTIFACTS_PERSONAL_ACCESS_TOKEN }} | |
| smoke-test: | |
| name: Smoke Tests | |
| needs: build-populated-template | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| shell: pwsh | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@87b7050bc53ea08284295505d98d2aa94301e852 # v4.2 | |
| with: | |
| dotnet-version: "8.0.x" | |
| - name: Cache NuGet packages | |
| uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2 | |
| with: | |
| path: ~/.nuget/packages | |
| key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nuget- | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0 | |
| - name: Cache Docker layers | |
| uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2 | |
| with: | |
| path: /tmp/.buildx-cache | |
| key: ${{ runner.os }}-buildx-${{ hashFiles('src/Directory.Packages.props', 'src/dms/Dockerfile', 'src/dms/**') }} | |
| restore-keys: | | |
| ${{ runner.os }}-buildx- | |
| - name: Build DMS | |
| run: ./build-dms.ps1 Build -Configuration Release | |
| - name: Build DMS Docker image | |
| uses: docker/build-push-action@b32b51a8eda65d6793cd0494a773d4f6bcef32dc # v6.11.0 | |
| with: | |
| load: true | |
| context: ./src/dms | |
| file: ./src/dms/Dockerfile | |
| build-contexts: | | |
| parentdir=./src | |
| push: false | |
| tags: dms-local-dms:latest | |
| cache-from: type=local,src=/tmp/.buildx-cache | |
| cache-to: type=local,dest=/tmp/.buildx-cache | |
| - name: Start DMS with Core, TPDM, Sample, and Homograph Extensions (SmokeTest) | |
| run: ./build-dms.ps1 StartEnvironment -SkipDockerBuild -LoadSeedData -EnvironmentFile "./.env.example" | |
| - name: Wait for services to be ready | |
| run: | | |
| Write-Host "Waiting for DMS to be ready..." | |
| $maxAttempts = 30 | |
| $attempt = 0 | |
| do { | |
| Start-Sleep -Seconds 10 | |
| try { | |
| $response = Invoke-RestMethod -Uri "http://localhost:8080/health" -Method Get -TimeoutSec 5 | |
| if ($response) { | |
| Write-Host "DMS is ready!" | |
| break | |
| } | |
| } | |
| catch { | |
| Write-Host "Attempt $($attempt + 1): DMS not ready yet..." | |
| } | |
| $attempt++ | |
| } while ($attempt -lt $maxAttempts) | |
| if ($attempt -eq $maxAttempts) { | |
| Write-Error "DMS failed to start within expected time" | |
| exit 1 | |
| } | |
| - name: Create Smoke Test Credentials | |
| run: | | |
| Import-Module ./modules/SmokeTest.psm1 -Force | |
| $credentials = Get-SmokeTestCredentials -ConfigServiceUrl "http://localhost:8081" | |
| # Store credentials in environment variables for subsequent steps | |
| "SMOKE_TEST_KEY=$($credentials.Key)" | Out-File -FilePath $env:GITHUB_ENV -Append | |
| "SMOKE_TEST_SECRET=$($credentials.Secret)" | Out-File -FilePath $env:GITHUB_ENV -Append | |
| Write-Host "Smoke test credentials created successfully" | |
| working-directory: eng/smoke_test/ | |
| - name: Generate SDK for Smoke Tests | |
| run: | | |
| ./build-sdk.ps1 BuildAndGenerateSdk -DmsUrl "http://localhost:8080" -PackageName "EdFi.DmsApi.TestSdk" | |
| - name: Verify SDK Generation | |
| run: | | |
| Write-Host "Checking SDK generation results..." | |
| $sdkPath = "${{ github.workspace }}/eng/sdkGen/csharp/src/EdFi.DmsApi.TestSdk/bin/Release/net8.0/EdFi.DmsApi.TestSdk.dll" | |
| Write-Host "Expected SDK path: $sdkPath" | |
| if (Test-Path $sdkPath) { | |
| Write-Host "✅ SDK DLL found at expected location" | |
| $fileInfo = Get-Item $sdkPath | |
| Write-Host "File size: $($fileInfo.Length) bytes" | |
| Write-Host "Last modified: $($fileInfo.LastWriteTime)" | |
| } else { | |
| Write-Host "❌ SDK DLL not found at expected location" | |
| Write-Host "Listing contents of SDK generation directory:" | |
| if (Test-Path "${{ github.workspace }}/eng/sdkGen") { | |
| Get-ChildItem -Path "${{ github.workspace }}/eng/sdkGen" -Recurse | Where-Object { $_.Name -like "*.dll" } | ForEach-Object { | |
| Write-Host "Found DLL: $($_.FullName)" | |
| } | |
| } else { | |
| Write-Host "sdkGen directory not found" | |
| } | |
| exit 1 | |
| } | |
| - name: Run NonDestructive API Tests | |
| run: | | |
| ./Invoke-NonDestructiveApiTests.ps1 -BaseUrl "http://localhost:8080" -Key "$env:SMOKE_TEST_KEY" -Secret "$env:SMOKE_TEST_SECRET" | |
| working-directory: eng/smoke_test/ | |
| - name: Run NonDestructive DMS SDK Tests | |
| run: | | |
| ./Invoke-NonDestructiveSdkTests.ps1 -BaseUrl "http://localhost:8080" -Key "$env:SMOKE_TEST_KEY" -Secret "$env:SMOKE_TEST_SECRET" -SdkPath "${{ github.workspace }}/eng/sdkGen/csharp/src/EdFi.DmsApi.TestSdk/bin/Release/net8.0/EdFi.DmsApi.TestSdk.dll" | |
| working-directory: eng/smoke_test/ | |
| - name: Run Destructive DMS SDK Tests | |
| run: | | |
| ./Invoke-DestructiveSdkTests.ps1 -BaseUrl "http://localhost:8080" -Key "$env:SMOKE_TEST_KEY" -Secret "$env:SMOKE_TEST_SECRET" -SdkPath "${{ github.workspace }}/eng/sdkGen/csharp/src/EdFi.DmsApi.TestSdk/bin/Release/net8.0/EdFi.DmsApi.TestSdk.dll" | |
| working-directory: eng/smoke_test/ | |
| - name: Run NonDestructive ODS SDK Tests | |
| run: | | |
| ./Invoke-NonDestructiveSdkTests.ps1 -BaseUrl "http://localhost:8080" -Key "$env:SMOKE_TEST_KEY" -Secret "$env:SMOKE_TEST_SECRET" -SdkNamespace "EdFi.OdsApi.Sdk" | |
| working-directory: eng/smoke_test/ | |
| - name: Run Destructive ODS SDK Tests | |
| run: | | |
| ./Invoke-DestructiveSdkTests.ps1 -BaseUrl "http://localhost:8080" -Key "$env:SMOKE_TEST_KEY" -Secret "$env:SMOKE_TEST_SECRET" -SdkNamespace "EdFi.OdsApi.Sdk" | |
| working-directory: eng/smoke_test/ | |
| - name: Export Docker Logs on Failure | |
| if: failure() | |
| run: | | |
| $logDir = "${{ github.workspace }}/logs" | |
| New-Item -ItemType Directory -Path $logDir -Force | Out-Null | |
| docker ps --format "{{.Names}}" | ForEach-Object { | |
| $container = $_ | |
| $logPath = Join-Path $logDir "$container.log" | |
| Write-Host "Exporting logs for container: $container" | |
| docker logs $container > $logPath 2>&1 | |
| } | |
| - name: Upload Docker Logs | |
| if: failure() | |
| uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5 | |
| with: | |
| name: Smoke-Tests-Docker-Logs | |
| path: ${{ github.workspace }}/logs | |
| retention-days: 10 | |
| notify-results: | |
| name: Notify Results | |
| runs-on: ubuntu-latest | |
| needs: [smoke-test] | |
| if: always() && github.event_name != 'workflow_dispatch' && github.event_name != 'pull_request' | |
| steps: | |
| - name: Notify Slack on success | |
| if: ${{ needs.smoke-test.result == 'success' }} | |
| uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0 | |
| with: | |
| payload: | | |
| { | |
| "text": "✅ Scheduled smoke tests passed successfully!", | |
| "blocks": [ | |
| { | |
| "type": "section", | |
| "text": { | |
| "type": "mrkdwn", | |
| "text": "✅ *Scheduled Smoke Tests - SUCCESS*\n*Repository:* ${{ github.repository }}\n*Branch:* ${{ github.ref }}\n*Tests Run:* DMS NonDestructiveAPI, DMS NonDestructiveSDK, DMS DestructiveSDK, ODS NonDestructiveSDK, ODS DestructiveSDK\n*Extensions:* Core, TPDM, Sample, Homograph\n*Log URL:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
| } | |
| } | |
| ] | |
| } | |
| webhook: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| webhook-type: incoming-webhook | |
| - name: Notify Slack on failure | |
| if: ${{ needs.smoke-test.result == 'failure' }} | |
| uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0 | |
| with: | |
| payload: | | |
| { | |
| "text": "❌ Scheduled smoke tests failed!", | |
| "blocks": [ | |
| { | |
| "type": "section", | |
| "text": { | |
| "type": "mrkdwn", | |
| "text": "❌ *Scheduled Smoke Tests - FAILURE*\n*Repository:* ${{ github.repository }}\n*Branch:* ${{ github.ref }}\n*Tests:* NonDestructiveAPI, NonDestructiveSDK, DestructiveSDK\n*Extensions:* Core, TPDM, Sample, Homograph\n*Log URL:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
| } | |
| } | |
| ] | |
| } | |
| webhook: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| webhook-type: incoming-webhook |