ProofedMesh/.forgejo/workflows/validate.yml
CTO Agent 1d4eccb6d3
Some checks failed
validate / Rego (opa fmt + opa test) (push) Failing after 30s
validate / JSON Schema (ajv) (push) Failing after 35s
ci: use fetch-depth 0 — Forgejo repo has sha256 object format, checkout cannot fetch by raw SHA
2026-10-25 15:33:02 +00:00

88 lines
2.7 KiB
YAML

name: validate
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
json-schema:
name: JSON Schema (ajv)
runs-on: ubuntu-latest
steps:
- name: Install prerequisites in container
run: |
set -euo pipefail
command -v curl >/dev/null || { apt-get update && apt-get install -y curl ca-certificates; }
node --version
npm --version
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install ajv-cli + ajv-formats
run: |
set -euo pipefail
npm install --prefix /tmp/ajv ajv-cli@5 ajv-formats@3
- name: Validate every JSON Schema parses as JSON
run: |
set -euo pipefail
find schemas -type f -name '*.json' -print | while read -r f; do
echo "--- parse: $f"
node -e "require('./$f')"
done
- name: Meta-validate each schema against JSON Schema 2020-12
run: |
set -euo pipefail
export NODE_PATH=/tmp/ajv/node_modules
find schemas -type f -name '*.json' -print | while read -r f; do
echo "--- meta-validate: $f"
node /tmp/ajv/node_modules/.bin/ajv compile --spec=draft2020 -c=ajv-formats -s "$f"
done
- name: Validate example payloads against their schemas (if any)
run: |
set -euo pipefail
export NODE_PATH=/tmp/ajv/node_modules
shopt -s nullglob
for schema in $(find schemas -type f -name '*.json'); do
dir="$(dirname "$schema")/examples"
[ -d "$dir" ] || continue
for example in "$dir"/*.json; do
echo "--- validate example $example against $schema"
node /tmp/ajv/node_modules/.bin/ajv validate --spec=draft2020 -c=ajv-formats -s "$schema" -d "$example"
done
done
rego:
name: Rego (opa fmt + opa test)
runs-on: ubuntu-latest
steps:
- name: Install prerequisites in container
run: |
set -euo pipefail
command -v curl >/dev/null || { apt-get update && apt-get install -y curl ca-certificates; }
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install OPA
run: |
set -euo pipefail
mkdir -p "$HOME/.local/bin"
curl -sSL -o "$HOME/.local/bin/opa" https://openpolicyagent.org/downloads/v1.9.0/opa_linux_amd64_static
chmod +x "$HOME/.local/bin/opa"
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
"$HOME/.local/bin/opa" version
- name: opa fmt (fail on any diff)
run: opa fmt --list --diff policies/
- name: opa test
run: opa test policies/ -v