From 93c61b12f29ebef1bc70ca8cbbe68498ee72b14b Mon Sep 17 00:00:00 2001 From: Vladimir Pouzanov Date: Sat, 18 Mar 2023 17:37:17 +0000 Subject: [PATCH] Add a slightly better linter check (#2446) * Remove the NPM cache from the validate_icons step * Add a prettier formatting check --------- Co-authored-by: ligi --- .github/workflows/pr_checks.yml | 43 ++++++++++++++++++++++++++------- .github/workflows/prettier.yml | 1 - 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pr_checks.yml b/.github/workflows/pr_checks.yml index ed63e162..5d566c7f 100644 --- a/.github/workflows/pr_checks.yml +++ b/.github/workflows/pr_checks.yml @@ -24,15 +24,6 @@ jobs: files: _data/icons/*.json base_sha: ${{ steps.last_successful_commit_push.outputs.base }} - - name: Configure npm Caching - uses: actions/cache@v2 - if: steps.changed-icons.outputs.any_changed == 'true' - with: - path: ~/.npm - key: ${{ runner.os }}-npm-${{ hashFiles('**/workflows/validate_json.yml') }} - restore-keys: | - ${{ runner.os }}-npm- - - run: sudo apt-get -y install jq curl exiftool - name: Verify the changed icons @@ -97,3 +88,37 @@ jobs: fi done exit $BAD + + validate_formatting: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: nrwl/nx-set-shas@v3 + id: last_successful_commit_push + with: + main-branch-name: master + workflow-id: 'pr_checks.yml' + + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v35 + with: + files: _data/*/*.json + base_sha: ${{ steps.last_successful_commit_push.outputs.base }} + + - run: sudo npm i -g prettier + + - name: Verify the changed icons + if: steps.changed-files.outputs.any_changed == 'true' + run: | + set -euo pipefail + + BAD=0 + + for CHANGED_FILE in ${{ steps.changed-files.outputs.all_changed_files }}; do + echo "Checking $CHANGED_FILE" + diff -u "$CHANGED_FILE" <(prettier "$CHANGED_FILE") + done diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index c4079c8a..aa43a040 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -2,7 +2,6 @@ name: Run prettier on: push: - pull_request: jobs: prettier: