Skip to content

Commit 921e620

Browse files
authored
add gh jobs (#31284)
1 parent 11f6022 commit 921e620

File tree

3 files changed

+158
-0
lines changed

3 files changed

+158
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: GH Azdev Setup
2+
description: 'azdev env setup'
3+
4+
runs:
5+
using: 'composite'
6+
steps:
7+
- name: Check Init GH Event
8+
env:
9+
action: ${{ toJSON(github.event.action) }}
10+
label: ${{ toJSON(github.event.label) }}
11+
shell: bash
12+
run: |
13+
echo start azdev env setup
14+
- name: Checkout CLI repo
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0 # checkout all branches
18+
ref: ${{ github.event.pull_request.head.ref }}
19+
repository: ${{ github.event.pull_request.head.repo.full_name }} # checkout pull request branch
20+
- name: Set up Python 3.12
21+
uses: actions/setup-python@v3
22+
with:
23+
python-version: "3.12"
24+
- name: Install azdev
25+
shell: bash
26+
run: |
27+
python -m pip install --upgrade pip
28+
set -ev
29+
python -m venv env
30+
chmod +x env/bin/activate
31+
source ./env/bin/activate
32+
pip install azdev
33+
azdev --version
34+
cd ../
35+
azdev setup -c azure-cli --debug
36+
az --version
37+
pip list -v

.github/workflows/AzdevLinter.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: GH Check CLI Linter
2+
on:
3+
pull_request_target:
4+
types: [opened, labeled, unlabeled, synchronize]
5+
branches:
6+
- dev
7+
8+
permissions: {}
9+
10+
jobs:
11+
azdev-linter:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
pull-requests: read
15+
contents: read
16+
steps:
17+
- name: Checkout CLI repo
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 1
21+
sparse-checkout: |
22+
.github
23+
- name: Azdev Env Setup
24+
uses: ./.github/actions/env-setup
25+
- name: Get Base Branch
26+
env:
27+
bash_sha: ${{ github.event.pull_request.base.sha }}
28+
base_branch: ${{ github.event.pull_request.base.ref }}
29+
base_repo: ${{ github.event.pull_request.base.repo.clone_url }}
30+
base_branch_pre: "upstream"
31+
diff_sha: ${{ github.event.pull_request.head.sha }}
32+
diff_branch: ${{ github.event.pull_request.head.ref }}
33+
repo_full_name: ${{ github.event.pull_request.head.repo.full_name }}
34+
run: |
35+
set -x
36+
git --version
37+
git log --oneline | head -n 10
38+
git branch -a
39+
git fetch "$base_repo" "$base_branch":"$base_branch_pre"/"$base_branch"
40+
git checkout "$base_branch_pre"/"$base_branch"
41+
- name: Run Azdev Style
42+
env:
43+
pr_label_list: ${{ toJson(github.event.pull_request.labels.*.name) }}
44+
pr_user: ${{ github.event.pull_request.user.login }}
45+
base_branch: ${{ github.event.pull_request.base.ref }}
46+
base_branch_pre: "upstream"
47+
diff_branch: ${{ github.event.pull_request.head.ref }}
48+
run: |
49+
chmod +x env/bin/activate
50+
source ./env/bin/activate
51+
set -ev
52+
53+
git checkout -f "$diff_branch"
54+
# always use the latest scripts from base branch
55+
git checkout "$base_branch_pre"/"$base_branch" -- scripts
56+
git checkout "$base_branch_pre"/"$base_branch" -- .github
57+
58+
python scripts/ci/service_name.py
59+
merge_base=$(git merge-base HEAD "$base_branch_pre"/"$base_branch")
60+
echo merge_base: "$merge_base"
61+
azdev linter --ci-exclusions --min-severity medium --repo ./ --src "$diff_branch" --tgt "$merge_base"

.github/workflows/AzdevStyle.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: GH Check CLI Style
2+
on:
3+
pull_request_target:
4+
types: [opened, labeled, unlabeled, synchronize]
5+
branches:
6+
- dev
7+
8+
permissions: {}
9+
10+
jobs:
11+
azdev-style:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
pull-requests: read
15+
contents: read
16+
steps:
17+
- name: Checkout CLI repo
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 1
21+
sparse-checkout: |
22+
.github
23+
- name: Azdev Env Setup
24+
uses: ./.github/actions/env-setup
25+
- name: Get Base Branch
26+
env:
27+
bash_sha: ${{ github.event.pull_request.base.sha }}
28+
base_branch: ${{ github.event.pull_request.base.ref }}
29+
base_repo: ${{ github.event.pull_request.base.repo.clone_url }}
30+
base_branch_pre: "upstream"
31+
diff_sha: ${{ github.event.pull_request.head.sha }}
32+
diff_branch: ${{ github.event.pull_request.head.ref }}
33+
repo_full_name: ${{ github.event.pull_request.head.repo.full_name }}
34+
run: |
35+
set -x
36+
git --version
37+
git log --oneline | head -n 10
38+
git branch -a
39+
git fetch "$base_repo" "$base_branch":"$base_branch_pre"/"$base_branch"
40+
git checkout "$base_branch_pre"/"$base_branch"
41+
- name: Run Azdev Style
42+
env:
43+
pr_label_list: ${{ toJson(github.event.pull_request.labels.*.name) }}
44+
pr_user: ${{ github.event.pull_request.user.login }}
45+
base_branch: ${{ github.event.pull_request.base.ref }}
46+
base_branch_pre: "upstream"
47+
diff_branch: ${{ github.event.pull_request.head.ref }}
48+
run: |
49+
chmod +x env/bin/activate
50+
source ./env/bin/activate
51+
set -ev
52+
53+
git checkout -f "$diff_branch"
54+
# always use the latest scripts from base branch
55+
git checkout "$base_branch_pre"/"$base_branch" -- scripts
56+
git checkout "$base_branch_pre"/"$base_branch" -- .github
57+
merge_base=$(git merge-base HEAD "$base_branch_pre"/"$base_branch")
58+
echo merge_base: "$merge_base"
59+
# check azdev style on diff mod
60+
azdev style

0 commit comments

Comments
 (0)