Skip to content

Commit 1545e20

Browse files
committed
get the pipeline fixed
1 parent eb14dea commit 1545e20

File tree

3 files changed

+47
-13
lines changed

3 files changed

+47
-13
lines changed

.github/workflows/update-azure-coverage.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ on:
99
required: true
1010
type: string
1111
description: "Branch to checkout and compare against (e.g. harshmishra/doc-91)"
12-
pull_request:
13-
types: [opened, synchronize]
1412

1513
jobs:
1614
update-azure-coverage:
@@ -25,7 +23,7 @@ jobs:
2523
with:
2624
fetch-depth: 0
2725
path: docs
28-
ref: ${{ github.event.inputs.targetBranch }}
26+
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.targetBranch || 'main' }}
2927

3028
- name: Set up system wide dependencies
3129
run: |
@@ -42,20 +40,25 @@ jobs:
4240
env:
4341
GITHUB_TOKEN: ${{ secrets.PRO_ACCESS_TOKEN }}
4442
REPOSITORY_NAME: localstack-pro
45-
ARTIFACT_ID: implemented_features_python-amd64.csv
43+
ARTIFACT_ID: implemented_features_python-amd64
4644
WORKFLOW: "Az / Build, Test, Push"
4745

4846
- name: Generate Azure coverage JSON data
4947
working-directory: docs
5048
run: |
51-
python3 scripts/create_azure_coverage.py -i target/implemented_features_python-amd64.csv/implemented_features.csv -o target/updated_azure_coverage
52-
mv -f target/updated_azure_coverage/*.json src/data/azure-coverage/
49+
python3 scripts/create_azure_coverage.py -i target/implemented_features.csv -o target/updated_azure_coverage
50+
if ls target/updated_azure_coverage/*.json > /dev/null 2>&1; then
51+
mv -f target/updated_azure_coverage/*.json src/data/azure-coverage/
52+
else
53+
echo "No JSON files generated in target/updated_azure_coverage."
54+
exit 1
55+
fi
5356
5457
- name: Check for changes
5558
id: check-for-changes
5659
working-directory: docs
5760
env:
58-
TARGET_BRANCH: ${{ github.event.inputs.targetBranch }}
61+
TARGET_BRANCH: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.targetBranch || 'main' }}
5962
run: |
6063
mkdir -p resources
6164
(git diff --name-only origin/automated-azure-coverage-updates src/data/azure-coverage/ 2>/dev/null || git diff --name-only "origin/$TARGET_BRANCH" src/data/azure-coverage/ 2>/dev/null) | tee -a resources/diff-check.log

scripts/create_azure_coverage.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ def _load_csv(path: Path) -> dict[str, dict[str, dict[str, dict[str, Any]]]]:
6363
reader = csv.DictReader(file)
6464
if not reader.fieldnames:
6565
raise ValueError("Input CSV has no headers.")
66+
required_headers = {"resource_provider", "service", "feature"}
67+
if not required_headers.issubset(set(reader.fieldnames)):
68+
raise ValueError(
69+
"Unexpected CSV schema. Expected headers including "
70+
f"{sorted(required_headers)}, got {reader.fieldnames}. "
71+
"The downloaded artifact may contain an error payload instead of CSV data."
72+
)
6673

6774
for row in reader:
6875
provider = _normalize_provider(row.get("resource_provider", ""))
@@ -90,6 +97,12 @@ def _load_csv(path: Path) -> dict[str, dict[str, dict[str, dict[str, Any]]]]:
9097
"pro": pro_only,
9198
}
9299

100+
if not coverage:
101+
raise ValueError(
102+
"No Azure coverage records were parsed from the input CSV. "
103+
"Please verify the artifact content is valid and non-empty."
104+
)
105+
93106
return coverage
94107

95108

scripts/get_latest_github_metrics.sh

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ METRICS_ARTIFACTS_BRANCH=${2:-main}
77

88
# env vars
99
REPOSITORY_NAME=${REPOSITORY_NAME:-localstack-pro}
10-
ARTIFACT_ID=${ARTIFACT_ID:-implemented_features_python-amd64.csv}
10+
ARTIFACT_ID=${ARTIFACT_ID:-implemented_features_python-amd64}
1111
WORKFLOW=${WORKFLOW:-"Az / Build, Test, Push"}
1212
PREFIX_ARTIFACT=${PREFIX_ARTIFACT:-}
1313
FILTER_SUCCESS=${FILTER_SUCCESS:-1}
@@ -30,15 +30,28 @@ else
3030
SELECTOR='.[] | select(.status=="completed" and (.conclusion=="failure" or .conclusion=="success"))'
3131
fi
3232

33-
RUN_IDS=$(gh run list --limit "$LIMIT" --branch "$METRICS_ARTIFACTS_BRANCH" --repo "$REPOSITORY_OWNER/$REPOSITORY_NAME" --workflow "$WORKFLOW" --json databaseId,conclusion,status --jq "$SELECTOR")
33+
RUN_IDS=()
34+
while IFS= read -r run_id; do
35+
RUN_IDS+=("$run_id")
36+
done < <(
37+
gh run list \
38+
--limit "$LIMIT" \
39+
--branch "$METRICS_ARTIFACTS_BRANCH" \
40+
--repo "$REPOSITORY_OWNER/$REPOSITORY_NAME" \
41+
--workflow "$WORKFLOW" \
42+
--json databaseId,conclusion,status \
43+
--jq "$SELECTOR | .databaseId"
44+
)
3445

35-
if [ "$(echo "$RUN_IDS" | jq -rs '.[0].databaseId')" = "null" ]; then
36-
echo "No matching workflow run found."
46+
if [ "${#RUN_IDS[@]}" -eq 0 ]; then
47+
echo "No matching workflow runs found."
3748
exit 1
3849
fi
3950

40-
for ((i=0; i<LIMIT; i++)); do
41-
RUN_ID=$(echo "$RUN_IDS" | jq -rs ".[$i].databaseId")
51+
for RUN_ID in "${RUN_IDS[@]}"; do
52+
if [ -z "$RUN_ID" ] || [ "$RUN_ID" = "null" ]; then
53+
continue
54+
fi
4255
echo "Trying run id: $RUN_ID"
4356

4457
gh run download "$RUN_ID" --repo "$REPOSITORY_OWNER/$REPOSITORY_NAME" -p "$ARTIFACT_ID" -D "$TMP_FOLDER" || true
@@ -49,6 +62,11 @@ for ((i=0; i<LIMIT; i++)); do
4962
fi
5063
done
5164

65+
if [ "$(ls -1 "$TMP_FOLDER" 2>/dev/null | wc -l)" -eq 0 ]; then
66+
echo "Failed to download artifact '$ARTIFACT_ID' from the checked workflow runs."
67+
exit 1
68+
fi
69+
5270
echo "Moving artifact to $TARGET_FOLDER"
5371
mkdir -p "$TARGET_FOLDER"
5472
if [[ -z "${PREFIX_ARTIFACT}" ]]; then

0 commit comments

Comments
 (0)