Skip to content

Commit 7380c3b

Browse files
Merge branch 'Azure:main' into main
2 parents d09a9ff + fb5c19f commit 7380c3b

20,138 files changed

Lines changed: 10188059 additions & 3010785 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
resources:
2+
- repo: self
3+
4+
trigger: none
5+
6+
pr:
7+
branches:
8+
include:
9+
- '*'
10+
11+
variables:
12+
- template: ${{ variables.Pipeline.Workspace }}/.azure-pipelines/templates/variables.yml
13+
14+
jobs:
15+
- job: BreakingChangeTest
16+
displayName: "Breaking Change Test"
17+
pool:
18+
name: ${{ variables.ubuntu_pool }}
19+
steps:
20+
- checkout: self
21+
fetchDepth: 0
22+
fetchTags: true
23+
- task: UsePythonVersion@0
24+
displayName: 'Use Python 3.10'
25+
inputs:
26+
versionSpec: 3.10
27+
- template: ${{ variables.Pipeline.Workspace }}/.azure-pipelines/templates/azdev_setup.yml
28+
- bash: |
29+
set -ev
30+
. env/bin/activate
31+
python scripts/ci/breaking_change_test.py
32+
breakingChangeTest='false'
33+
if [[ -f '/$(HOME)/.azdev/env_config/mnt/vss/_work/1/s/env/breaking_change_test.json' ]]; then
34+
breakingChangeTest='true'
35+
fi
36+
echo "##vso[task.setvariable variable=breakingChangeTest]$breakingChangeTest"
37+
displayName: "Breaking Change Test"
38+
env:
39+
PR_SRC_BRANCH: $(System.PullRequest.SourceBranch)
40+
PR_TARGET_BRANCH: $(System.PullRequest.TargetBranch)
41+
PULL_REQUEST_NUMBER: $(System.PullRequest.PullRequestNumber)
42+
JOB_NAME: "breaking_change_test"
43+
- task: PublishBuildArtifacts@1
44+
condition: and(succeededOrFailed(), eq(variables.breakingChangeTest, 'true'))
45+
inputs:
46+
# /mnt/vss/.azdev/env_config/mnt/vss/_work/1/s/env/breaking_change_test.json
47+
PathtoPublish: '/$(HOME)/.azdev/env_config/mnt/vss/_work/1/s/env/breaking_change_test.json'
48+
ArtifactName: 'breaking_change_test'
49+
publishLocation: 'Container'

.azure-pipelines/sync-alias.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
- main
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+
variables:
18+
- template: ${{ variables.Pipeline.Workspace }}/.azure-pipelines/templates/variables.yml
19+
20+
jobs:
21+
- job: UpdateYaml
22+
displayName: Update resourceManagement.yml
23+
pool:
24+
name: ${{ variables.windows_pool }}
25+
uses:
26+
repositories:
27+
- ServiceContactList
28+
29+
steps:
30+
- task: UseDotNet@2
31+
displayName: Install .NET 8 SDK
32+
inputs:
33+
packageType: sdk
34+
version: 8.0.x
35+
36+
- pwsh: |
37+
dotnet --version
38+
dotnet new tool-manifest --force
39+
dotnet tool install powershell --version 7.4.*
40+
displayName: Install PowerShell 7.4.x
41+
42+
- pwsh: |
43+
dotnet tool run pwsh -NoLogo -NoProfile -NonInteractive -File ./scripts/automation/ParseServiceContactsList.ps1 -AccessToken $env:SYSTEM_ACCESSTOKEN
44+
env:
45+
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
46+
displayName: Update resourceManagement.yml file locally
47+
48+
- pwsh: |
49+
$hasChanges = git diff --name-only .github/policies
50+
if ($null -eq $hasChanges) {
51+
Write-Host "The wiki has no changes."
52+
Write-Host "##vso[task.setvariable variable=ChangesDetected]false"
53+
} else {
54+
Write-Host "There are changes in the repository."
55+
Write-Host "##vso[task.setvariable variable=ChangesDetected]true"
56+
}
57+
displayName: Check if Wiki table has any changes
58+
59+
- task: AzurePowerShell@5
60+
inputs:
61+
pwsh: true
62+
azureSubscription: '$(AZURE_SDK_INFRA_SUB_CONNECTED_SERVICE)'
63+
ScriptType: 'InlineScript'
64+
Inline: |
65+
$GithubToken = Get-AzKeyVaultSecret -VaultName $(GithubPATKeyVaultName) -Name $(GithubPATKeyVaultAccount) -AsPlainText
66+
Write-Host "##vso[task.setvariable variable=GithubToken;issecret=true]$GithubToken"
67+
azurePowerShellVersion: 'LatestVersion'
68+
displayName: Get Github PAT from Key Vault
69+
70+
- pwsh: |
71+
git config --global user.email "AzPyCLI@microsoft.com"
72+
git config --global user.name "Azure CLI Team"
73+
git checkout -b "sync_alias_$env:Build_BuildId"
74+
75+
git add .github/policies
76+
git commit -m "Sync resourceManagement.yml"
77+
78+
git remote add azclibot https://azclibot:$(GithubToken)@github.com/azclibot/azure-cli-extensions.git
79+
git push azclibot "sync_alias_$env:Build_BuildId" --force
80+
displayName: Git commit and push
81+
condition: and(succeeded(), eq(variables['ChangesDetected'], 'true'))
82+
83+
- pwsh: |
84+
$Title = "{CI} Sync resourceManagement.yml according To ADO Wiki Page - Service Contact List"
85+
$HeadBranch = "azclibot:sync_alias_$env:Build_BuildId"
86+
$BaseBranch = "main"
87+
$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"
88+
89+
$Headers = @{"Accept" = "application/vnd.github+json"; "Authorization" = "Bearer $(GithubToken)" }
90+
$RequestBody = @{"title" = $Title; "body" = $Description; "head" = $HeadBranch; "base" = $BaseBranch;}
91+
$Uri = "https://api.github.com/repos/Azure/azure-cli-extensions/pulls"
92+
93+
Invoke-WebRequest -Uri $Uri -Method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json)
94+
95+
displayName: Create PR to azure/azure-cli-extensions main branch
96+
condition: and(succeeded(), eq(variables['ChangesDetected'], 'true'))
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
parameters:
2+
- name: CLIRepoPath
3+
type: string
4+
default: '../azure-cli'
5+
- name: CLIExtensionRepoPath
6+
type: string
7+
default: './'
8+
steps:
9+
- bash: |
10+
set -ev
11+
python -m venv env
12+
chmod +x env/bin/activate
13+
source ./env/bin/activate
14+
# clone azure-cli
15+
git clone -q --single-branch -b dev https://github.com/Azure/azure-cli.git ../azure-cli
16+
python -m pip install -U pip
17+
pip install azdev
18+
azdev --version
19+
azdev setup -c $CLI_REPO_PATH -r $CLI_EXT_REPO_PATH --debug
20+
# Installing setuptools with a version higher than 70.0.0 will not generate metadata.json
21+
pip install setuptools==70.0.0
22+
pip list -v
23+
az --version
24+
displayName: 'azdev setup'
25+
env:
26+
CLI_REPO_PATH: ${{ parameters.CLIRepoPath }}
27+
CLI_EXT_REPO_PATH: ${{ parameters.CLIExtensionRepoPath }}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
variables:
2+
ubuntu_pool: 'pool-ubuntu-2204'
3+
windows_pool: 'pool-windows-2019'
4+
ubuntu_arm64_pool: 'pool-ubuntu-latest-arm64'

