Skip to content

Commit 3eb47eb

Browse files
Fix release validation to parse YAML instead of grepping comments
The validate-packages-yml job was using grep to check for git hash references in packages.yml, which also matched commented-out lines. This caused the release to fail even though the actual YAML config was correct. Replace the grep-based validation with a Python script that properly parses the YAML, ignoring comments and only checking actual package entries. Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
1 parent 0f1c676 commit 3eb47eb

1 file changed

Lines changed: 39 additions & 10 deletions

File tree

.github/workflows/release.yml

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,47 @@ jobs:
1515
- name: Checkout Elementary
1616
uses: actions/checkout@v4
1717

18+
- name: Setup Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.10"
22+
23+
- name: Install PyYAML
24+
run: pip install pyyaml
25+
1826
- name: Validate dbt-data-reliability is not a git hash reference
1927
run: |
20-
PACKAGES_FILE="./elementary/monitor/dbt_project/packages.yml"
21-
if grep -q 'git: https://github.com/elementary-data/dbt-data-reliability.git' "$PACKAGES_FILE"; then
22-
echo "::error::packages.yml contains a git hash reference for dbt-data-reliability. Releases must use a proper package version (e.g. 'package: elementary-data/elementary' with a 'version:' field). Please update packages.yml before releasing."
23-
exit 1
24-
fi
25-
if ! grep -q 'package: elementary-data/elementary' "$PACKAGES_FILE"; then
26-
echo "::error::packages.yml does not contain a proper package reference for elementary-data/elementary. Please update packages.yml before releasing."
27-
exit 1
28-
fi
29-
echo "packages.yml validation passed - using proper package version reference."
28+
python - <<'EOF'
29+
import yaml
30+
import sys
31+
32+
packages_file = "./elementary/monitor/dbt_project/packages.yml"
33+
with open(packages_file) as f:
34+
data = yaml.safe_load(f)
35+
36+
packages = data.get("packages", [])
37+
38+
has_git_ref = any(
39+
"git" in pkg and "dbt-data-reliability" in pkg["git"]
40+
for pkg in packages
41+
)
42+
if has_git_ref:
43+
print("::error::packages.yml contains a git hash reference for dbt-data-reliability. "
44+
"Releases must use a proper package version (e.g. 'package: elementary-data/elementary' "
45+
"with a 'version:' field). Please update packages.yml before releasing.")
46+
sys.exit(1)
47+
48+
has_package_ref = any(
49+
pkg.get("package") == "elementary-data/elementary"
50+
for pkg in packages
51+
)
52+
if not has_package_ref:
53+
print("::error::packages.yml does not contain a proper package reference for "
54+
"elementary-data/elementary. Please update packages.yml before releasing.")
55+
sys.exit(1)
56+
57+
print("packages.yml validation passed - using proper package version reference.")
58+
EOF
3059
3160
publish-to-pypi:
3261
needs: validate-packages-yml

0 commit comments

Comments
 (0)