|
| 1 | +# ============================================================================== |
| 2 | +# This workflow: |
| 3 | +# 1. Checks out cdisc-rules-engine (the engine itself) |
| 4 | +# 2. Checks out cdisc-open-rules (rules + test data) into ./open-rules/ |
| 5 | +# 3. Installs engine Python dependencies |
| 6 | +# 4. Iterates every Published/ rule from cdisc-open-rules |
| 7 | +# 5. Runs the engine against each test case |
| 8 | +# 6. Compares actual output with expected results.csv baseline |
| 9 | +# 7. Publishes a Markdown report to Job Summary and as an artifact |
| 10 | +# ============================================================================== |
| 11 | +name: Validate Published Rules |
| 12 | + |
| 13 | +on: |
| 14 | + push: |
| 15 | + branches: |
| 16 | + - main |
| 17 | + workflow_dispatch: |
| 18 | + inputs: |
| 19 | + rules_ref: |
| 20 | + description: "Branch/tag/SHA of cdisc-open-rules to validate against" |
| 21 | + required: false |
| 22 | + default: "main" |
| 23 | + core_ids: |
| 24 | + description: "Space-separated list of rule IDs to validate (e.g. CORE-000001 CORE-000002). Leave blank to validate all." |
| 25 | + required: false |
| 26 | + default: "" |
| 27 | + |
| 28 | +jobs: |
| 29 | + validate-published-rules: |
| 30 | + runs-on: ubuntu-latest |
| 31 | + permissions: |
| 32 | + contents: read |
| 33 | + |
| 34 | + steps: |
| 35 | + # ----------------------------------------------------------------------- |
| 36 | + # 1. Checkout cdisc-rules-engine |
| 37 | + # ----------------------------------------------------------------------- |
| 38 | + - name: Checkout cdisc-rules-engine |
| 39 | + uses: actions/checkout@v6 |
| 40 | + with: |
| 41 | + repository: cdisc-org/cdisc-rules-engine |
| 42 | + path: engine |
| 43 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + |
| 45 | + # ----------------------------------------------------------------------- |
| 46 | + # 2. Checkout cdisc-open-rules (rules + test data + helper scripts) |
| 47 | + # ----------------------------------------------------------------------- |
| 48 | + - name: Checkout cdisc-open-rules |
| 49 | + uses: actions/checkout@v6 |
| 50 | + with: |
| 51 | + repository: cdisc-org/cdisc-open-rules |
| 52 | + ref: ${{ inputs.rules_ref}} |
| 53 | + path: open-rules |
| 54 | + |
| 55 | + # ----------------------------------------------------------------------- |
| 56 | + # 2b. Debug — verify directory layout |
| 57 | + # ----------------------------------------------------------------------- |
| 58 | + - name: Debug — list workspace layout |
| 59 | + run: | |
| 60 | + echo "=== Workspace root ===" |
| 61 | + ls -la |
| 62 | + echo "=== open-rules/ ===" |
| 63 | + ls -la open-rules/ || echo "open-rules/ NOT FOUND" |
| 64 | + echo "=== open-rules/Published/ (first 10) ===" |
| 65 | + ls open-rules/Published/ 2>/dev/null | head -10 || echo "Published/ NOT FOUND" |
| 66 | + echo "=== engine/ ===" |
| 67 | + ls engine/ | head -10 || echo "engine/ NOT FOUND" |
| 68 | +
|
| 69 | + # ----------------------------------------------------------------------- |
| 70 | + # 3. Set up Python |
| 71 | + # ----------------------------------------------------------------------- |
| 72 | + - name: Set up Python 3.12 |
| 73 | + uses: actions/setup-python@v6 |
| 74 | + with: |
| 75 | + python-version: "3.12" |
| 76 | + |
| 77 | + # ----------------------------------------------------------------------- |
| 78 | + # 4. Install engine dependencies |
| 79 | + # ----------------------------------------------------------------------- |
| 80 | + - name: Install engine dependencies |
| 81 | + run: | |
| 82 | + python -m venv venv |
| 83 | + ./venv/bin/pip install --upgrade pip |
| 84 | + ./venv/bin/pip install -r engine/requirements.txt |
| 85 | +
|
| 86 | + # ----------------------------------------------------------------------- |
| 87 | + # 5. Run validation for every Published rule |
| 88 | + # ----------------------------------------------------------------------- |
| 89 | + - name: Run validation for all Published rules |
| 90 | + id: validate |
| 91 | + continue-on-error: true |
| 92 | + run: | |
| 93 | + chmod +x open-rules/.github/scripts/run_validation.sh |
| 94 | +
|
| 95 | + CORE_IDS_ARG="" |
| 96 | + if [ -n "${{ inputs.core_ids }}" ]; then |
| 97 | + CORE_IDS_ARG="--core-ids ${{ inputs.core_ids }}" |
| 98 | + fi |
| 99 | +
|
| 100 | + ./venv/bin/python engine/scripts/validate_published_rules.py \ |
| 101 | + --rules-root "$(pwd)/open-rules" \ |
| 102 | + --engine-dir "$(pwd)/engine" \ |
| 103 | + --python-cmd "$(pwd)/venv/bin/python" \ |
| 104 | + --output-dir "$(pwd)" \ |
| 105 | + $CORE_IDS_ARG |
| 106 | +
|
| 107 | + # ----------------------------------------------------------------------- |
| 108 | + # 6. Upload both reports + raw results as artifacts |
| 109 | + # ----------------------------------------------------------------------- |
| 110 | + - name: Upload validation artifacts |
| 111 | + if: always() |
| 112 | + uses: actions/upload-artifact@v6 |
| 113 | + with: |
| 114 | + name: published-rules-validation-${{ github.run_id }} |
| 115 | + path: | |
| 116 | + open-rules/Published/**/results/results.csv |
| 117 | + summary_table.md |
| 118 | + detail_report.md |
| 119 | + if-no-files-found: warn |
| 120 | + |
| 121 | + # ----------------------------------------------------------------------- |
| 122 | + # 7. Write ONLY the summary table to GitHub Actions Job Summary |
| 123 | + # ----------------------------------------------------------------------- |
| 124 | + - name: Write summary table to workflow summary |
| 125 | + if: always() |
| 126 | + run: | |
| 127 | + [ -f summary_table.md ] && cat summary_table.md >> $GITHUB_STEP_SUMMARY || true |
| 128 | +
|
| 129 | + # ----------------------------------------------------------------------- |
| 130 | + # 8. Fail the job if any rule failed |
| 131 | + # ----------------------------------------------------------------------- |
| 132 | + - name: Check overall status |
| 133 | + if: steps.validate.outcome == 'failure' |
| 134 | + run: | |
| 135 | + echo "One or more published rules failed validation — see the artifacts for detail_report.md." |
| 136 | + exit 1 |
0 commit comments