diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml deleted file mode 100644 index 8546137e..00000000 --- a/.github/workflows/format.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: format json files with `jq` -on: - push: - branches: - - main - -permissions: - contents: read - issues: write - pull-requests: write - -jobs: - format-json: - 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: | - if just format; then - echo "format_failed=false" >> $GITHUB_ENV - else - echo "format_failed=true" >> $GITHUB_ENV - fi - - - name: check for changes - id: check-changes - run: | - if [ -n "$(git status --porcelain)" ]; then - echo "changes_detected=true" >> $GITHUB_ENV - else - echo "changes_detected=false" >> $GITHUB_ENV - fi - - - name: commit changes - if: env.changes_detected == 'true' - run: | - git config --local user.email "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - git add "**/*.json" - git commit --message "chore: format json files" - git push - - - name: create issue if formatting failed - if: failure() && env.format_failed == 'true' - uses: actions/github-script@v6 - with: - github-token: ${{secrets.GITHUB_TOKEN}} - script: | - github.rest.issues.create({ - owner: context.repo.owner, - repo: context.repo.repo, - title: 'JSON Formatting Failed', - body: 'The automatic JSON formatting job failed. Please check the logs and fix the issues manually.' - }) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 1b10c6d9..00000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: lint json files with `jq` -on: - workflow_run: - workflows: ["run-linter"] - types: - - completed - -permissions: - contents: read - issues: write - pull-requests: write - -jobs: - lint-json: - 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: lint json files - id: lint-json - run: | - if just lint; then - echo "lint_failed=false" >> $GITHUB_ENV - else - echo "lint_failed=true" >> $GITHUB_ENV - fi - - - name: add a comment to the pull request - if: env.lint_failed == 'true' - uses: actions/github-script@v4 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - github.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: "[error] linting failed. please fix the errors and push again." - }) diff --git a/.github/workflows/trigger-lint.yml b/.github/workflows/trigger-lint.yml deleted file mode 100644 index 646ff8bd..00000000 --- a/.github/workflows/trigger-lint.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: run-linter - -on: - push: - branches: - - "**" - -jobs: - trigger-lint: - runs-on: ubuntu-latest - steps: - - name: "[trigger]: run lint workflow" - run: | - curl \ - --request POST \ - --user "${{ secrets.GITHUB_TOKEN }}" \ - --header "Accept: application/vnd.github.v3+json" \ - --url "https://api.github.com/repos/TBD54566975/tbdex/actions/workflows/lint.yml/dispatches" \ - --data '{"ref": "main"}' diff --git a/.github/workflows/validate-json.yml b/.github/workflows/validate-json.yml new file mode 100644 index 00000000..1349c720 --- /dev/null +++ b/.github/workflows/validate-json.yml @@ -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 diff --git a/bin/.just-1.34.0.pkg b/bin/.just-1.34.0.pkg new file mode 120000 index 00000000..383f4511 --- /dev/null +++ b/bin/.just-1.34.0.pkg @@ -0,0 +1 @@ +hermit \ No newline at end of file diff --git a/bin/just b/bin/just new file mode 120000 index 00000000..bf5e8a7c --- /dev/null +++ b/bin/just @@ -0,0 +1 @@ +.just-1.34.0.pkg \ No newline at end of file diff --git a/hooks/pre-commit b/hooks/pre-commit index 78770f53..0b7dcc77 100644 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -1,8 +1,6 @@ #!/usr/bin/env bash -if just lint; then - echo "[success] linting passed" -else +if ! just format; then echo "[error] linting failed" exit 1 fi