From 2ba1f8f99898c07cf0f5b5718638476a6b04ba6a Mon Sep 17 00:00:00 2001 From: Oscar Tovar Date: Mon, 25 Jul 2022 15:43:33 -0400 Subject: [PATCH 1/7] ci: lint commit messages --- .commitlintrc.yml | 128 ++++++++++++++++++++++++++++++++++ .gitlab/ci/lint.gitlab-ci.yml | 8 +++ 2 files changed, 136 insertions(+) create mode 100644 .commitlintrc.yml diff --git a/.commitlintrc.yml b/.commitlintrc.yml new file mode 100644 index 000000000..ff37569a2 --- /dev/null +++ b/.commitlintrc.yml @@ -0,0 +1,128 @@ +--- +rules: + body-leading-blank: + - 1 + - always + body-max-line-length: + - 2 + - always + - 100 + footer-leading-blank: + - 1 + - always + footer-max-line-length: + - 2 + - always + - 100 + header-max-length: + - 2 + - always + - 100 + subject-case: + - 2 + - never + - - sentence-case + - start-case + - pascal-case + - upper-case + subject-empty: + - 2 + - never + subject-full-stop: + - 2 + - never + - "." + type-case: + - 2 + - always + - lower-case + type-empty: + - 2 + - never + type-enum: + - 2 + - always + - - build + - chore + - ci + - docs + - feat + - fix + - improvement + - perf + - refactor + - revert + - style + - test +prompt: + questions: + type: + description: Select the type of change that you're committing + enum: + feat: + description: A new feature + title: Features + emoji: "✨" + fix: + description: A bug fix + title: Bug Fixes + emoji: "\U0001F41B" + docs: + description: Documentation only changes + title: Documentation + emoji: "\U0001F4DA" + style: + description: Changes that do not affect the meaning of the code (white-space, + formatting, missing semi-colons, etc) + title: Styles + emoji: "\U0001F48E" + refactor: + description: A code change that neither fixes a bug nor adds a feature + title: Code Refactoring + emoji: "\U0001F4E6" + perf: + description: A code change that improves performance + title: Performance Improvements + emoji: "\U0001F680" + test: + description: Adding missing tests or correcting existing tests + title: Tests + emoji: "\U0001F6A8" + build: + description: 'Changes that affect the build system or external dependencies + (example scopes: gulp, broccoli, npm)' + title: Builds + emoji: "\U0001F6E0" + ci: + description: 'Changes to our CI configuration files and scripts (example + scopes: Travis, Circle, BrowserStack, SauceLabs)' + title: Continuous Integrations + emoji: "⚙️" + chore: + description: Other changes that don't modify src or test files + title: Chores + emoji: "♻️" + revert: + description: Reverts a previous commit + title: Reverts + emoji: "\U0001F5D1" + scope: + description: What is the scope of this change (e.g. component or file name) + subject: + description: Write a short, imperative tense description of the change + body: + description: Provide a longer description of the change + isBreaking: + description: Are there any breaking changes? + breakingBody: + description: A BREAKING CHANGE commit requires a body. Please enter a longer + description of the commit itself + breaking: + description: Describe the breaking changes + isIssueAffected: + description: Does this change affect any open issues? + issuesBody: + description: If issues are closed, the commit requires a body. Please enter + a longer description of the commit itself + issues: + description: 'Add issue references (e.g. "fix #123", "re #123".)' diff --git a/.gitlab/ci/lint.gitlab-ci.yml b/.gitlab/ci/lint.gitlab-ci.yml index 29ca259d7..93993ea7d 100644 --- a/.gitlab/ci/lint.gitlab-ci.yml +++ b/.gitlab/ci/lint.gitlab-ci.yml @@ -13,3 +13,11 @@ lint: codequality: gl-code-quality-report.json paths: - gl-code-quality-report.json + +commitlint: + image: node:lts-alpine3.15 + stage: test + script: + - npx --yes commitlint --from=$CI_DEFAULT_BRANCH --verbose + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' -- GitLab From 5d6edeb6f57579d40faf5a5f0dad43d51651245a Mon Sep 17 00:00:00 2001 From: Oscar Tovar Date: Mon, 25 Jul 2022 18:05:33 -0400 Subject: [PATCH 2/7] ci: activate commitlint in .gitlab-ci.yml --- .gitlab-ci.yml | 8 ++++++++ .gitlab/ci/lint.gitlab-ci.yml | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e3f18a887..819003112 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,6 +38,14 @@ code_navigation: reports: lsif: dump.lsif +commitlint: + image: node:lts-alpine3.15 + stage: test + script: + - npx --yes commitlint --from=$CI_DEFAULT_BRANCH --verbose + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + run_tests: stage: test before_script: diff --git a/.gitlab/ci/lint.gitlab-ci.yml b/.gitlab/ci/lint.gitlab-ci.yml index 93993ea7d..29ca259d7 100644 --- a/.gitlab/ci/lint.gitlab-ci.yml +++ b/.gitlab/ci/lint.gitlab-ci.yml @@ -13,11 +13,3 @@ lint: codequality: gl-code-quality-report.json paths: - gl-code-quality-report.json - -commitlint: - image: node:lts-alpine3.15 - stage: test - script: - - npx --yes commitlint --from=$CI_DEFAULT_BRANCH --verbose - rules: - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' -- GitLab From bbc0bfb8d2cf1f5158ad8a80e9032ac62b514f41 Mon Sep 17 00:00:00 2001 From: Oscar Tovar Date: Mon, 25 Jul 2022 18:18:42 -0400 Subject: [PATCH 3/7] asdf: this commit message should fail --- tmp.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tmp.txt diff --git a/tmp.txt b/tmp.txt new file mode 100644 index 000000000..e69de29bb -- GitLab From 0665e651eabf3626361e7eca2b571a57fd7bb461 Mon Sep 17 00:00:00 2001 From: Oscar Tovar Date: Fri, 29 Jul 2022 11:02:15 -0400 Subject: [PATCH 4/7] ci: apply linter to all target branches --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 819003112..097af7774 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -42,9 +42,9 @@ commitlint: image: node:lts-alpine3.15 stage: test script: - - npx --yes commitlint --from=$CI_DEFAULT_BRANCH --verbose + - npx --yes commitlint --from=$CI_MERGE_REQUEST_TARGET_BRANCH --verbose rules: - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_MERGE_REQUEST_ID run_tests: stage: test -- GitLab From c3f9787d14a82ac4297c7de3982c25b6f7b20f8e Mon Sep 17 00:00:00 2001 From: Oscar Tovar Date: Mon, 1 Aug 2022 13:44:13 -0400 Subject: [PATCH 5/7] ci: run commitlint on branch pipelines --- .gitlab-ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 097af7774..999aaf4c0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -43,8 +43,6 @@ commitlint: stage: test script: - npx --yes commitlint --from=$CI_MERGE_REQUEST_TARGET_BRANCH --verbose - rules: - - if: $CI_MERGE_REQUEST_ID run_tests: stage: test -- GitLab From 07ae217c1d9141c8bf0489c903a0d891753fbe8c Mon Sep 17 00:00:00 2001 From: Oscar Tovar Date: Mon, 1 Aug 2022 14:00:18 -0400 Subject: [PATCH 6/7] ci: disable shallow cloning in commitlint job --- .gitlab-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 999aaf4c0..a193b230c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -43,6 +43,9 @@ commitlint: stage: test script: - npx --yes commitlint --from=$CI_MERGE_REQUEST_TARGET_BRANCH --verbose + variables: + # Disable shallow cloning so that commitlint can view log between revisions. + GIT_DEPTH: 0 run_tests: stage: test -- GitLab From 0cc876c8e0512220016d3b689ddf3c41632435ee Mon Sep 17 00:00:00 2001 From: Oscar Tovar Date: Mon, 1 Aug 2022 14:10:02 -0400 Subject: [PATCH 7/7] ci: fix predefined variable name usage --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a193b230c..18f97e846 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -42,7 +42,7 @@ commitlint: image: node:lts-alpine3.15 stage: test script: - - npx --yes commitlint --from=$CI_MERGE_REQUEST_TARGET_BRANCH --verbose + - npx --yes commitlint --from=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME --verbose variables: # Disable shallow cloning so that commitlint can view log between revisions. GIT_DEPTH: 0 -- GitLab