From de52841f06c5fb69a6afa9813d8c17a7c845b5f0 Mon Sep 17 00:00:00 2001 From: katie-gardner-AND Date: Tue, 26 Nov 2024 12:01:22 +0000 Subject: [PATCH] feat: Add qa-visualiser to github workflows --- .../azure-get-db-connectionstring/action.yml | 26 ------ .../azure-get-keyvault-secret/action.yml | 26 ++++++ .../action.yml | 20 ++-- .github/scripts/qa-data.py | 65 ------------- .github/scripts/qa-visualisations.py | 67 -------------- .github/workflows/clear-user-data-from-db.yml | 6 +- .github/workflows/deploy-image.yml | 8 +- .github/workflows/e2e-tests.yml | 6 +- .github/workflows/qa-viz.yml | 91 +++++++++++-------- 9 files changed, 98 insertions(+), 217 deletions(-) delete mode 100644 .github/actions/azure-get-db-connectionstring/action.yml create mode 100644 .github/actions/azure-get-keyvault-secret/action.yml delete mode 100644 .github/scripts/qa-data.py delete mode 100644 .github/scripts/qa-visualisations.py diff --git a/.github/actions/azure-get-db-connectionstring/action.yml b/.github/actions/azure-get-db-connectionstring/action.yml deleted file mode 100644 index b5321e40d..000000000 --- a/.github/actions/azure-get-db-connectionstring/action.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Get DB connection string -description: Gets DB connection string from Azure Keyvault - -inputs: - az_keyvault_database_connectionstring_name: - required: true - type: string - az_keyvault_name: - required: true - type: string - -outputs: - connection_string: - description: DB connection string - value: ${{ steps.get-connection-string.outputs.connection_string }} - -runs: - using: composite - steps: - - name: Get connection string - id: get-connection-string - shell: bash - run: | - connection_string=$(az keyvault secret show --name ${{ inputs.az_keyvault_database_connectionstring_name }} --vault-name ${{ inputs.az_keyvault_name }} --query value -o tsv) - echo "::add-mask::$connection_string" - echo "connection_string=$connection_string" >> $GITHUB_OUTPUT \ No newline at end of file diff --git a/.github/actions/azure-get-keyvault-secret/action.yml b/.github/actions/azure-get-keyvault-secret/action.yml new file mode 100644 index 000000000..505c643c2 --- /dev/null +++ b/.github/actions/azure-get-keyvault-secret/action.yml @@ -0,0 +1,26 @@ +name: Get Keyvault secret +description: Gets a secret from the Azure Keyvault + +inputs: + az_keyvault_secret_name: + required: true + type: string + az_keyvault_name: + required: true + type: string + +outputs: + secret_value: + description: Value of secret from the keyvault + value: ${{ steps.get-secret.outputs.secret_value }} + +runs: + using: composite + steps: + - name: Get secret + id: get-secret + shell: bash + run: | + secret_value=$(az keyvault secret show --name ${{ inputs.az_keyvault_secret_name }} --vault-name ${{ inputs.az_keyvault_name }} --query value -o tsv) + echo "::add-mask::$secret_value" + echo "secret_value=$secret_value" >> $GITHUB_OUTPUT diff --git a/.github/actions/build-and-run-database-upgrader/action.yml b/.github/actions/build-and-run-database-upgrader/action.yml index c5077789f..4f375d6c4 100644 --- a/.github/actions/build-and-run-database-upgrader/action.yml +++ b/.github/actions/build-and-run-database-upgrader/action.yml @@ -7,16 +7,16 @@ inputs: type: string az_keyvault_name: required: true - type: string + type: string az_keyvault_database_connectionstring_name: required: true - type: string + type: string az_sql_database_server_name: required: true - type: string + type: string az_resource_group_name: required: true - type: string + type: string environment: required: true type: string @@ -30,16 +30,16 @@ inputs: runs: using: composite steps: - - name: Build database upgrader + - name: Build database upgrader uses: ./.github/actions/build-dotnet-app with: - dotnet_version: ${{ inputs.dotnet_version }} + dotnet_version: ${{ inputs.dotnet_version }} solution_filename: Dfe.PlanTech.DatabaseUpgrader.sln - name: Get workflow IP address id: whats-my-ip uses: ./.github/actions/whats-my-ip-address - + - name: Add Azure firewall rules shell: bash run: | @@ -48,14 +48,14 @@ runs: - name: Get connection string id: get-db-connection-string - uses: ./.github/actions/azure-get-db-connectionstring + uses: ./.github/actions/azure-get-keyvault-secret with: az_keyvault_name: ${{ inputs.az_keyvault_name }} - az_keyvault_database_connectionstring_name: ${{ inputs.az_keyvault_database_connectionstring_name }} + az_keyvault_secret_name: ${{ inputs.az_keyvault_database_connectionstring_name }} - name: Run database upgrader shell: bash - run: dotnet ./build/Dfe.PlanTech.DatabaseUpgrader.dll -c "${{ steps.get-db-connection-string.outputs.connection_string }}" --env ${{ inputs.environment }} -p Analytics_Username=${{ inputs.sql_analytics_username }} Analytics_Password=${{ inputs.sql_analytics_password }} + run: dotnet ./build/Dfe.PlanTech.DatabaseUpgrader.dll -c "${{ steps.get-db-connection-string.outputs.secret_value }}" --env ${{ inputs.environment }} -p Analytics_Username=${{ inputs.sql_analytics_username }} Analytics_Password=${{ inputs.sql_analytics_password }} - name: Remove Azure firewall rules shell: bash diff --git a/.github/scripts/qa-data.py b/.github/scripts/qa-data.py deleted file mode 100644 index 1bf9e6c57..000000000 --- a/.github/scripts/qa-data.py +++ /dev/null @@ -1,65 +0,0 @@ -import os -import pyodbc -import json -import struct -from azure import identity - -def query_to_json(connection_string, sql_query): - - if os.getenv("ENV") != "dev": - credential = identity.DefaultAzureCredential(exclude_interactive_browser_credential=True) - token_bytes = credential.get_token("https://database.windows.net/.default").token.encode("UTF-16-LE") - token_struct = struct.pack(f'