.devcontainer/devcontainer.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "Azure CLI Dev Container",
3+
"image": "mcr.microsoft.com/devcontainers/python:3.12",
4+
"features": {
5+
"ghcr.io/devcontainers/features/github-cli:1": {}
6+
},
7+
"workspaceFolder": "/workspaces",
8+
"onCreateCommand": "python -m venv venv",
9+
"postCreateCommand": "REPO_NAME=$(basename $GITHUB_REPOSITORY) && cat $REPO_NAME/.devcontainer/login.sh >> ~/.bashrc && cp $REPO_NAME/.devcontainer/setup.sh easy_setup.sh && chmod +x easy_setup.sh",
10+
"hostRequirements": {
11+
"cpus": 16,
12+
"memory": "64gb",
13+
"storage": "128gb"
14+
},
15+
"customizations": {
16+
"vscode": {
17+
"extensions": [
18+
"ms-python.python"
19+
]
20+
}
21+
}
22+
}

.devcontainer/login.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
. /workspaces/venv/bin/activate
3+
4+
export GITHUB_TOKEN= # logout default account
5+
6+
if gh auth status -a 2>/dev/null | grep "Token scopes: " | grep -q "repo"; then # check `repo` scope exists or not
7+
echo "You were already logged into GitHub."
8+
else
9+
gh auth login -p https -w
10+
fi

.devcontainer/setup.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
3+
# define color codes
4+
GREEN="\033[0;32m"
5+
YELLOW="\033[1;33m"
6+
NC="\033[0m" # no color
7+
8+
set_or_add_remote() {
9+
local REMOTE_NAME=$1
10+
local REMOTE_URL=$2
11+
local REPO_PATH="/workspaces/$REPO_NAME"
12+
13+
git -C "$REPO_PATH" remote get-url "$REMOTE_NAME" &>/dev/null || git -C "$REPO_PATH" remote add "$REMOTE_NAME" "$REMOTE_URL"
14+
git -C "$REPO_PATH" remote set-url "$REMOTE_NAME" "$REMOTE_URL"
15+
}
16+
17+
setup_repo() {
18+
local DIR_NAME="$1"
19+
local DIR_PATH="/workspaces/$DIR_NAME"
20+
local REPO="Azure/$DIR_NAME"
21+
22+
if [ -d "$DIR_PATH" ]; then
23+
echo -e "\n${YELLOW}($DIR_NAME) Pulling the latest changes from upstream...${NC}"
24+
gh repo fork "$REPO" --clone=false
25+
else
26+
echo -e "\n${GREEN}($DIR_NAME) Forking and cloning the repository...${NC}"
27+
gh repo fork "$REPO" --clone=true
28+
fi
29+
30+
# git doesn't work well with private repository
31+
if [ "$(gh repo view "$REPO" --json visibility --jq '.visibility')" == "PRIVATE" ]; then
32+
cd "$DIR_PATH"
33+
gh repo sync --source "$REPO"
34+
cd /workspaces
35+
else
36+
DEFAULT_BRANCH=$(git -C "$DIR_PATH" remote show upstream | grep "HEAD branch" | awk '{print $NF}')
37+
git -C "$DIR_PATH" pull -r upstream "$DEFAULT_BRANCH"
38+
fi
39+
}
40+
41+
SECONDS=0
42+
43+
REPO_NAME=$(basename "$GITHUB_REPOSITORY")
44+
set_or_add_remote origin "https://github.com/$GITHUB_USER/$REPO_NAME.git"
45+
set_or_add_remote upstream "https://github.com/Azure/$REPO_NAME.git"
46+
47+
pip install aaz-dev
48+
49+
# azdev repositories
50+
setup_repo "azure-cli"
51+
setup_repo "azure-cli-extensions"
52+
53+
azdev setup -c -r ./azure-cli-extensions
54+
55+
# aaz-dev repositories
56+
setup_repo "aaz"
57+
setup_repo "azure-rest-api-specs"
58+
setup_repo "azure-rest-api-specs-pr"
59+
60+
ELAPSED_TIME=$SECONDS
61+
echo -e "\n${YELLOW}Elapsed time: $((ELAPSED_TIME / 60)) min $((ELAPSED_TIME % 60)) sec.${NC}"
62+
echo -e "${GREEN}Finished setup! Please launch the codegen tool via \`aaz-dev run -c azure-cli -e azure-cli-extensions -s azure-rest-api-specs -a aaz\`.${NC}\n"

.flake8

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@
22
max-line-length = 120
33
max-complexity = 10
44
ignore =
5-
E501, # line too long, it is covered by pylint
6-
E722, # bare except, bad practice, to be removed in the future
7-
F401, # imported but unused, too many violations, to be removed in the future
8-
F811, # redefinition of unused, to be removed in the future
9-
C901 # code flow is too complex, too many violations, to be removed in the future
10-
W503 # line break before binary operator effect on readability is subjective
11-
W504 # line break after binary operator effect on readability is subjective
5+
# line too long, it is covered by pylint
6+
E501
7+
# bare except, bad practice, to be removed in the future
8+
E722
9+
# imported but unused, too many violations, to be removed in the future
10+
F401
11+
# redefinition of unused, to be removed in the future
12+
F811
13+
# code flow is too complex, too many violations, to be removed in the future
14+
C901
15+
# line break before binary operator effect on readability is subjective
16+
W503
17+
# line break after binary operator effect on readability is subjective
18+
W504
1219
exclude =
1320
*/vendored_sdks
1421
docs

.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1+
# Set default behavior to automatically normalize line endings
2+
* text=auto
3+
4+
# Force bash scripts to use LF
5+
*.sh text eol=lf
6+
7+
# Force batch scripts to use CRLF
8+
*.bat text eol=crlf
9+
110
src/vmware/azext_vmware/tests/latest/recordings/*.yaml linguist-generated=true

.githooks/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
This option will bypass any pre-commit or pre-push hooks that are configured in the repository, allowing you to commit or push changes without running these checks.
20+
For example:
21+
Skipping verification during commit
22+
git commit -m "your commit message" --no-verify
23+
Skipping verification during push
24+
git push origin main --no-verify
25+
26+
## Note
27+
28+
### pre-commit
29+
30+
The pre-commit hook (`pre-commit.ps1`) performs the following checks:
31+
32+
1. Verifies that azdev is active in your current environment
33+
2. Runs `azdev scan` on all staged files to detect potential secrets
34+
3. If any secrets are detected, the commit will be blocked
35+
- You can use `azdev mask` to remove secrets before committing
36+
- Alternatively, use `git commit --no-verify` to bypass the check
37+
38+
### pre-push
39+
40+
The pre-push hooks (`pre-push.sh` for bash and `pre-push.ps1` for PowerShell) perform several quality checks:
41+
42+
1. Verifies that azdev is active in your current environment
43+
2. Detects which repository you're working in:
44+
- For azure-cli (when installed in editable mode):
45+
* Checks if your branch needs rebasing against upstream/dev
46+
* If rebasing is needed, displays instructions and provides a 5-second window to cancel
47+
- For extensions:
48+
* Automatically detects modified extensions
49+
* Adds them to the test scope using `azdev extension add`
50+
3. Runs the following quality checks on changed files:
51+
- `azdev lint`: Checks for linting issues
52+
- `azdev style`: Verifies code style compliance
53+
- `azdev test`: Runs tests for modified code/extensions
54+
4. If any check fails, the push will be blocked
55+
- Use `git push --no-verify` to bypass these checks (not recommended)
56+
57+
The hooks support both Windows (PowerShell) and Unix-like systems (Bash), automatically using the appropriate script for your environment.

0 commit comments

Comments
 (0)