This commit is contained in:
lonegunmanb
2023-02-04 20:12:13 +08:00
committed by GitHub
parent 6ec09b5972
commit 62c65dcf48
12 changed files with 473 additions and 1 deletions

37
.github/workflows/e2e.yaml vendored Normal file
View File

@ -0,0 +1,37 @@
name: E2E Test Check
on:
pull_request:
types: ['opened', 'synchronize']
paths:
- '.github/**'
- '.github/workflows/**'
- 'quickstart/**'
jobs:
e2e-check:
runs-on: [self-hosted, 1ES.Pool=terraform-azurerm-doc]
environment:
name: acctests
steps:
- name: checkout
uses: actions/checkout@v3
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v34
with:
dir_names: "true"
separator: ","
files: "quickstart/*"
- name: test pr
run: |
az login --identity --username $MSI_ID > /dev/null
export ARM_SUBSCRIPTION_ID=$(az login --identity --username $MSI_ID | jq -r '.[0] | .id')
export ARM_TENANT_ID=$(az login --identity --username $MSI_ID | jq -r '.[0] | .tenantId')
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_USE_MSI=true -e CHANGED_FOLDERS mcr.microsoft.com/azterraform:latest sh -c "go mod tidy && go test -timeout=360m -v ./e2e"
- uses: actions/upload-artifact@v3
with:
name: TestRecord-${{ github.event.number }}
retention-days: 60
path: |
quickstart/**/TestRecord.md.tmp

29
.github/workflows/pr-check.yaml vendored Normal file
View File

@ -0,0 +1,29 @@
name: Pre Pull Request Check
on:
pull_request:
types: [ 'opened', 'synchronize' ]
paths:
- '.github/**'
- '.github/workflows/**'
- 'quickstart/**'
jobs:
prepr-check:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v34
with:
dir_names: "true"
separator: ","
files: "quickstart/*"
- name: pr-check
run: |
export CHANGED_FOLDERS="${{ steps.changed-files.outputs.all_changed_files }}"
if [ -z "${{ github.event.number }}" ]; then
CHANGED_FOLDERS=$(find ./quickstart -maxdepth 1 -mindepth 1 -type d | tr '\n' ',')
fi
docker run --rm -v $(pwd):/src -w /src -e CHANGED_FOLDERS mcr.microsoft.com/azterraform:latest make pr-check

39
.github/workflows/pr-merged.yaml vendored Normal file
View File

@ -0,0 +1,39 @@
name: Main Branch Push
on:
push:
branches:
- main
- master
paths:
- 'quickstart/**'
jobs:
main-branch-push:
runs-on: ubuntu-latest
steps:
- name: get-default-branch
run: |
branch=$(curl -s "https://api.github.com/repos/$GITHUB_REPOSITORY" | jq -r '.default_branch')
echo "default_branch=$branch" >> $GITHUB_ENV
- name: checkout
uses: actions/checkout@v3
- uses: 8BitJonny/gh-get-current-pr@2.1.0
id: PR
- name: Download artifact
id: download-artifact
uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: e2e.yaml
pr: ${{ steps.PR.outputs.number }}
name: TestRecord-${{ steps.PR.outputs.number }}
path: TestRecord
if_no_artifact_found: ignore
- name: Update
run: |
sh scripts/update-test-record.sh
- name: Commit & Push changes
uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
message: 'Update TestRecord'
branch: ${{ env.default_branch }}

35
.github/workflows/weekly-e2e.yaml vendored Normal file
View File

@ -0,0 +1,35 @@
name: Weekly E2E Test Check
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'
jobs:
full-e2e-check:
runs-on: [self-hosted, 1ES.Pool=terraform-azurerm-doc]
timeout-minutes: 1440
environment:
name: crontests
steps:
- name: checkout
uses: actions/checkout@v3
- name: test all examples
continue-on-error: true
timeout-minutes: 1440
run: |
az login --identity --username $MSI_ID > /dev/null
export ARM_SUBSCRIPTION_ID=$(az login --identity --username $MSI_ID | jq -r '.[0] | .id')
export ARM_TENANT_ID=$(az login --identity --username $MSI_ID | jq -r '.[0] | .tenantId')
docker run --rm -v $(pwd):/src -w /src/test -e MSI_ID -e ARM_SUBSCRIPTION_ID -e ARM_TENANT_ID -e ARM_USE_MSI=true -e CHANGED_FOLDERS mcr.microsoft.com/azterraform sh -c "go mod tidy && go test -timeout=1440m -v ./e2e"
- name: Update
run: |
docker run --rm -v $(pwd):/src -w /src mcr.microsoft.com/azterraform sh scripts/update-test-record.sh
cd .git
sudo chmod -R a+rwX .
sudo find . -type d -exec chmod g+s '{}' +
- name: Commit & Push changes
uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
message: 'Update TestRecord'
branch: ${{ env.default_branch }}