11name : Run Stamp Metadata Validation
22
33on :
4+ push :
5+ branches : [ "main" ]
6+ pull_request :
47 workflow_dispatch :
58 inputs :
69 paths :
7- description : " Files to validate"
10+ description : " Files or glob patterns to validate"
811 required : false
912 default : " **/*.md"
1013 mode :
11- description : " Validation mode (check/ fix)"
14+ description : " Validation mode (check or fix)"
1215 type : choice
1316 options :
1417 - check
1518 - fix
1619 default : " check"
1720 output_dir :
18- description : " Optional output directory"
21+ description : " Optional directory to write normalized files "
1922 required : false
20- pull_request :
21- push :
22- branches : [ "main" ]
2323
2424jobs :
2525 stamp :
26- name : Run Stamp Validator
26+ name : Stamp Metadata Validation
2727 runs-on : ubuntu-latest
2828
2929 steps :
30+ # ---------------------------------------------------------------
31+ # CHECKOUT REPO
32+ # ---------------------------------------------------------------
3033 - name : Checkout Repository
3134 uses : actions/checkout@v4
35+ with :
36+ fetch-depth : 0
3237
38+ # ---------------------------------------------------------------
39+ # PYTHON SETUP
40+ # ---------------------------------------------------------------
3341 - name : Set up Python
3442 uses : actions/setup-python@v5
3543 with :
3644 python-version : " 3.11"
3745
46+ # ---------------------------------------------------------------
47+ # INSTALL STAMP FROM THE REPO
48+ # ---------------------------------------------------------------
3849 - name : Install Stamp
39- # NOTE: Change this to 'pip install stamp-core' for production use in other repos
4050 run : |
4151 python -m pip install --upgrade pip
4252 pip install -e .
4353
54+ # ---------------------------------------------------------------
55+ # DETERMINE MODE + PATHS
56+ # ---------------------------------------------------------------
4457 - name : Configure Execution Parameters
4558 id : config
46- shell : bash
4759 run : |
48- # Default to 'check' and all markdown files for Push/PR
4960 MODE="--check"
5061 PATHS="**/*.md"
5162 OUTDIR=""
5263
53- # Override if this is a manual dispatch
5464 if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
5565 if [[ "${{ inputs.mode }}" == "fix" ]]; then
5666 MODE="--fix"
5767 fi
58-
68+
5969 if [[ -n "${{ inputs.paths }}" ]]; then
6070 PATHS="${{ inputs.paths }}"
6171 fi
@@ -68,45 +78,48 @@ jobs:
6878 echo "MODE=$MODE" >> $GITHUB_OUTPUT
6979 echo "PATHS=$PATHS" >> $GITHUB_OUTPUT
7080 echo "OUTDIR=$OUTDIR" >> $GITHUB_OUTPUT
71-
72- echo "::notice::Running Stamp with mode: $MODE on paths: $PATHS"
7381
82+ # ---------------------------------------------------------------
83+ # RUN STAMP VALIDATION
84+ # ---------------------------------------------------------------
7485 - name : Run Stamp
7586 id : stamp_run
76- # We allow error here to handle the exit codes manually in the next step
7787 continue-on-error : true
7888 run : |
79- # Using redirection > for report as per Spec 5.8
8089 stamp ${{ steps.config.outputs.MODE }} \
8190 ${{ steps.config.outputs.OUTDIR }} \
8291 "${{ steps.config.outputs.PATHS }}" \
8392 --json > stamp_report.json
84-
85- # Capture the actual exit code of the stamp command
93+
8694 echo "EXIT_CODE=$?" >> $GITHUB_OUTPUT
8795
96+ # ---------------------------------------------------------------
97+ # UPLOAD REPORT AS ARTIFACT
98+ # ---------------------------------------------------------------
8899 - name : Upload Validation Report
89100 uses : actions/upload-artifact@v4
90101 with :
91102 name : stamp-validation-report
92103 path : stamp_report.json
93104
94- - name : Process Verification Results
105+ # ---------------------------------------------------------------
106+ # PROCESS STATUS + FAIL PIPELINE IF NEEDED
107+ # ---------------------------------------------------------------
108+ - name : Process Results
95109 if : always()
96110 run : |
97111 CODE=${{ steps.stamp_run.outputs.EXIT_CODE }}
98-
112+
99113 if [[ "$CODE" == "0" ]]; then
100- echo "✅ Stamp Verification Passed ."
114+ echo "✅ Metadata validation passed ."
101115 exit 0
102116 elif [[ "$CODE" == "1" ]]; then
103117 echo "⚠️ Repairable metadata issues detected."
104- echo "Run 'stamp --fix' locally or re-run this workflow in 'fix' mode."
105- # We fail the CI pipeline on code 1 so the user knows they must fix it
118+ echo "Run workflow_dispatch in 'fix' mode to auto-correct."
106119 exit 1
107120 elif [[ "$CODE" == "2" ]]; then
108- echo "❌ FATAL: Non-compliant metadata detected."
109- echo "These errors cannot be auto-repaired. Check the report ."
121+ echo "❌ FATAL: Noncompliant metadata detected."
122+ echo "Check stamp_report.json for error details ."
110123 exit 2
111124 else
112125 echo "❓ Unknown error occurred."
0 commit comments