From 26b07cb569f123b2472de5b29b79757f85ff4a0f Mon Sep 17 00:00:00 2001 From: Wagner Santos <7467450+wagoid@users.noreply.github.com> Date: Fri, 12 Feb 2021 15:49:35 -0300 Subject: [PATCH 1/4] ci: remove redundant commitlint-with-yml-file workflow We have tests for custom yml config file, so this is not needed. --- .commitlintrc.yml | 3 --- .dockerignore | 1 - .github/workflows/commitlint.yml | 11 ----------- 3 files changed, 15 deletions(-) delete mode 100644 .commitlintrc.yml diff --git a/.commitlintrc.yml b/.commitlintrc.yml deleted file mode 100644 index 7ed6a30..0000000 --- a/.commitlintrc.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -extends: - - '@commitlint/config-conventional' diff --git a/.dockerignore b/.dockerignore index be870c0..ed625e5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,4 @@ node_modules -.commitlintrc.yml commitlint.config.js action.yml .github diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index a2d87b1..6a2f201 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -15,17 +15,6 @@ jobs: - name: Show results from JSON output if: ${{ always() }} run: echo ${{ toJSON(steps.run_commitlint.outputs.results) }} - commitlint-with-yml-file: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - run: sed -i -E "s/(docker:.+)/Dockerfile/" ./action.yml - - run: echo -n '' > .dockerignore - - uses: ./ - with: - configFile: './.commitlintrc.yml' commitlint-pulling-from-docker-hub: runs-on: ubuntu-latest steps: From cd7f07d5ef238d2a92f064e3c590d3e8b69b8e63 Mon Sep 17 00:00:00 2001 From: Wagner Santos <7467450+wagoid@users.noreply.github.com> Date: Fri, 12 Feb 2021 16:25:26 -0300 Subject: [PATCH 2/4] style: ignore body-max-line-length rule for deps commits --- .github/workflows/commitlint.yml | 12 +++++++++ commitlint.config.js | 24 +++++++++++++++++ package-lock.json | 46 ++++++++++++++++++++++++++------ package.json | 2 ++ 4 files changed, 76 insertions(+), 8 deletions(-) diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index 6a2f201..e63dd87 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -10,8 +10,14 @@ jobs: fetch-depth: 0 - run: sed -i -E "s/(docker:.+)/Dockerfile/" ./action.yml - run: echo -n '' > .dockerignore + - uses: actions/setup-node@v2 + with: + node-version: '14' + - run: npm install - uses: ./ id: run_commitlint + env: + NODE_PATH: ${{ github.workspace }}/node_modules - name: Show results from JSON output if: ${{ always() }} run: echo ${{ toJSON(steps.run_commitlint.outputs.results) }} @@ -21,4 +27,10 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 + - uses: actions/setup-node@v2 + with: + node-version: '14' + - run: npm install - uses: ./ + env: + NODE_PATH: ${{ github.workspace }}/node_modules diff --git a/commitlint.config.js b/commitlint.config.js index 98ee7df..072ad14 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -1,3 +1,27 @@ +const { maxLineLength } = require('@commitlint/ensure') + +const bodyMaxLineLength = 100 + +const validateBodyMaxLengthIgnoringDeps = parsedCommit => { + const { type, scope, body } = parsedCommit + const isDepsCommit = + type === 'chore' && (scope === 'deps' || scope === 'deps-dev') + + return [ + isDepsCommit || !body || maxLineLength(body, bodyMaxLineLength), + `body's lines must not be longer than ${bodyMaxLineLength}`, + ] +} + module.exports = { extends: ['@commitlint/config-conventional'], + plugins: ['commitlint-plugin-function-rules'], + rules: { + 'body-max-line-length': [0], + 'function-rules/body-max-line-length': [ + 2, + 'always', + validateBodyMaxLengthIgnoringDeps, + ], + }, } diff --git a/package-lock.json b/package-lock.json index 9c13eac..76d8f9f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -644,18 +644,20 @@ } }, "@commitlint/ensure": { - "version": "9.1.2", - "resolved": "https://registry.npmjs.org/@commitlint/ensure/-/ensure-9.1.2.tgz", - "integrity": "sha512-hwQICwpNSTsZgj/1/SdPvYAzhwjwgCJI4vLbT879+Jc+AJ6sj2bUDGw/F89vzgKz1VnaMm4D65bNhoWhG3pdhQ==", + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@commitlint/ensure/-/ensure-11.0.0.tgz", + "integrity": "sha512-/T4tjseSwlirKZdnx4AuICMNNlFvRyPQimbZIOYujp9DSO6XRtOy9NrmvWujwHsq9F5Wb80QWi4WMW6HMaENug==", + "dev": true, "requires": { - "@commitlint/types": "^9.1.2", + "@commitlint/types": "^11.0.0", "lodash": "^4.17.19" }, "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==" + "@commitlint/types": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@commitlint/types/-/types-11.0.0.tgz", + "integrity": "sha512-VoNqai1vR5anRF5Tuh/+SWDFk7xi7oMwHrHrbm1BprYXjB2RJsWLhUrStMssDxEl5lW/z3EUdg8RvH/IUBccSQ==", + "dev": true } } }, @@ -901,6 +903,17 @@ "@commitlint/message": "^9.1.2", "@commitlint/to-lines": "^9.1.2", "@commitlint/types": "^9.1.2" + }, + "dependencies": { + "@commitlint/ensure": { + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/@commitlint/ensure/-/ensure-9.1.2.tgz", + "integrity": "sha512-hwQICwpNSTsZgj/1/SdPvYAzhwjwgCJI4vLbT879+Jc+AJ6sj2bUDGw/F89vzgKz1VnaMm4D65bNhoWhG3pdhQ==", + "requires": { + "@commitlint/types": "^9.1.2", + "lodash": "^4.17.19" + } + } } }, "@commitlint/test": { @@ -4382,6 +4395,23 @@ "resolved": "https://registry.npmjs.org/commitlint-jira-utils/-/commitlint-jira-utils-1.4.0.tgz", "integrity": "sha512-vW1eGt7cSwtk9I/jOfvxJpDJoSixIn5lq9gI2UOFbidkL4eqAbWFOk/g0NuYVQIF2k/xPZ2yzDr2mXfSCkqAFA==" }, + "commitlint-plugin-function-rules": { + "version": "1.1.20", + "resolved": "https://registry.npmjs.org/commitlint-plugin-function-rules/-/commitlint-plugin-function-rules-1.1.20.tgz", + "integrity": "sha512-uaWdKa1OI4s0upk0g/sCX2SOgggo+3FCQk7omZxfm0caMj0NgbgEcYulcslFhHRYLc/FjhJfnL2cxPXEldRFWQ==", + "dev": true, + "requires": { + "@commitlint/types": "11.0.0" + }, + "dependencies": { + "@commitlint/types": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@commitlint/types/-/types-11.0.0.tgz", + "integrity": "sha512-VoNqai1vR5anRF5Tuh/+SWDFk7xi7oMwHrHrbm1BprYXjB2RJsWLhUrStMssDxEl5lW/z3EUdg8RvH/IUBccSQ==", + "dev": true + } + } + }, "commitlint-plugin-jira-rules": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/commitlint-plugin-jira-rules/-/commitlint-plugin-jira-rules-1.4.0.tgz", diff --git a/package.json b/package.json index 7b25b01..c414256 100644 --- a/package.json +++ b/package.json @@ -34,8 +34,10 @@ }, "devDependencies": { "@commitlint/cli": "^11.0.0", + "@commitlint/ensure": "^11.0.0", "@commitlint/test": "^9.0.1", "@commitlint/test-environment": "^9.0.1", + "commitlint-plugin-function-rules": "^1.1.20", "conventional-changelog-cli": "^2.1.0", "husky": "^3.1.0", "jest": "^24.9.0", From 0a48910d24bde82228d877d9a16de51d4cdeea93 Mon Sep 17 00:00:00 2001 From: Wagner Santos <7467450+wagoid@users.noreply.github.com> Date: Fri, 12 Feb 2021 16:40:24 -0300 Subject: [PATCH 3/4] docs: update instructions to use current Node.js LTS --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3213ff8..80bde6d 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-node@v1 with: - node-version: '10.x' + node-version: '14' - run: npm install # Run the commitlint action, considering its own dependencies and yours as well 🚀 # `github.workspace` is the path to your repository. From 6f63f52e0fee60147150428a7729e3322fb50c2d Mon Sep 17 00:00:00 2001 From: Wagner Santos <7467450+wagoid@users.noreply.github.com> Date: Fri, 12 Feb 2021 16:47:01 -0300 Subject: [PATCH 4/4] ci: cache deps when running commitlint --- .github/workflows/commitlint.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index e63dd87..278a00f 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -13,6 +13,14 @@ jobs: - uses: actions/setup-node@v2 with: node-version: '14' + - uses: actions/cache@v2 + with: + path: | + ~/.npm + **/node_modules + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- - run: npm install - uses: ./ id: run_commitlint @@ -30,6 +38,14 @@ jobs: - uses: actions/setup-node@v2 with: node-version: '14' + - uses: actions/cache@v2 + with: + path: | + ~/.npm + **/node_modules + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- - run: npm install - uses: ./ env: