From 9632b30023af763e052852c015c601474f71cb3d Mon Sep 17 00:00:00 2001 From: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> Date: Wed, 7 Jul 2021 09:57:06 +0900 Subject: [PATCH] Refactor the use of actions/setup-node (#545) - Set `.nvmrc` value to `with.node-version` See - Add `npm run lint-ci` to use "Problem Matchers" of actions/setup-node --- .github/workflows/eslint.yml | 4 +++- .github/workflows/stylelint.yml | 4 ++++ .github/workflows/test.yml | 17 ++++++----------- package.json | 1 + 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml index 7b385b53..ea0215e0 100644 --- a/.github/workflows/eslint.yml +++ b/.github/workflows/eslint.yml @@ -12,8 +12,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - run: echo ::set-output name=nvmrc::$(cat .nvmrc) + id: nvm - uses: actions/setup-node@v2 with: - node-version: "16.x" + node-version: "${{ steps.nvm.outputs.nvmrc }}" - run: npm install eslint-config-ybiquitous @typescript-eslint/eslint-plugin - run: npx eslint . diff --git a/.github/workflows/stylelint.yml b/.github/workflows/stylelint.yml index 90fa9cb9..d0e2641a 100644 --- a/.github/workflows/stylelint.yml +++ b/.github/workflows/stylelint.yml @@ -12,7 +12,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - run: echo ::set-output name=nvmrc::$(cat .nvmrc) + id: nvm - uses: actions/setup-node@v2 + with: + node-version: "${{ steps.nvm.outputs.nvmrc }}" # https://github.com/actions/toolkit/blob/2f164000dcd42fb08287824a3bc3030dbed33687/docs/commands.md#problem-matchers # https://gist.github.com/ybiquitous/184a337662bfcafdd3d227253f9401ff - name: Set up Problem Matchers for stylelint diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 89cdc700..c1793412 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,16 +11,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - run: | - nvm install --latest-npm --no-progress - echo "PATH=${NVM_BIN}:${PATH}" >> $GITHUB_ENV - shell: bash --login {0} + - run: echo ::set-output name=nvmrc::$(cat .nvmrc) + id: nvm + - uses: actions/setup-node@v2 + with: + node-version: "${{ steps.nvm.outputs.nvmrc }}" - run: npm ci - - name: Set up Problem Matchers for tsc - run: | - curl -fLO "https://raw.githubusercontent.com/actions/setup-node/5c355be17065acf11598c7a9bb47112fbcf2bbdc/.github/tsc.json" - mv tsc.json "${HOME}/tsc.json" - echo "::add-matcher::${HOME}/tsc.json" - - run: npm run lint:types - - run: npm run lint + - run: npm run lint-ci - run: npm run build diff --git a/package.json b/package.json index 91f825b6..34557046 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "postbuild": "cp -v _redirects dist/", "static": "npm run build && npx http-server ./dist", "format": "npm-run-all --print-label --parallel lint:*:fix prettier:write", + "lint-ci": "npm-run-all --silent --parallel lint:* prettier:check", "lint": "npm-run-all --print-label --parallel lint:* prettier:check", "lint:md": "remark .", "lint:md:fix": "remark . --output",