Skip to content

Commit 2ceb9f9

Browse files
chore(adj-validator): copy ADJ-Validator from test-adj
1 parent 277d808 commit 2ceb9f9

2 files changed

Lines changed: 68 additions & 2 deletions

File tree

.github/workflows/adj-tester.yaml

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
name: ADJ Validator
1+
name: ADJ Validator (and Compact)
22

33
on:
4-
push:
4+
push:
55
pull_request:
66

77
jobs:
@@ -41,3 +41,38 @@ jobs:
4141
}' | curl -X POST -H "Content-type: application/json" \
4242
--data @- \
4343
$SLACK_WEBHOOK
44+
45+
publish-compact-adj:
46+
needs: validate-adj
47+
runs-on: ubuntu-latest
48+
env:
49+
TARGET_REPO: Hyperloop-UPV/ADJ-Archive
50+
TARGET_BRANCH: main
51+
TARGET_PATH: storage/commit-${{ github.sha }}.json
52+
53+
steps:
54+
- name: Checkout source repository
55+
uses: actions/checkout@v4
56+
57+
- name: Compact ADJ
58+
run: |
59+
chmod +x .github/workflows/scripts/adj-compact/compact.sh
60+
.github/workflows/scripts/adj-compact/compact.sh "${{ runner.temp }}/adj.json"
61+
62+
- name: Upload to destination repo via API
63+
env:
64+
GH_TOKEN: ${{ secrets.TARGET_REPO_TOKEN }}
65+
run: |
66+
base64 -w0 "${{ runner.temp }}/adj.json" > "${{ runner.temp }}/adj.b64"
67+
jq -n \
68+
--arg message "chore: add compacted ADJ from ${{ github.repository }}@${{ github.sha }}" \
69+
--rawfile content "${{ runner.temp }}/adj.b64" \
70+
--arg branch "$TARGET_BRANCH" \
71+
'{message: $message, content: $content, branch: $branch}' \
72+
> "${{ runner.temp }}/body.json"
73+
curl --fail-with-body -sS -X PUT \
74+
-H "Authorization: Bearer $GH_TOKEN" \
75+
-H "Accept: application/vnd.github+json" \
76+
-H "X-GitHub-Api-Version: 2022-11-28" \
77+
--data "@${{ runner.temp }}/body.json" \
78+
"https://api.github.com/repos/${TARGET_REPO}/contents/${TARGET_PATH}"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Javier Ribal del Río
5+
# ADJ Compact: Merge all JSON files into a single `adj.json` for easier consumption by clients that prefer a single file.
6+
# Usage: `./compact.sh [output-file]`
7+
# Version: v11.0.0 (2026-05-18)
8+
#
9+
10+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
11+
ROOT="$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null || (cd "$SCRIPT_DIR/../../../.." && pwd))"
12+
OUT="${1:-${ROOT}/adj.json}"
13+
OUT_BASE="$(basename "$OUT")"
14+
15+
cd "$ROOT"
16+
17+
acc='{}'
18+
# Sort shallowest-first so files like `boards.json` are merged before `boards/X/Y.json`,
19+
# letting the deeper, more specific content override the index-file stubs.
20+
while IFS= read -r rel; do
21+
[[ -z "$rel" ]] && continue
22+
[[ "$rel" == "$OUT_BASE" ]] && continue
23+
key="${rel%.json}"
24+
acc=$(jq -c --arg k "$key" --slurpfile v "$rel" '
25+
($k | split("/")) as $p
26+
| . * ([{($p[-1]): $v[0]}] | .[0] | reduce ($p[:-1] | reverse)[] as $seg (.; {($seg): .}))
27+
' <<<"$acc")
28+
done < <(find . -type d -name .github -prune -o -type f -name '*.json' -printf '%d %p\n' | sort -n | sed 's|^[0-9]* \./||')
29+
30+
printf '%s\n' "$acc" >"$OUT"
31+
echo "Wrote $OUT"

0 commit comments

Comments
 (0)