From 4fb87ade221504bb71fb20d8df7b2191977f308e Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Wed, 4 Nov 2020 10:44:09 -0500 Subject: [PATCH] chore: Pull JS Linting to separate Action Only trigger if JS, package, or Action file is changed --- .github/workflows/js-lint.yml | 59 +++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 41 ------------------------ 2 files changed, 59 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/js-lint.yml diff --git a/.github/workflows/js-lint.yml b/.github/workflows/js-lint.yml new file mode 100644 index 0000000000..2484bb8ca9 --- /dev/null +++ b/.github/workflows/js-lint.yml @@ -0,0 +1,59 @@ +name: Lint JS + +on: + workflow_dispatch: + push: + branches: + - main + pull_request: + branches-ignore: + - translations + +jobs: + see_if_should_skip: + runs-on: ubuntu-latest + + outputs: + should_skip: ${{ steps.skip_check.outputs.should_skip }} + steps: + - id: skip_check + uses: fkirc/skip-duplicate-actions@36feb0d8d062137530c2e00bd278d138fe191289 + with: + cancel_others: 'false' + github_token: ${{ github.token }} + paths: '["**/*.js","package*.json",".github/workflows/js-lint.yml"]' + + lint: + runs-on: ubuntu-latest + needs: see_if_should_skip + if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }} + steps: + - name: Check out repo + uses: actions/checkout@a81bbbf8298c0fa03ea29cdc473d45769f953675 + + - name: Setup node + uses: actions/setup-node@56899e050abffc08c2b3b61f3ec6a79a9dc3223d + with: + node-version: 14.x + + - name: Get npm cache directory + id: npm-cache + run: | + echo "::set-output name=dir::$(npm config get cache)" + + - name: Cache node modules + uses: actions/cache@d1255ad9362389eac595a9ae406b8e8cb3331f16 + with: + path: ${{ steps.npm-cache.outputs.dir }} + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Install dependencies + run: npm ci + + - name: Run linter + run: npx standard + + - name: Check dependencies + run: npm run check-deps diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3e103a7bc7..158066be42 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,48 +28,7 @@ jobs: cancel_others: 'false' github_token: ${{ github.token }} paths: '[".github/workflows/test.yml",".node-version", ".npmrc", "app.json", "content/**", "data/**","lib/**", "Dockerfile", "feature-flags.json", "Gemfile", "Gemfile.lock", "middleware/**", "node_modules/**","package.json", "package-lock.json", "server.js", "tests/**", "translations/**", "Procfile", "webpack.config.js"]' - lint: - needs: see_if_should_skip - runs-on: ubuntu-latest - steps: - # Each of these ifs needs to be repeated at each step to make sure the required check still runs - # Even if if doesn't do anything - - if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }} - name: Check out repo - uses: actions/checkout@a81bbbf8298c0fa03ea29cdc473d45769f953675 - - if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }} - name: Setup node - uses: actions/setup-node@56899e050abffc08c2b3b61f3ec6a79a9dc3223d - with: - node-version: 14.x - - - if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }} - name: Get npm cache directory - id: npm-cache - run: | - echo "::set-output name=dir::$(npm config get cache)" - - - if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }} - name: Cache node modules - uses: actions/cache@d1255ad9362389eac595a9ae406b8e8cb3331f16 - with: - path: ${{ steps.npm-cache.outputs.dir }} - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node- - - - if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }} - name: Install dependencies - run: npm ci - - - if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }} - name: Run linter - run: npx standard - - - if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }} - name: Check dependencies - run: npm run check-deps test: needs: see_if_should_skip runs-on: ubuntu-latest