diff --git a/.github/workflows/copilot-build-backend.yml b/.github/workflows/copilot-build-backend.yml index f8c9f6ad3..389583e27 100644 --- a/.github/workflows/copilot-build-backend.yml +++ b/.github/workflows/copilot-build-backend.yml @@ -1,6 +1,7 @@ name: copilot-build-backend on: + workflow_dispatch: pull_request: branches: ["main"] paths: diff --git a/.github/workflows/copilot-deploy-backend.yml b/.github/workflows/copilot-deploy-backend.yml index 464426bf4..a846ed149 100644 --- a/.github/workflows/copilot-deploy-backend.yml +++ b/.github/workflows/copilot-deploy-backend.yml @@ -19,6 +19,10 @@ on: required: true AZURE_SUBSCRIPTION_ID: required: true + outputs: + backend-host: + description: "Host to which backend is deployed" + value: ${{jobs.webapi.outputs.backend-host}} permissions: contents: read @@ -33,13 +37,12 @@ jobs: matrix: include: - { dotnet: "6.0", configuration: Release, os: ubuntu-latest } + # Map the job output to step output + outputs: + backend-host: ${{steps.app-name.outputs.backend-host}} runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 - with: - clean: true - - uses: actions/download-artifact@v3 with: name: ${{inputs.ARTIFACT_NAME}} @@ -58,9 +61,11 @@ jobs: enable-AzPSSession: false - name: Get app name + id: app-name run: | WEB_APP_NAME=$(az deployment group show --name ${{inputs.DEPLOYMENT_NAME}} --resource-group ${{vars.CC_DEPLOYMENT_GROUP_NAME}} --output json | jq -r '.properties.outputs.webapiName.value') echo "AZURE_WEBAPP_NAME=$WEB_APP_NAME" >> $GITHUB_ENV + echo "backend-host=$WEB_APP_NAME" >> $GITHUB_OUTPUT - name: Enable Run From Package uses: azure/CLI@v1 diff --git a/.github/workflows/copilot-deploy-environment.yml b/.github/workflows/copilot-deploy-environment.yml index 306167a6a..dc721711c 100644 --- a/.github/workflows/copilot-deploy-environment.yml +++ b/.github/workflows/copilot-deploy-environment.yml @@ -18,6 +18,10 @@ on: required: true AZURE_OPENAI_ENDPOINT: required: true + outputs: + backend-host: + description: "Host on which backend runs" + value: ${{jobs.deploy-backend.outputs.backend-host}} permissions: contents: read diff --git a/.github/workflows/copilot-deploy-pipeline.yml b/.github/workflows/copilot-deploy-pipeline.yml index c6e0d2583..b1860b961 100644 --- a/.github/workflows/copilot-deploy-pipeline.yml +++ b/.github/workflows/copilot-deploy-pipeline.yml @@ -29,9 +29,16 @@ jobs: AZURE_SUBSCRIPTION_ID: ${{secrets.AZURE_SUBSCRIPTION_ID}} AZURE_OPENAI_ENDPOINT: ${{secrets.AZURE_OPENAI_ENDPOINT}} + int-tests: + uses: ./.github/workflows/copilot-run-integration-tests.yml + needs: int + with: + ENVIRONMENT: int + BACKEND_HOST: ${{needs.int.outputs.backend-host}} + stable: uses: ./.github/workflows/copilot-deploy-environment.yml - needs: [build, int] + needs: int-tests with: ENVIRONMENT: stable ARTIFACT_NAME: ${{needs.build.outputs.artifact}} diff --git a/.github/workflows/copilot-run-integration-tests.yml b/.github/workflows/copilot-run-integration-tests.yml new file mode 100644 index 000000000..9cf2fa60c --- /dev/null +++ b/.github/workflows/copilot-run-integration-tests.yml @@ -0,0 +1,25 @@ +name: copilot-run-integration-tests + +on: + workflow_call: + inputs: + ENVIRONMENT: + required: true + type: string + BACKEND_HOST: + required: true + type: string + +permissions: + contents: read + +jobs: + tests: + environment: ${{inputs.ENVIRONMENT}} + name: Integration Testing + runs-on: windows-latest + + steps: + - uses: actions/checkout@v3 + - name: Run integration tests + run: dotnet test --environment BaseUrl="https://${{inputs.BACKEND_HOST}}.azurewebsites.net/" --logger trx diff --git a/integration-tests/ChatCopilotIntegrationTest.cs b/integration-tests/ChatCopilotIntegrationTest.cs index 2694e5f60..522c1579d 100644 --- a/integration-tests/ChatCopilotIntegrationTest.cs +++ b/integration-tests/ChatCopilotIntegrationTest.cs @@ -12,7 +12,7 @@ namespace ChatCopilotIntegrationTests; /// public abstract class ChatCopilotIntegrationTest : IDisposable { - protected const string BaseAddressSettingName = "BaseAddress"; + protected const string BaseUrlSettingName = "BaseUrl"; protected readonly HttpClient _httpClient; @@ -26,12 +26,12 @@ protected ChatCopilotIntegrationTest() .AddUserSecrets() .Build(); - string? baseAddress = configuration[BaseAddressSettingName]; - Assert.False(string.IsNullOrEmpty(baseAddress)); - Assert.True(baseAddress.EndsWith('/')); + string? baseUrl = configuration[BaseUrlSettingName]; + Assert.False(string.IsNullOrEmpty(baseUrl)); + Assert.True(baseUrl.EndsWith('/')); this._httpClient = new HttpClient(); - this._httpClient.BaseAddress = new Uri(baseAddress); + this._httpClient.BaseAddress = new Uri(baseUrl); } public void Dispose() diff --git a/integration-tests/README.md b/integration-tests/README.md index 10d3dc23b..6674822af 100644 --- a/integration-tests/README.md +++ b/integration-tests/README.md @@ -21,7 +21,7 @@ To set your secrets with Secret Manager: cd integration-tests dotnet user-secrets init -dotnet user-secrets set "BaseAddress" "https://your-backend-address/" +dotnet user-secrets set "BaseUrl" "https://your-backend-address/" ``` ### Option 2: Use a Configuration File @@ -35,7 +35,7 @@ For example: ```json { - "BaseAddress": "https://localhost:40443/" + "BaseUrl": "https://localhost:40443/" } ``` @@ -45,11 +45,11 @@ You may also set the test settings in your environment variables. The environmen - bash: ```bash -export BaseAddress="https://localhost:40443/" +export BaseUrl="https://localhost:40443/" ``` - PowerShell: ```ps -$env:BaseAddress = "https://localhost:40443/" +$env:BaseUrl = "https://localhost:40443/" ``` diff --git a/integration-tests/testsettings.json b/integration-tests/testsettings.json index 89d37fd21..b9265777b 100644 --- a/integration-tests/testsettings.json +++ b/integration-tests/testsettings.json @@ -1,3 +1,3 @@ { - "BaseAddress": "https://localhost:40443/" + "BaseUrl": "https://localhost:40443/" } \ No newline at end of file