Skip to content

Commit d433e5c

Browse files
authored
Merge branch 'Azure:dev' into dev
2 parents 501a284 + db09a85 commit d433e5c

File tree

3,342 files changed

+1262837
-695094
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,342 files changed

+1262837
-695094
lines changed

.azure-pipelines/breaking-change-tests.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ jobs:
2020
- checkout: self
2121
fetchDepth: 0
2222
fetchTags: true
23-
persistCredentials: true
2423
- task: UsePythonVersion@0
25-
displayName: 'Use Python 3.11'
24+
displayName: 'Use Python 3.12'
2625
inputs:
27-
versionSpec: 3.11
26+
versionSpec: 3.12
2827
- template: ${{ variables.Pipeline.Workspace }}/.azure-pipelines/templates/azdev_setup.yml
2928
- bash: |
3029
set -ev

.azure-pipelines/sync-alias.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Azure CLI Sync Alias
2+
3+
schedules:
4+
- cron: "50 15 * * 0"
5+
displayName: 11:50 PM (UTC + 8:00) China Weekly Run
6+
branches:
7+
include:
8+
- dev
9+
10+
# The 'resources' and 'uses' below are used to resolve the error 'Repository associated with wiki ID <WikiId> does not exist or you do not have permissions for the operation you are attempting.'
11+
resources:
12+
repositories:
13+
- repository: ServiceContactList
14+
type: git
15+
name: internal.wiki
16+
17+
jobs:
18+
- job: UpdateYaml
19+
displayName: Update resourceManagement.yml
20+
pool: pool-windows-2019
21+
uses:
22+
repositories:
23+
- ServiceContactList
24+
25+
steps:
26+
- task: UseDotNet@2
27+
displayName: Install .NET 8 SDK
28+
inputs:
29+
packageType: sdk
30+
version: 8.0.x
31+
32+
- pwsh: |
33+
dotnet --version
34+
dotnet new tool-manifest --force
35+
dotnet tool install powershell --version 7.4.*
36+
displayName: Install PowerShell 7.4.x
37+
38+
- pwsh: |
39+
dotnet tool run pwsh -NoLogo -NoProfile -NonInteractive -File ./tools/Github/ParseServiceContactsList.ps1 -AccessToken $env:SYSTEM_ACCESSTOKEN
40+
env:
41+
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
42+
displayName: Update resourceManagement.yml file locally
43+
44+
- pwsh: |
45+
$hasChanges = git diff --name-only .github/policies
46+
if ($null -eq $hasChanges) {
47+
Write-Host "The wiki has no changes."
48+
Write-Host "##vso[task.setvariable variable=ChangesDetected]false"
49+
} else {
50+
Write-Host "There are changes in the repository."
51+
Write-Host "##vso[task.setvariable variable=ChangesDetected]true"
52+
}
53+
displayName: Check if Wiki table has any changes
54+
55+
- task: AzurePowerShell@5
56+
inputs:
57+
pwsh: true
58+
azureSubscription: '$(AZURE_SDK_INFRA_SUB_CONNECTED_SERVICE)'
59+
ScriptType: 'InlineScript'
60+
Inline: |
61+
$GithubToken = Get-AzKeyVaultSecret -VaultName $(GithubPATKeyVaultName) -Name $(GithubPATKeyVaultAccount) -AsPlainText
62+
Write-Host "##vso[task.setvariable variable=GithubToken;issecret=true]$GithubToken"
63+
azurePowerShellVersion: 'LatestVersion'
64+
displayName: Get Github PAT from Key Vault
65+
66+
- pwsh: |
67+
git config --global user.email "[email protected]"
68+
git config --global user.name "Azure CLI Team"
69+
git checkout -b "sync_alias_$env:Build_BuildId"
70+
71+
git add .github/policies
72+
git commit -m "Sync resourceManagement.yml"
73+
74+
git remote set-url origin https://azclibot:$(GithubToken)@github.com/Azure/azure-cli.git;
75+
git push origin "sync_alias_$env:Build_BuildId" --force
76+
displayName: Git commit and push
77+
condition: and(succeeded(), eq(variables['ChangesDetected'], 'true'))
78+
79+
- pwsh: |
80+
$Title = "{CI} Sync resourceManagement.yml according To ADO Wiki Page - Service Contact List"
81+
$HeadBranch = "sync_alias_$env:Build_BuildId"
82+
$BaseBranch = "dev"
83+
$Description = "This PR synchronizes the task: 'Triage issues to the service team' part of resourceManagement.yml from table of Service Contact List in ADO wiki page"
84+
85+
$Headers = @{"Accept" = "application/vnd.github+json"; "Authorization" = "Bearer $(GithubToken)" }
86+
$RequestBody = @{"title" = $Title; "body" = $Description; "head" = $HeadBranch; "base" = $BaseBranch;}
87+
$Uri = "https://api.github.com/repos/Azure/azure-cli/pulls"
88+
89+
Invoke-WebRequest -Uri $Uri -Method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json)
90+
91+
displayName: Create PR to dev branch
92+
condition: and(succeeded(), eq(variables['ChangesDetected'], 'true'))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
variables:
22
ubuntu_pool: 'pool-ubuntu-2004'
3+
ubuntu_multi_core_pool: 'pool-ubuntu-2004-multi-core'
34
windows_pool: 'pool-windows-2019'
45
ubuntu_arm64_pool: 'ubuntu-arm64-2004-pool'
56
macos_pool: 'macOS-14'

