-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2,594 changed files
with
353,135 additions
and
316,091 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
name: Azure CLI Sync Alias | ||
|
||
schedules: | ||
- cron: "50 15 * * 0" | ||
displayName: 11:50 PM (UTC + 8:00) China Weekly Run | ||
branches: | ||
include: | ||
- main | ||
|
||
# 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.' | ||
resources: | ||
repositories: | ||
- repository: ServiceContactList | ||
type: git | ||
name: internal.wiki | ||
|
||
jobs: | ||
- job: UpdateYaml | ||
displayName: Update resourceManagement.yml | ||
pool: pool-windows-2019 | ||
uses: | ||
repositories: | ||
- ServiceContactList | ||
|
||
steps: | ||
- task: UseDotNet@2 | ||
displayName: Install .NET 8 SDK | ||
inputs: | ||
packageType: sdk | ||
version: 8.0.x | ||
|
||
- pwsh: | | ||
dotnet --version | ||
dotnet new tool-manifest --force | ||
dotnet tool install powershell --version 7.4.* | ||
displayName: Install PowerShell 7.4.x | ||
- pwsh: | | ||
dotnet tool run pwsh -NoLogo -NoProfile -NonInteractive -File ./scripts/automation/ParseServiceContactsList.ps1 -AccessToken $env:SYSTEM_ACCESSTOKEN | ||
env: | ||
SYSTEM_ACCESSTOKEN: $(System.AccessToken) | ||
displayName: Update resourceManagement.yml file locally | ||
- pwsh: | | ||
$hasChanges = git diff --name-only .github/policies | ||
if ($null -eq $hasChanges) { | ||
Write-Host "The wiki has no changes." | ||
Write-Host "##vso[task.setvariable variable=ChangesDetected]false" | ||
} else { | ||
Write-Host "There are changes in the repository." | ||
Write-Host "##vso[task.setvariable variable=ChangesDetected]true" | ||
} | ||
displayName: Check if Wiki table has any changes | ||
- task: AzurePowerShell@5 | ||
inputs: | ||
pwsh: true | ||
azureSubscription: '$(AZURE_SDK_INFRA_SUB_CONNECTED_SERVICE)' | ||
ScriptType: 'InlineScript' | ||
Inline: | | ||
$GithubToken = Get-AzKeyVaultSecret -VaultName $(GithubPATKeyVaultName) -Name $(GithubPATKeyVaultAccount) -AsPlainText | ||
Write-Host "##vso[task.setvariable variable=GithubToken;issecret=true]$GithubToken" | ||
azurePowerShellVersion: 'LatestVersion' | ||
displayName: Get Github PAT from Key Vault | ||
|
||
- pwsh: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Azure CLI Team" | ||
git checkout -b "sync_alias_$env:Build_BuildId" | ||
git add .github/policies | ||
git commit -m "Sync resourceManagement.yml" | ||
git remote set-url origin https://azclibot:$(GithubToken)@github.com/Azure/azure-cli-extensions.git; | ||
git push origin "sync_alias_$env:Build_BuildId" --force | ||
displayName: Git commit and push | ||
condition: and(succeeded(), eq(variables['ChangesDetected'], 'true')) | ||
- pwsh: | | ||
$Title = "{CI} Sync resourceManagement.yml according To ADO Wiki Page - Service Contact List" | ||
$HeadBranch = "sync_alias_$env:Build_BuildId" | ||
$BaseBranch = "main" | ||
$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" | ||
$Headers = @{"Accept" = "application/vnd.github+json"; "Authorization" = "Bearer $(GithubToken)" } | ||
$RequestBody = @{"title" = $Title; "body" = $Description; "head" = $HeadBranch; "base" = $BaseBranch;} | ||
$Uri = "https://api.github.com/repos/Azure/azure-cli-extensions/pulls" | ||
Invoke-WebRequest -Uri $Uri -Method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) | ||
displayName: Create PR to main branch | ||
condition: and(succeeded(), eq(variables['ChangesDetected'], 'true')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "Azure CLI Dev Container", | ||
"image": "mcr.microsoft.com/devcontainers/python:3.12", | ||
"features": { | ||
"ghcr.io/devcontainers/features/github-cli:1": {} | ||
}, | ||
"workspaceFolder": "/workspaces", | ||
"onCreateCommand": "python -m venv venv", | ||
"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", | ||
"hostRequirements": { | ||
"cpus": 16, | ||
"memory": "64gb", | ||
"storage": "128gb" | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-python.python" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
. /workspaces/venv/bin/activate | ||
|
||
export GITHUB_TOKEN= # logout default account | ||
|
||
if gh auth status -a 2>/dev/null | grep "Token scopes: " | grep -q "repo"; then # check `repo` scope exists or not | ||
echo "You were already logged into GitHub." | ||
else | ||
gh auth login -p https -w | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/bash | ||
|
||
# define color codes | ||
GREEN="\033[0;32m" | ||
YELLOW="\033[1;33m" | ||
NC="\033[0m" # no color | ||
|
||
set_or_add_remote() { | ||
local REMOTE_NAME=$1 | ||
local REMOTE_URL=$2 | ||
local REPO_PATH="/workspaces/$REPO_NAME" | ||
|
||
git -C "$REPO_PATH" remote get-url "$REMOTE_NAME" &>/dev/null || git -C "$REPO_PATH" remote add "$REMOTE_NAME" "$REMOTE_URL" | ||
git -C "$REPO_PATH" remote set-url "$REMOTE_NAME" "$REMOTE_URL" | ||
} | ||
|
||
setup_repo() { | ||
local DIR_NAME="$1" | ||
local DIR_PATH="/workspaces/$DIR_NAME" | ||
local REPO="Azure/$DIR_NAME" | ||
|
||
if [ -d "$DIR_PATH" ]; then | ||
echo -e "\n${YELLOW}($DIR_NAME) Pulling the latest changes from upstream...${NC}" | ||
gh repo fork "$REPO" --clone=false | ||
else | ||
echo -e "\n${GREEN}($DIR_NAME) Forking and cloning the repository...${NC}" | ||
gh repo fork "$REPO" --clone=true | ||
fi | ||
|
||
# git doesn't work well with private repository | ||
if [ "$(gh repo view "$REPO" --json visibility --jq '.visibility')" == "PRIVATE" ]; then | ||
cd "$DIR_PATH" | ||
gh repo sync --source "$REPO" | ||
cd /workspaces | ||
else | ||
DEFAULT_BRANCH=$(git -C "$DIR_PATH" remote show upstream | grep "HEAD branch" | awk '{print $NF}') | ||
git -C "$DIR_PATH" pull -r upstream "$DEFAULT_BRANCH" | ||
fi | ||
} | ||
|
||
SECONDS=0 | ||
|
||
REPO_NAME=$(basename "$GITHUB_REPOSITORY") | ||
set_or_add_remote origin "https://github.com/$GITHUB_USER/$REPO_NAME.git" | ||
set_or_add_remote upstream "https://github.com/Azure/$REPO_NAME.git" | ||
|
||
pip install aaz-dev | ||
|
||
# azdev repositories | ||
setup_repo "azure-cli" | ||
setup_repo "azure-cli-extensions" | ||
|
||
azdev setup -c -r ./azure-cli-extensions | ||
|
||
# aaz-dev repositories | ||
setup_repo "aaz" | ||
setup_repo "azure-rest-api-specs" | ||
setup_repo "azure-rest-api-specs-pr" | ||
|
||
ELAPSED_TIME=$SECONDS | ||
echo -e "\n${YELLOW}Elapsed time: $((ELAPSED_TIME / 60)) min $((ELAPSED_TIME % 60)) sec.${NC}" | ||
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,10 @@ | ||
# Set default behavior to automatically normalize line endings | ||
* text=auto | ||
|
||
# Force bash scripts to use LF | ||
*.sh text eol=lf | ||
|
||
# Force batch scripts to use CRLF | ||
*.bat text eol=crlf | ||
|
||
src/vmware/azext_vmware/tests/latest/recordings/*.yaml linguist-generated=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Git Hooks for Azure CLI Extension Development | ||
|
||
## Setup | ||
|
||
Please run the following command to enable the hooks. | ||
|
||
```bash | ||
azdev setup -c {azure_cli_repo_path} -r {azure_cli_extension_repo_path} | ||
|
||
# if you install azdev which version is less than 0.1.84, you need to run the following command to enable the hooks | ||
git config --local core.hooksPath .githooks | ||
``` | ||
|
||
## Usage | ||
|
||
Every time you git commit or git push, please make sure you have activated the python environment and completed the azdev setup. | ||
|
||
If you want to skip the verification, you can add `--no-verify` to the git command. | ||
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. | ||
For example: | ||
Skipping verification during commit | ||
git commit -m "your commit message" --no-verify | ||
Skipping verification during push | ||
git push origin main --no-verify | ||
|
||
## Note | ||
|
||
### pre-commit | ||
|
||
The pre-commit hook (`pre-commit.ps1`) performs the following checks: | ||
|
||
1. Verifies that azdev is active in your current environment | ||
2. Runs `azdev scan` on all staged files to detect potential secrets | ||
3. If any secrets are detected, the commit will be blocked | ||
- You can use `azdev mask` to remove secrets before committing | ||
- Alternatively, use `git commit --no-verify` to bypass the check | ||
|
||
### pre-push | ||
|
||
The pre-push hooks (`pre-push.sh` for bash and `pre-push.ps1` for PowerShell) perform several quality checks: | ||
|
||
1. Verifies that azdev is active in your current environment | ||
2. Detects which repository you're working in: | ||
- For azure-cli (when installed in editable mode): | ||
* Checks if your branch needs rebasing against upstream/dev | ||
* If rebasing is needed, displays instructions and provides a 5-second window to cancel | ||
- For extensions: | ||
* Automatically detects modified extensions | ||
* Adds them to the test scope using `azdev extension add` | ||
3. Runs the following quality checks on changed files: | ||
- `azdev lint`: Checks for linting issues | ||
- `azdev style`: Verifies code style compliance | ||
- `azdev test`: Runs tests for modified code/extensions | ||
4. If any check fails, the push will be blocked | ||
- Use `git push --no-verify` to bypass these checks (not recommended) | ||
|
||
The hooks support both Windows (PowerShell) and Unix-like systems (Bash), automatically using the appropriate script for your environment. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Check if in the python environment | ||
$pythonPath = (Get-Command python -ErrorAction SilentlyContinue).Path | ||
Write-Host "PYTHON_PATH: $pythonPath" | ||
|
||
if (-not $pythonPath) { | ||
Write-Host "Error: Python not found in PATH" -ForegroundColor Red | ||
exit 1 | ||
} | ||
|
||
$pythonEnvFolder = Split-Path -Parent (Split-Path -Parent $pythonPath) | ||
$pythonActiveFile = Join-Path $pythonEnvFolder "Scripts\activate.ps1" | ||
|
||
if (-not (Test-Path $pythonActiveFile)) { | ||
Write-Host "Python active file does not exist: $pythonActiveFile" -ForegroundColor Red | ||
Write-Host "Error: Please activate the python environment first." -ForegroundColor Red | ||
exit 1 | ||
} | ||
|
||
# Construct the full path to the .azdev\env_config directory | ||
$azdevEnvConfigFolder = Join-Path $env:USERPROFILE ".azdev\env_config" | ||
Write-Host "AZDEV_ENV_CONFIG_FOLDER: $azdevEnvConfigFolder" | ||
|
||
# Check if the directory exists | ||
if (-not (Test-Path $azdevEnvConfigFolder)) { | ||
Write-Host "AZDEV_ENV_CONFIG_FOLDER does not exist: $azdevEnvConfigFolder" -ForegroundColor Red | ||
Write-Host "Error: azdev environment is not completed, please run 'azdev setup' first." -ForegroundColor Red | ||
exit 1 | ||
} | ||
|
||
$configFile = Join-Path $azdevEnvConfigFolder ($pythonEnvFolder.Substring(2) + "\config") | ||
if (-not (Test-Path $configFile)) { | ||
Write-Host "CONFIG_FILE does not exist: $configFile" -ForegroundColor Red | ||
Write-Host "Error: azdev environment is not completed, please run 'azdev setup' first." -ForegroundColor Red | ||
exit 1 | ||
} | ||
|
||
Write-Host "CONFIG_FILE: $configFile" | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
# Check if in the python environment | ||
PYTHON_FILE=$(which python) | ||
printf "PYTHON_PATH: %s\n" "$PYTHON_FILE" | ||
|
||
if [ -z "$PYTHON_FILE" ]; then | ||
printf "\033[0;31mError: Python not found in PATH\033[0m\n" | ||
exit 1 | ||
fi | ||
|
||
PYTHON_ENV_FOLDER=$(dirname "$PYTHON_FILE") | ||
PYTHON_ACTIVE_FILE="$PYTHON_ENV_FOLDER/activate" | ||
|
||
if [ ! -f "$PYTHON_ACTIVE_FILE" ]; then | ||
printf "Python active file does not exist: %s\n" "$PYTHON_ACTIVE_FILE" | ||
printf "\033[0;31mError: Please activate the python environment first.\033[0m\n" | ||
exit 1 | ||
fi | ||
|
||
# Construct the full path to the .azdev/env_config directory | ||
AZDEV_ENV_CONFIG_FOLDER="$HOME/.azdev/env_config" | ||
printf "AZDEV_ENV_CONFIG_FOLDER: %s\n" "$AZDEV_ENV_CONFIG_FOLDER" | ||
|
||
# Check if the directory exists | ||
if [ ! -d "$AZDEV_ENV_CONFIG_FOLDER" ]; then | ||
printf "AZDEV_ENV_CONFIG_FOLDER does not exist: %s\n" "$AZDEV_ENV_CONFIG_FOLDER" | ||
printf "\033[0;31mError: azdev environment is not completed, please run 'azdev setup' first.\033[0m\n" | ||
exit 1 | ||
fi | ||
|
||
PYTHON_ENV_FOLDER=$(dirname "$PYTHON_ENV_FOLDER") | ||
|
||
CONFIG_FILE="$AZDEV_ENV_CONFIG_FOLDER${PYTHON_ENV_FOLDER}/config" | ||
if [ ! -f "$CONFIG_FILE" ]; then | ||
printf "CONFIG_FILE does not exist: %s\n" "$CONFIG_FILE" | ||
printf "\033[0;31mError: azdev environment is not completed, please run 'azdev setup' first.\033[0m\n" | ||
exit 1 | ||
fi | ||
|
||
printf "CONFIG_FILE: %s\n" "$CONFIG_FILE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env sh | ||
":" //; 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 | ||
":" //; exit # Skip rest on Unix | ||
|
||
@echo off | ||
powershell -NoProfile -Command "if (Get-Command powershell -ErrorAction SilentlyContinue) { exit 0 } else { exit 1 }" | ||
if %errorlevel% equ 0 ( | ||
powershell -ExecutionPolicy Bypass -File .githooks\pre-commit.ps1 | ||
) else ( | ||
echo Error: PowerShell is not available. Please install PowerShell. | ||
exit /b 1 | ||
) | ||
exit /b %errorlevel% |
Oops, something went wrong.