Repository navigation
170 lines (159 loc) · 6.78 KB
/
Copy pathpr_supplement_new_tests.yaml
File metadata and controls
170 lines (159 loc) · 6.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Supplement New Tests
# pull_request_target is required so OBS secrets are available for fork PRs.
# Collect from the GitHub three-dot PR diff, not the merge/squash commit.
on:
pull_request_target:
types: [closed]
permissions:
contents: read
jobs:
upload-merged-new-tests:
name: Supplement New Tests
if: >-
${{
github.event.pull_request.merged == true &&
(
github.event.pull_request.base.ref == 'main' ||
startsWith(github.event.pull_request.base.ref, 'releases/v')
)
}}
runs-on: linux-amd64-cpu-8-hk
env:
OBS_ACCESS_KEY: ${{ secrets.OBS_ACCESS_KEY_PRECISION }}
OBS_SECRET_KEY: ${{ secrets.OBS_SECRET_ACCESS_KEY_PRECISION }}
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.base.ref }}
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v7
with:
python-version: "3.12"
- name: Resolve supported target branch
id: target
env:
BASE_REF: ${{ github.event.pull_request.base.ref }}
run: |
set -euo pipefail
if [ "${BASE_REF}" = "main" ]; then
{
echo "supported=true"
echo "obs_object=ci/precision-test/extra_recommended_tests.yaml"
} >> "$GITHUB_OUTPUT"
exit 0
fi
POINTER_URL="https://vllm-ascend.obs.cn-north-4.myhuaweicloud.com/ci/precision-test/coverage_release_branch.txt"
curl -sSL --retry 3 -o coverage_release_branch.txt "${POINTER_URL}" || true
python3 - <<'PY'
import os
base_ref = os.environ["BASE_REF"]
pointer_path = "coverage_release_branch.txt"
recorded = ""
if os.path.isfile(pointer_path):
recorded = open(pointer_path, encoding="utf-8").read().strip()
supported = recorded == base_ref
if supported:
print(f"PR targets the release branch recorded by coverage: {recorded}")
else:
print(f"Skip PR targeting {base_ref}; coverage_release_branch.txt records {recorded or '<empty>'}")
obs_object = ""
if supported:
version = base_ref.split("/", 1)[1]
obs_object = f"ci/precision-test/extra_recommended_tests-{version}.yaml"
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output:
print(f"supported={str(supported).lower()}", file=output)
print(f"obs_object={obs_object}", file=output)
PY
- name: Collect new or moved tests
id: collect
if: ${{ steps.target.outputs.supported == 'true' }}
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_BASE: ${{ github.event.pull_request.base.sha }}
MERGE_SHA: ${{ github.event.pull_request.merge_commit_sha }}
run: |
set -euo pipefail
git config --global --add safe.directory "$GITHUB_WORKSPACE"
# GitHub keeps refs/pull/<n>/head on the base repo. Three-dot
# PR_BASE...PR_HEAD is the Files changed tab, even if PR_BASE is stale.
git fetch origin "pull/${PR_NUMBER}/head" --no-tags
PR_HEAD=$(git rev-parse FETCH_HEAD)
echo "pr-number=${PR_NUMBER}"
echo "pr-base=${PR_BASE}"
echo "pr-head=${PR_HEAD}"
echo "merge=${MERGE_SHA}"
python3 .github/workflows/scripts/collect_merged_new_tests.py \
--pr-base "${PR_BASE}" \
--pr-head "${PR_HEAD}" \
--output merged_new_tests.yaml \
--pr-number "${PR_NUMBER}" \
--merge-sha "${MERGE_SHA}"
if [ -s merged_new_tests.yaml ]; then
echo "has_tests=true" >> "$GITHUB_OUTPUT"
echo "Collected tests:"
cat merged_new_tests.yaml
else
echo "has_tests=false" >> "$GITHUB_OUTPUT"
echo "No new or moved tests to upload"
fi
- name: Merge into OBS extra_recommended_tests.yaml
id: merge
if: ${{ steps.collect.outputs.has_tests == 'true' }}
env:
OBS_OBJECT: ${{ steps.target.outputs.obs_object }}
run: |
set -euo pipefail
OBS_URL="https://vllm-ascend.obs.cn-north-4.myhuaweicloud.com/${OBS_OBJECT}"
python3 -m pip install pyyaml --quiet
http_code=$(curl -sSL --retry 3 -o extra_recommended_tests.yaml -w "%{http_code}" "${OBS_URL}" || echo "000")
if [ "${http_code}" = "200" ] && [ -s extra_recommended_tests.yaml ]; then
echo "Downloaded existing ${OBS_OBJECT} from OBS"
elif [ "${http_code}" = "404" ] || [ "${http_code}" = "403" ]; then
# Anonymous reads return 403 when the object does not exist.
echo "No ${OBS_OBJECT} on OBS yet (HTTP ${http_code}); starting a new file"
: > extra_recommended_tests.yaml
else
echo "::error::Failed to download ${OBS_OBJECT} from OBS (HTTP ${http_code})"
exit 1
fi
python3 .github/workflows/scripts/merge_extra_recommended_tests.py \
--extra-yaml extra_recommended_tests.yaml \
--incoming-yaml merged_new_tests.yaml \
--output-yaml extra_recommended_tests.yaml \
| tee merge.out
if grep -q "^Appended " merge.out; then
echo "has_new_paths=true" >> "$GITHUB_OUTPUT"
echo "Merged extra yaml:"
cat extra_recommended_tests.yaml
else
echo "has_new_paths=false" >> "$GITHUB_OUTPUT"
echo "No new paths to upload"
fi
- name: Upload extra_recommended_tests.yaml to OBS
if: ${{ steps.merge.outputs.has_new_paths == 'true' }}
env:
OBS_OBJECT: ${{ steps.target.outputs.obs_object }}
run: |
set -euo pipefail
if [ -z "${OBS_ACCESS_KEY}" ] || [ -z "${OBS_SECRET_KEY}" ]; then
echo "::error::OBS credentials are missing"
exit 1
fi
python3 -m pip install esdk-obs-python --quiet
python3 - <<'EOF'
import os
from obs import ObsClient
obs_path = os.environ['OBS_OBJECT']
client = ObsClient(
access_key_id=os.environ['OBS_ACCESS_KEY'],
secret_access_key=os.environ['OBS_SECRET_KEY'],
server='https://obs.cn-north-4.myhuaweicloud.com',
)
resp = client.putFile('vllm-ascend', obs_path, 'extra_recommended_tests.yaml')
if resp.status >= 300:
raise Exception(f'Failed to upload {obs_path}: {resp.errorMessage}')
print(f'Uploaded extra_recommended_tests.yaml -> {obs_path}')
print('https://vllm-ascend.obs.cn-north-4.myhuaweicloud.com/' + obs_path)
EOF