.githooks/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Git Hooks for Azure CLI Extension Development
2+
3+
## Setup
4+
5+
Please run the following command to enable the hooks.
6+
7+
```bash
8+
azdev setup -c {azure_cli_repo_path} -r {azure_cli_extension_repo_path}
9+
10+
# if you install azdev which version is less than 0.1.84, you need to run the following command to enable the hooks
11+
git config --local core.hooksPath .githooks
12+
```
13+
14+
## Usage
15+
16+
Every time you git commit or git push, please make sure you have activated the python environment and completed the azdev setup.
17+
18+
If you want to skip the verification, you can add `--no-verify` to the git command.
19+
20+
## Note
21+
22+
### pre-commit
23+
24+
The pre-commit hook (`pre-commit.ps1`) performs the following checks:
25+
26+
1. Verifies that azdev is active in your current environment
27+
2. Runs `azdev scan` on all staged files to detect potential secrets
28+
3. If any secrets are detected, the commit will be blocked
29+
- You can use `azdev mask` to remove secrets before committing
30+
- Alternatively, use `git commit --no-verify` to bypass the check
31+
32+
### pre-push
33+
34+
The pre-push hooks (`pre-push.sh` for bash and `pre-push.ps1` for PowerShell) perform several quality checks:
35+
36+
1. Verifies that azdev is active in your current environment
37+
2. Confirms azure-cli is installed in editable mode
38+
3. Checks if your branch needs rebasing against upstream/dev
39+
- If rebasing is needed, displays instructions and provides a 5-second window to cancel
40+
4. Runs the following quality checks on changed files:
41+
- `azdev lint`: Checks for linting issues
42+
- `azdev style`: Verifies code style compliance
43+
- `azdev test`: Runs tests for modified code
44+
5. If any check fails, the push will be blocked
45+
- Use `git push --no-verify` to bypass these checks (not recommended)
46+
47+
The hooks support both Windows (PowerShell) and Unix-like systems (Bash), automatically using the appropriate script for your environment.

.githooks/azdev_active.ps1

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Check if in the python environment
2+
$pythonPath = (Get-Command python -ErrorAction SilentlyContinue).Path
3+
Write-Host "PYTHON_PATH: $pythonPath"
4+
5+
if (-not $pythonPath) {
6+
Write-Host "Error: Python not found in PATH" -ForegroundColor Red
7+
exit 1
8+
}
9+
10+
$pythonEnvFolder = Split-Path -Parent (Split-Path -Parent $pythonPath)
11+
$pythonActiveFile = Join-Path $pythonEnvFolder "Scripts\activate.ps1"
12+
13+
if (-not (Test-Path $pythonActiveFile)) {
14+
Write-Host "Python active file does not exist: $pythonActiveFile" -ForegroundColor Red
15+
Write-Host "Error: Please activate the python environment first." -ForegroundColor Red
16+
exit 1
17+
}
18+
19+
# Construct the full path to the .azdev\env_config directory
20+
$azdevEnvConfigFolder = Join-Path $env:USERPROFILE ".azdev\env_config"
21+
Write-Host "AZDEV_ENV_CONFIG_FOLDER: $azdevEnvConfigFolder"
22+
23+
# Check if the directory exists
24+
if (-not (Test-Path $azdevEnvConfigFolder)) {
25+
Write-Host "AZDEV_ENV_CONFIG_FOLDER does not exist: $azdevEnvConfigFolder" -ForegroundColor Red
26+
Write-Host "Error: azdev environment is not completed, please run 'azdev setup' first." -ForegroundColor Red
27+
exit 1
28+
}
29+
30+
$configFile = Join-Path $azdevEnvConfigFolder ($pythonEnvFolder.Substring(2) + "\config")
31+
if (-not (Test-Path $configFile)) {
32+
Write-Host "CONFIG_FILE does not exist: $configFile" -ForegroundColor Red
33+
Write-Host "Error: azdev environment is not completed, please run 'azdev setup' first." -ForegroundColor Red
34+
exit 1
35+
}
36+
37+
Write-Host "CONFIG_FILE: $configFile"
38+
39+
exit 0

.githooks/azdev_active.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
# Check if in the python environment
4+
PYTHON_FILE=$(which python)
5+
printf "PYTHON_PATH: %s\n" "$PYTHON_FILE"
6+
7+
if [ -z "$PYTHON_FILE" ]; then
8+
printf "\033[0;31mError: Python not found in PATH\033[0m\n"
9+
exit 1
10+
fi
11+
12+
PYTHON_ENV_FOLDER=$(dirname "$PYTHON_FILE")
13+
PYTHON_ACTIVE_FILE="$PYTHON_ENV_FOLDER/activate"
14+
15+
if [ ! -f "$PYTHON_ACTIVE_FILE" ]; then
16+
printf "Python active file does not exist: %s\n" "$PYTHON_ACTIVE_FILE"
17+
printf "\033[0;31mError: Please activate the python environment first.\033[0m\n"
18+
exit 1
19+
fi
20+
21+
# Construct the full path to the .azdev/env_config directory
22+
AZDEV_ENV_CONFIG_FOLDER="$HOME/.azdev/env_config"
23+
printf "AZDEV_ENV_CONFIG_FOLDER: %s\n" "$AZDEV_ENV_CONFIG_FOLDER"
24+
25+
# Check if the directory exists
26+
if [ ! -d "$AZDEV_ENV_CONFIG_FOLDER" ]; then
27+
printf "AZDEV_ENV_CONFIG_FOLDER does not exist: %s\n" "$AZDEV_ENV_CONFIG_FOLDER"
28+
printf "\033[0;31mError: azdev environment is not completed, please run 'azdev setup' first.\033[0m\n"
29+
exit 1
30+
fi
31+
32+
PYTHON_ENV_FOLDER=$(dirname "$PYTHON_ENV_FOLDER")
33+
34+
CONFIG_FILE="$AZDEV_ENV_CONFIG_FOLDER${PYTHON_ENV_FOLDER}/config"
35+
if [ ! -f "$CONFIG_FILE" ]; then
36+
printf "CONFIG_FILE does not exist: %s\n" "$CONFIG_FILE"
37+
printf "\033[0;31mError: azdev environment is not completed, please run 'azdev setup' first.\033[0m\n"
38+
exit 1
39+
fi
40+
41+
printf "CONFIG_FILE: %s\n" "$CONFIG_FILE"

.githooks/pre-commit

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env sh
2+
":" //; if command -v pwsh >/dev/null 2>&1; then pwsh -ExecutionPolicy Bypass -File .githooks/pre-commit.ps1; else sh .githooks/pre-commit.sh; fi; exit $? # Try PowerShell Core first, then sh on Unix
3+
":" //; exit # Skip rest on Unix
4+
5+
@echo off
6+
powershell -NoProfile -Command "if (Get-Command powershell -ErrorAction SilentlyContinue) { exit 0 } else { exit 1 }"
7+
if %errorlevel% equ 0 (
8+
powershell -ExecutionPolicy Bypass -File .githooks\pre-commit.ps1
9+
) else (
10+
echo Error: PowerShell is not available. Please install PowerShell.
11+
exit /b 1
12+
)
13+
exit /b %errorlevel%

.githooks/pre-commit.ps1

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env pwsh
2+
Write-Host "Running pre-commit hook in powershell..." -ForegroundColor Green
3+
4+
# run azdev_active script
5+
$scriptPath = Join-Path $PSScriptRoot "azdev_active.ps1"
6+
. $scriptPath
7+
if ($LASTEXITCODE -ne 0) {
8+
exit 1
9+
}
10+
11+
# Run command azdev scan
12+
Write-Host "Running azdev scan..." -ForegroundColor Green
13+
14+
# Check if we have a previous commit to compare against
15+
if (git rev-parse --verify HEAD 2>$null) {
16+
Write-Host "Using HEAD as the previous commit"
17+
$against = "HEAD"
18+
}
19+
else {
20+
Write-Host "Using an empty tree object as the previous commit"
21+
$against = $(git hash-object -t tree /dev/null)
22+
}
23+
24+
$hasSecrets = 0
25+
$files = $(git diff --cached --name-only --diff-filter=AM $against)
26+
27+
foreach ($file in $files) {
28+
# Check if the file contains secrets
29+
$detected = $(azdev scan -f $file --continue-on-failure | ConvertFrom-Json).secrets_detected
30+
if ($detected -eq "True") {
31+
Write-Host "Detected secrets from $file. Please run the following command to mask it:" -ForegroundColor Red
32+
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++" -ForegroundColor Red
33+
Write-Host "azdev mask -f $file" -ForegroundColor Red
34+
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++" -ForegroundColor Red
35+
$hasSecrets = 1
36+
}
37+
}
38+
39+
if ($hasSecrets -eq 1) {
40+
Write-Host "Secret detected. If you want to skip that, run add '--no-verify' in the end of 'git commit' command." -ForegroundColor Red
41+
exit 1
42+
}
43+
44+
Write-Host "Pre-commit hook passed." -ForegroundColor Green
45+
exit 0

.githooks/pre-commit.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
printf "\033[0;32mRunning pre-commit hook in bash ...\033[0m\n"
3+
4+
# run azdev_active script
5+
SCRIPT_PATH="$(dirname "$0")/azdev_active.sh"
6+
. "$SCRIPT_PATH"
7+
if [ $? -ne 0 ]; then
8+
exit 1
9+
fi
10+
11+
# Run command azdev scan
12+
printf "\033[0;32mRunning azdev scan...\033[0m\n"
13+
14+
if git rev-parse --verify HEAD >/dev/null 2>&1
15+
then
16+
printf "Using HEAD as the previous commit\n"
17+
against=HEAD
18+
else
19+
printf "Using an empty tree object as the previous commit\n"
20+
against=$(git hash-object -t tree /dev/null)
21+
fi
22+
has_secrets=0
23+
for FILE in `git diff --cached --name-only --diff-filter=AM $against` ; do
24+
# Check if the file contains secrets
25+
detected=$(azdev scan -f "$FILE" --continue-on-failure | python -c "import sys, json; print(json.load(sys.stdin)['secrets_detected'])")
26+
if [ "$detected" = "True" ]; then
27+
printf "\033[0;31mDetected secrets from %s, Please run the following command to mask it:\033[0m\n" "$FILE"
28+
printf "\033[0;31m+++++++++++++++++++++++++++++++++++++++++++++++++++++++\033[0m\n"
29+
printf "\033[0;31mazdev mask -f %s\033[0m\n" "$FILE"
30+
printf "\033[0;31m+++++++++++++++++++++++++++++++++++++++++++++++++++++++\033[0m\n"
31+
has_secrets=1
32+
fi
33+
done
34+
35+
if [ $has_secrets -eq 1 ]; then
36+
printf "\033[0;31mSecret detected. If you want to skip that, run add '--no-verify' in the end of 'git commit' command.\033[0m\n"
37+
exit 1
38+
fi
39+
40+
printf "\033[0;32mPre-commit hook passed.\033[0m\n"
41+
exit 0

.githooks/pre-push

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env sh
2+
":" //; if command -v pwsh >/dev/null 2>&1; then pwsh -ExecutionPolicy Bypass -File .githooks/pre-push.ps1; else sh .githooks/pre-push.sh; fi; exit $? # Try PowerShell Core first, then sh on Unix
3+
":" //; exit # Skip rest on Unix
4+
5+
@echo off
6+
powershell -NoProfile -Command "if (Get-Command powershell -ErrorAction SilentlyContinue) { exit 0 } else { exit 1 }"
7+
if %errorlevel% equ 0 (
8+
powershell -ExecutionPolicy Bypass -File .githooks\pre-push.ps1
9+
) else (
10+
echo Error: PowerShell is not available. Please install PowerShell.
11+
exit /b 1
12+
)
13+
exit /b %errorlevel%

0 commit comments

Comments
 (0)