From 0431fbf166d56019323c2a2ba5b0a9a0ec04476a Mon Sep 17 00:00:00 2001 From: Yan Xu Date: Thu, 26 Oct 2023 15:26:50 +0800 Subject: [PATCH] disable output in CI logs (#359) --- .github/workflows/azure-login-canary.yml | 10 +- .../azure-login-integration-tests.yml | 20 +-- .github/workflows/azure-login-negative.yml | 52 ++++---- .github/workflows/azure-login-positive.yml | 116 +++++++++++------- .github/workflows/azure-login-pr-check.yml | 9 +- 5 files changed, 116 insertions(+), 91 deletions(-) diff --git a/.github/workflows/azure-login-canary.yml b/.github/workflows/azure-login-canary.yml index 58e8d5d60..75235a30a 100644 --- a/.github/workflows/azure-login-canary.yml +++ b/.github/workflows/azure-login-canary.yml @@ -38,7 +38,7 @@ jobs: creds: ${{ secrets.AZURE_CREDENTIALS }} - run: | - az account show + az account show --output none - name: 'Az CLI login without subscription' uses: azure/login@v1 @@ -47,7 +47,7 @@ jobs: allow-no-subscriptions: true - run: | - az account show + az account show --output none - name: 'Az CLI login with subscription OIDC' uses: azure/login@v1 @@ -57,7 +57,7 @@ jobs: subscription-id: ${{ secrets.AZURE_SUBSCRIPTIONID }} - run: | - az account show + az account show --output none - name: 'Az CLI login without subscription OIDC' uses: azure/login@v1 @@ -67,9 +67,7 @@ jobs: allow-no-subscriptions: true - run: | - az account show - - + az account show --output none slack-post-result: runs-on: ubuntu-latest diff --git a/.github/workflows/azure-login-integration-tests.yml b/.github/workflows/azure-login-integration-tests.yml index 7d5810e68..120b5a71b 100644 --- a/.github/workflows/azure-login-integration-tests.yml +++ b/.github/workflows/azure-login-integration-tests.yml @@ -19,8 +19,8 @@ jobs: creds: ${{ secrets.AZURE_CREDENTIALS }} - run: | - az account show -# az webapp list + az account show --output none + az vm list --output none - name: 'Az CLI login without subscription' uses: azure/login@v1 @@ -29,7 +29,7 @@ jobs: allow-no-subscriptions: true - run: | - az account show + az account show --output none - name: 'Azure PowerShell login with subscription' uses: azure/login@v1 @@ -39,7 +39,7 @@ jobs: - uses: azure/powershell@v1 with: - inlineScript: "Get-AzContext" + inlineScript: "(Get-AzContext).Environment.Name" azPSVersion: "latest" - name: 'Azure PowerShell login without subscription' @@ -51,7 +51,7 @@ jobs: - uses: azure/powershell@v1 with: - inlineScript: "Get-AzContext" + inlineScript: "(Get-AzContext).Environment.Name" azPSVersion: "latest" az-login-test-oidc: @@ -66,8 +66,8 @@ jobs: subscription-id: ${{ secrets.AZURE_SUBSCRIPTIONID }} - run: | - az account show -# az webapp list + az account show --output none + az vm list --output none - name: 'Az CLI login without subscription' uses: azure/login@v1 @@ -77,7 +77,7 @@ jobs: allow-no-subscriptions: true - run: | - az account show + az account show --output none - name: 'Azure PowerShell login with subscription' uses: azure/login@v1 @@ -89,7 +89,7 @@ jobs: - uses: azure/powershell@v1 with: - inlineScript: "Get-AzContext" + inlineScript: "(Get-AzContext).Environment.Name" azPSVersion: "latest" - name: 'Azure PowerShell login without subscription' @@ -102,7 +102,7 @@ jobs: - uses: azure/powershell@v1 with: - inlineScript: "Get-AzContext" + inlineScript: "(Get-AzContext).Environment.Name" azPSVersion: "latest" slack-post-result: diff --git a/.github/workflows/azure-login-negative.yml b/.github/workflows/azure-login-negative.yml index 0d8a4b39a..3cb37d5e6 100644 --- a/.github/workflows/azure-login-negative.yml +++ b/.github/workflows/azure-login-negative.yml @@ -37,9 +37,9 @@ jobs: - name: Run Azure Cli run: | - az account show - az group show --name GitHubAction_CI_RG - az vm list + az account show --output none + az group show --name GitHubAction_CI_RG --output none + az vm list --output none - name: Run Azure PowerShell id: ps_1 @@ -48,9 +48,9 @@ jobs: with: azPSVersion: "latest" inlineScript: | - Get-AzContext | Format-List - Get-AzResourceGroup -Name GitHubAction_CI_RG - Get-AzVM + (Get-AzContext).Environment.Name -eq 'AzureCloud' + (Get-AzResourceGroup -Name GitHubAction_CI_RG).ResourceGroupName -eq 'GitHubAction_CI_RG' + (Get-AzVM).Count -gt 0 - name: Check Last step failed if: steps.ps_1.outcome == 'success' @@ -71,7 +71,7 @@ jobs: - name: Run Azure Cli again run: | - az account show + az account show --output none - name: Run Azure PowerShell again id: ps_2 @@ -80,7 +80,7 @@ jobs: with: azPSVersion: "latest" inlineScript: | - Get-AzContext | Format-List + (Get-AzContext).Environment.Name -eq 'AzureCloud' - name: Check Last step failed if: steps.ps_2.outcome == 'success' @@ -124,9 +124,9 @@ jobs: id: cli_3 continue-on-error: true run: | - az account show - az group show --name GitHubAction_CI_RG - az vm list + az account show --output none + az group show --name GitHubAction_CI_RG --output none + az vm list --output none - name: Check Last step failed if: steps.cli_3.outcome == 'success' @@ -142,9 +142,9 @@ jobs: with: azPSVersion: "latest" inlineScript: | - Get-AzContext | Format-List - Get-AzResourceGroup -Name GitHubAction_CI_RG - Get-AzVM + (Get-AzContext).Environment.Name -eq 'AzureCloud' + (Get-AzResourceGroup -Name GitHubAction_CI_RG).ResourceGroupName -eq 'GitHubAction_CI_RG' + (Get-AzVM).Count -gt 0 - name: Check Last step failed if: steps.ps_3.outcome == 'success' @@ -259,9 +259,9 @@ jobs: - name: Run Azure Cli run: | - az account show - az group show --name GitHubAction_CI_RG - az vm list + az account show --output none + az group show --name GitHubAction_CI_RG --output none + az vm list --output none - name: Run Azure PowerShell id: ps_8 @@ -270,9 +270,9 @@ jobs: with: azPSVersion: "latest" inlineScript: | - Get-AzContext | Format-List - Get-AzResourceGroup -Name GitHubAction_CI_RG - Get-AzVM + (Get-AzContext).Environment.Name -eq 'AzureCloud' + (Get-AzResourceGroup -Name GitHubAction_CI_RG).ResourceGroupName -eq 'GitHubAction_CI_RG' + (Get-AzVM).Count -gt 0 - name: Check Last step failed if: steps.ps_8.outcome == 'success' @@ -289,9 +289,9 @@ jobs: - name: Run Azure Cli run: | - az account show - az group show --name GitHubAction_CI_RG - az vm list + az account show --output none + az group show --name GitHubAction_CI_RG --output none + az vm list --output none - name: Run Azure PowerShell id: ps_9 @@ -300,9 +300,9 @@ jobs: with: azPSVersion: "latest" inlineScript: | - Get-AzContext | Format-List - Get-AzResourceGroup -Name GitHubAction_CI_RG - Get-AzVM + (Get-AzContext).Environment.Name -eq 'AzureCloud' + (Get-AzResourceGroup -Name GitHubAction_CI_RG).ResourceGroupName -eq 'GitHubAction_CI_RG' + (Get-AzVM).Count -gt 0 - name: Check Last step failed if: steps.ps_9.outcome == 'success' diff --git a/.github/workflows/azure-login-positive.yml b/.github/workflows/azure-login-positive.yml index 71a80127b..8d5581803 100644 --- a/.github/workflows/azure-login-positive.yml +++ b/.github/workflows/azure-login-positive.yml @@ -42,18 +42,21 @@ jobs: - name: Run Azure Cli run: | - az account show - az group show --name GitHubAction_CI_RG - az vm list + az account show --output none + az group show --name GitHubAction_CI_RG --output none + az vm list --output none - name: Run Azure PowerShell uses: azure/powershell@v1.2.0 with: azPSVersion: "latest" inlineScript: | - Get-AzContext | Format-List - Get-AzResourceGroup -Name GitHubAction_CI_RG - Get-AzVM + $checkResult = (Get-AzContext).Environment.Name -eq 'AzureCloud' + $checkResult = $checkResult -and ((Get-AzResourceGroup -Name GitHubAction_CI_RG).ResourceGroupName -eq 'GitHubAction_CI_RG') + $checkResult = $checkResult -and ((Get-AzVM).Count -gt 0) + if(-not $checkResult){ + throw "Not all checks passed!" + } - name: Login with individual parameters uses: ./ @@ -66,14 +69,17 @@ jobs: - name: Run Azure Cli again run: | - az account show + az account show --output none - name: Run Azure PowerShell again uses: azure/powershell@v1.2.0 with: azPSVersion: "latest" inlineScript: | - Get-AzContext | Format-List + $checkResult = (Get-AzContext).Environment.Name -eq 'AzureCloud' + if(-not $checkResult){ + throw "Not all checks passed!" + } - name: Login with explicit auth-type uses: ./ @@ -84,18 +90,21 @@ jobs: - name: Run Azure Cli run: | - az account show - az group show --name GitHubAction_CI_RG - az vm list + az account show --output none + az group show --name GitHubAction_CI_RG --output none + az vm list --output none - name: Run Azure PowerShell uses: azure/powershell@v1.2.0 with: azPSVersion: "latest" inlineScript: | - Get-AzContext | Format-List - Get-AzResourceGroup -Name GitHubAction_CI_RG - Get-AzVM + $checkResult = (Get-AzContext).Environment.Name -eq 'AzureCloud' + $checkResult = $checkResult -and ((Get-AzResourceGroup -Name GitHubAction_CI_RG).ResourceGroupName -eq 'GitHubAction_CI_RG') + $checkResult = $checkResult -and ((Get-AzVM).Count -gt 0) + if(-not $checkResult){ + throw "Not all checks passed!" + } ParameterTest: strategy: @@ -126,9 +135,9 @@ jobs: - name: Run Azure Cli run: | - az account show - az group show --name GitHubAction_CI_RG - az vm list + az account show --output none + az group show --name GitHubAction_CI_RG --output none + az vm list --output none - name: Login with creds, wrong boolean value uses: ./ @@ -138,9 +147,9 @@ jobs: - name: Run Azure Cli run: | - az account show - az group show --name GitHubAction_CI_RG - az vm list + az account show --output none + az group show --name GitHubAction_CI_RG --output none + az vm list --output none - name: Login with creds, allow no subscription uses: ./ @@ -151,18 +160,21 @@ jobs: - name: Run Azure Cli run: | - az account show - az group show --name GitHubAction_CI_RG - az vm list + az account show --output none + az group show --name GitHubAction_CI_RG --output none + az vm list --output none - name: Run Azure PowerShell uses: azure/powershell@v1.2.0 with: azPSVersion: "latest" inlineScript: | - Get-AzContext | Format-List - Get-AzResourceGroup -Name GitHubAction_CI_RG - Get-AzVM + $checkResult = (Get-AzContext).Environment.Name -eq 'AzureCloud' + $checkResult = $checkResult -and ((Get-AzResourceGroup -Name GitHubAction_CI_RG).ResourceGroupName -eq 'GitHubAction_CI_RG') + $checkResult = $checkResult -and ((Get-AzVM).Count -gt 0) + if(-not $checkResult){ + throw "Not all checks passed!" + } - name: Login with individual parameters, no subscription, allow no subscription uses: ./ @@ -174,14 +186,17 @@ jobs: - name: Run Azure Cli run: | - az account show + az account show --output none - name: Run Azure PowerShell uses: azure/powershell@v1.2.0 with: azPSVersion: "latest" inlineScript: | - Get-AzContext | Format-List + $checkResult = (Get-AzContext).Environment.Name -eq 'AzureCloud' + if(-not $checkResult){ + throw "Not all checks passed!" + } VMTest: strategy: @@ -213,14 +228,17 @@ jobs: - name: Run Azure Cli run: | - az account show + az account show --output none - name: Run Azure PowerShell uses: azure/powershell@v1.2.0 with: azPSVersion: "latest" inlineScript: | - Get-AzContext | Format-List + $checkResult = (Get-AzContext).Environment.Name -eq 'AzureCloud' + if(-not $checkResult){ + throw "Not all checks passed!" + } - name: Login with system-assigned managed identity, with subscription id uses: ./ @@ -231,18 +249,21 @@ jobs: - name: Run Azure Cli run: | - az account show - az group show --name GitHubAction_CI_RG - az vm list + az account show --output none + az group show --name GitHubAction_CI_RG --output none + az vm list --output none - name: Run Azure PowerShell uses: azure/powershell@v1.2.0 with: azPSVersion: "latest" inlineScript: | - Get-AzContext | Format-List - Get-AzResourceGroup -Name GitHubAction_CI_RG - Get-AzVM + $checkResult = (Get-AzContext).Environment.Name -eq 'AzureCloud' + $checkResult = $checkResult -and ((Get-AzResourceGroup -Name GitHubAction_CI_RG).ResourceGroupName -eq 'GitHubAction_CI_RG') + $checkResult = $checkResult -and ((Get-AzVM).Count -gt 0) + if(-not $checkResult){ + throw "Not all checks passed!" + } - name: Login with tenant-level user-assigned managed identity with allow-no-subscriptions uses: ./ @@ -254,14 +275,17 @@ jobs: - name: Run Azure Cli run: | - az account show + az account show --output none - name: Run Azure PowerShell uses: azure/powershell@v1.2.0 with: azPSVersion: "latest" inlineScript: | - Get-AzContext | Format-List + $checkResult = (Get-AzContext).Environment.Name -eq 'AzureCloud' + if(-not $checkResult){ + throw "Not all checks passed!" + } - name: Login with user-assigned managed identity, subscription-id uses: ./ @@ -273,17 +297,19 @@ jobs: - name: Run Azure Cli run: | - az account show - az group show --name GitHubAction_CI_RG - az vm list + az account show --output none + az group show --name GitHubAction_CI_RG --output none + az vm list --output none - name: Run Azure PowerShell uses: azure/powershell@v1.2.0 with: azPSVersion: "latest" inlineScript: | - Get-AzContext | Format-List - Get-AzResourceGroup -Name GitHubAction_CI_RG - Get-AzVM - + $checkResult = (Get-AzContext).Environment.Name -eq 'AzureCloud' + $checkResult = $checkResult -and ((Get-AzResourceGroup -Name GitHubAction_CI_RG).ResourceGroupName -eq 'GitHubAction_CI_RG') + $checkResult = $checkResult -and ((Get-AzVM).Count -gt 0) + if(-not $checkResult){ + throw "Not all checks passed!" + } diff --git a/.github/workflows/azure-login-pr-check.yml b/.github/workflows/azure-login-pr-check.yml index a484a71fd..9c0353c58 100644 --- a/.github/workflows/azure-login-pr-check.yml +++ b/.github/workflows/azure-login-pr-check.yml @@ -34,8 +34,8 @@ jobs: creds: ${{ secrets.AZURE_CREDENTIALS }} - run: | - az account show - # az webapp list + az account show --output none + az vm list --output none - name: 'Az CLI login without subscription' uses: ./ @@ -44,7 +44,8 @@ jobs: allow-no-subscriptions: true - run: | - az account show + az account show --output none + az vm list --output none - name: 'Azure PowerShell login with subscription' uses: ./ @@ -54,7 +55,7 @@ jobs: - uses: azure/powershell@v1 with: - inlineScript: "Get-AzContext" + inlineScript: "(Get-AzContext).Environment.Name" azPSVersion: "latest" # - name: 'Azure PowerShell login without subscription'