Skip to content

Commit a2bee7d

Browse files
committed
ci(workflow): add TSV validation step and improve error handling
Adds qsv installation and TSV validation to CI workflow to catch data format issues early. Refactors tsv-check script to fail fast on first error and include schema validation.
1 parent 9a8aa66 commit a2bee7d

2 files changed

Lines changed: 22 additions & 20 deletions

File tree

.github/workflows/update-price-data.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,17 @@ jobs:
1111
steps:
1212
- name: Checkout repository
1313
uses: actions/checkout@v5
14-
15-
- name: Get app installation token
16-
id: app-token
17-
uses: actions/create-github-app-token@v2
18-
with:
19-
app-id: ${{ vars.APP_ID }}
20-
owner: ${{ github.repository_owner }}
21-
private-key: ${{ secrets.APP_PRIVATE_KEY }}
22-
repositories: price-data,indexers,accounting
23-
2414
- name: Set up devkit
2515
uses: sablier-labs/devkit/actions/setup@main
2616
with:
2717
package-manager: bun
2818

19+
- name: Install qsv
20+
uses: cargo-bins/cargo-binstall@main
21+
22+
- name: Install qsv binary
23+
run: cargo binstall --no-confirm qsv
24+
2925
- name: Fetch cryptocurrency prices
3026
env:
3127
COINGECKO_API_KEY_1: ${{ secrets.COINGECKO_API_KEY_1 }}
@@ -37,6 +33,9 @@ jobs:
3733
CURRENCY_FREAKS_API_KEY: ${{ secrets.CURRENCY_FREAKS_API_KEY }}
3834
run: just fetch-forex
3935

36+
- name: Validate TSV files
37+
run: just tsv-check
38+
4039
- name: Verify changes
4140
run: | #shell
4241
if ! git diff --quiet -- crypto/ forex/; then
@@ -47,6 +46,15 @@ jobs:
4746
exit 1
4847
fi
4948
49+
- name: Get app installation token
50+
id: app-token
51+
uses: actions/create-github-app-token@v2
52+
with:
53+
app-id: ${{ vars.APP_ID }}
54+
owner: ${{ github.repository_owner }}
55+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
56+
repositories: price-data,indexers,accounting
57+
5058
- name: Generate timestamp
5159
id: timestamp
5260
run: echo "human=$(date '+%B %d, %Y at %H:%M UTC')" >> $GITHUB_OUTPUT

justfile

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ YEAR := ```
3535
# ---------------------------------------------------------------------------- #
3636

3737
# Fetch cryptocurrency prices from CoinGecko
38-
[group("scripts")]
3938
@fetch-crypto currency year=YEAR month=MONTH *args:
4039
na tsx src/cli/fetch-crypto.ts \
4140
--currency {{ currency }} \
@@ -44,19 +43,17 @@ YEAR := ```
4443
{{ args }}
4544

4645
# Fetch daily GBP/USD forex rates from CurrencyFreaks
47-
[group("scripts")]
4846
@fetch-forex year=YEAR month=MONTH *args:
4947
na tsx src/cli/fetch-forex.ts \
5048
--year {{ year }} \
5149
--month {{ month }} \
5250
{{ args }}
5351

5452
# Check TSV files
55-
[group("lint")]
53+
[group("checks")]
5654
[script]
5755
tsv-check:
5856
echo "Validating TSV files..."
59-
has_error=0
6057
for file in data/transactions/*/*.tsv; do
6158
# Skip validation artifact files
6259
case "$file" in
@@ -68,13 +65,10 @@ tsv-check:
6865
# Skip if no files match the pattern
6966
[ -e "$file" ] || continue
7067

71-
if ! qsv validate "$file" &>/dev/null; then
72-
echo "$file is invalid"
68+
if ! qsv validate "$file" data/transactions/schema.json > /dev/null 2>&1; then
69+
echo "Validation failed for: $file"
7370
echo "See $file.validation-errors.tsv for details"
74-
has_error=1
71+
exit 1
7572
fi
7673
done
77-
if [ $has_error -eq 1 ]; then
78-
exit 1
79-
fi
8074
echo "✅ All TSV files are valid"

0 commit comments

Comments
 (0)