convert e2e to a workflow_disptach event

This commit is contained in:
hezijie 2024-09-13 10:18:16 +08:00
parent 5196ebf436
commit 869b6f6930

View File

@ -1,22 +1,25 @@
name: E2E Test Check name: E2E Test Check
on: on:
pull_request: workflow_dispatch:
types: ['opened', 'synchronize'] inputs:
paths: pr_number:
- '.github/**' description: '(Required) pull request number to test against'
- '.github/workflows/**' type: string
- 'quickstart/**' required: true
permissions: permissions:
actions: write actions: write
contents: read
id-token: write
jobs: jobs:
e2e-check: e2e-check:
runs-on: [self-hosted, 1ES.Pool=terraform-azurerm-doc] runs-on: ubuntu-latest
environment: environment:
name: acctests name: acctests
steps: steps:
- name: checkout - name: checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 #v3.6.0 run:
gh pr checkout ${{ inputs.query }}
- name: Get changed files - name: Get changed files
id: changed-files id: changed-files
uses: tj-actions/changed-files@v34 uses: tj-actions/changed-files@v34
@ -31,15 +34,16 @@ jobs:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: | run: |
echo "change files" $ALL_CHANGED_FILES echo "change files" $ALL_CHANGED_FILES
az login --identity --username $MSI_ID > /dev/null export ARM_OIDC_REQUEST_TOKEN=$ACTIONS_ID_TOKEN_REQUEST_TOKEN
export ARM_SUBSCRIPTION_ID=$(az login --identity --username $MSI_ID | jq -r '.[0] | .id') export ARM_OIDC_REQUEST_URL=$ACTIONS_ID_TOKEN_REQUEST_URL
export ARM_TENANT_ID=$(az login --identity --username $MSI_ID | jq -r '.[0] | .tenantId') export ARM_SUBSCRIPTION_ID=${{ secrets.ARM_SUBSCRIPTION_ID }}
ARM_CLIENT_ID=$(az identity list | jq -r --arg MSI_ID "$MSI_ID" '.[] | select(.principalId == $MSI_ID) | .clientId') export ARM_TENANT_ID=${{ secrets.ARM_TENANT_ID }}
export ARM_CLIENT_ID=${{ secrets.ARM_CLIENT_ID }}
export CHANGED_FOLDERS="${{ steps.changed-files.outputs.all_changed_files }}" export CHANGED_FOLDERS="${{ steps.changed-files.outputs.all_changed_files }}"
docker run --rm -v $(pwd):/src -w /src/test --network=host -e MSI_ID -e ARM_SUBSCRIPTION_ID -e ARM_TENANT_ID -e ARM_CLIENT_ID -e ARM_USE_MSI=true -e CHANGED_FOLDERS mcr.microsoft.com/azterraform:latest sh -c "pkenv install 1.10.2 && go mod tidy && go test -timeout=360m -v ./e2e" docker run --rm -v $(pwd):/src -w /src/test --network=host -e MSI_ID -e ARM_SUBSCRIPTION_ID -e ARM_TENANT_ID -e ARM_CLIENT_ID -e ARM_OIDC_REQUEST_TOKEN -e ARM_OIDC_REQUEST_URL -e ARM_USE_OIDC=true -e CHANGED_FOLDERS mcr.microsoft.com/azterraform:latest sh -c "pkenv install 1.10.2 && go mod tidy && go test -timeout=360m -v ./e2e"
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 #v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 #v3.1.3
with: with:
name: TestRecord-${{ github.event.number }} name: TestRecord-${{ inputs.query }}
retention-days: 60 retention-days: 60
path: | path: |
quickstart/**/TestRecord.md.tmp quickstart/**/TestRecord.md.tmp