Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

fix: simplify json format/validation action #372

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 0 additions & 62 deletions .github/workflows/format.yml

This file was deleted.

45 changes: 0 additions & 45 deletions .github/workflows/lint.yml

This file was deleted.

19 changes: 0 additions & 19 deletions .github/workflows/trigger-lint.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/validate-json.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: validate-json
on:
push:
branches:
- "**"

pull_request:
types:
- opened
- synchronize

jobs:
format:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v4

- uses: cashapp/activate-hermit@v1
name: setup hermit with `just` and `jq`
with:
cache: true

- name: format json files
id: format-json
run: just format
8 changes: 3 additions & 5 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,15 @@ lint: clean
exit 1
fi

no_errors_found=true
has_errors=false
for file in $(find hosted -type f -name "*.json"); do
if ! jq empty $file > /dev/null; then
printf "[error] %s is not a valid JSON file\n\n" $file
no_errors_found=false
has_errors=true
fi
done

if [ "$no_errors_found" = true ]; then
echo "[success] All JSON files are valid"
else
if [ "$has_errors" = true ]; then
exit 1
Comment on lines -38 to 43
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe just exit 1 right away instead of assigning to a variable and then reading afterwards?

Copy link
Contributor Author

@lamchau lamchau Sep 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could! if the user had 3 malformed files then they'd only see one at a time.

this felt more "ergonomic" to show all the files so potentially it (just lint) could be fixed without having to run it multiple times.

open to either approach!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm for showing all the files that fail lint at once

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah nice, that's better!

fi

Expand Down
1 change: 1 addition & 0 deletions bin/.just-1.34.0.pkg
1 change: 1 addition & 0 deletions bin/just
7 changes: 1 addition & 6 deletions hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
#!/usr/bin/env bash

if just lint; then
echo "[success] linting passed"
else
echo "[error] linting failed"
exit 1
fi
just format
Loading