From 056a4468323c7c9656d62b46cab6b4ed74d6dc24 Mon Sep 17 00:00:00 2001 From: Darren Ethier Date: Sun, 17 Jan 2021 14:06:24 -0500 Subject: [PATCH] change eslint workflow to use different method and action (https://github.com/woocommerce/woocommerce-blocks/pull/3693) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Our existing worfklow was giving a cryptic error that I couldn’t troubleshoot so decided to just switch to a different method --- .../.github/workflows/js-css-linting.yml | 95 +++++++++++++------ plugins/woocommerce-blocks/.gitignore | 1 + plugins/woocommerce-blocks/package.json | 1 + 3 files changed, 68 insertions(+), 29 deletions(-) diff --git a/plugins/woocommerce-blocks/.github/workflows/js-css-linting.yml b/plugins/woocommerce-blocks/.github/workflows/js-css-linting.yml index 29ca30585e1..db015811ced 100644 --- a/plugins/woocommerce-blocks/.github/workflows/js-css-linting.yml +++ b/plugins/woocommerce-blocks/.github/workflows/js-css-linting.yml @@ -6,37 +6,74 @@ on: branches: [trunk] jobs: - check: - name: All - + Setup: + name: Setup for Jobs runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v2 + - name: Cache node modules + uses: actions/cache@v2 + with: + path: node_modules + key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.OS }}-build-${{ env.cache-name }}- + ${{ runner.OS }}-build- + ${{ runner.OS }}- + - name: Install Node Dependencies + run: npm install - - name: Cache node modules - uses: actions/cache@v2 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - name: Use Node.js 12.x - uses: actions/setup-node@v1 - with: - node-version: 12.x - - name: Npm install - run: | - npm install - - name: Lint JavaScript - uses: bradennapier/eslint-plus-action@v3.4.2 - with: - issueSummaryOnlyOnEvent: true - - name: Lint CSS - run: npm run lint:css + JSLintingCheck: + name: Lint JavaScript + needs: Setup + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Cache node modules + uses: actions/cache@v2 + with: + path: node_modules + key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.OS }}-build-${{ env.cache-name }}- + ${{ runner.OS }}-build- + ${{ runner.OS }}- + - name: Install Node Dependencies + run: npm install + - name: Save Code Linting Report JSON + run: npm run lint:js:report + # Continue to the next step even if this fails + continue-on-error: true + - name: Upload ESLint report + uses: actions/upload-artifact@v2 + with: + name: eslint_report.json + path: eslint_report.json + - name: Annotate Code Linting Results + uses: ataylorme/eslint-annotate-action@1.1.2 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" + report-json: "eslint_report.json" + + CSSLintingCheck: + name: Lint CSS + needs: Setup + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Cache node modules + uses: actions/cache@v2 + with: + path: node_modules + key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.OS }}-build-${{ env.cache-name }}- + ${{ runner.OS }}-build- + ${{ runner.OS }}- + - name: Install Node Dependencies + run: npm install + - name: Lint CSS + run: npm run lint:css diff --git a/plugins/woocommerce-blocks/.gitignore b/plugins/woocommerce-blocks/.gitignore index ed96bf2fc01..39113f5e88b 100644 --- a/plugins/woocommerce-blocks/.gitignore +++ b/plugins/woocommerce-blocks/.gitignore @@ -53,3 +53,4 @@ storybook-static/ blocks.ini /wp-content/ /.wp-env.override.json +/eslint_report.json diff --git a/plugins/woocommerce-blocks/package.json b/plugins/woocommerce-blocks/package.json index 709c052858b..e9eb048ee89 100644 --- a/plugins/woocommerce-blocks/package.json +++ b/plugins/woocommerce-blocks/package.json @@ -41,6 +41,7 @@ "lint:css": "stylelint 'assets/**/*.scss'", "lint:css-fix": "stylelint 'assets/**/*.scss' --fix", "lint:js": "wp-scripts lint-js", + "lint:js:report": "npm run lint:js -- --output-file eslint_report.json --format json", "lint:js-fix": "eslint assets/js --ext=js,jsx --fix", "lint:php": "composer run-script phpcs ./src", "package-plugin": "rimraf woocommerce-gutenberg-products-block.zip && ./bin/build-plugin-zip.sh",