Skip to content

Commit

Permalink
Merge pull request fluidattacks#1407 from dsalaza4/main
Browse files Browse the repository at this point in the history
refac(back): fluidattacks#1378 deprecate commit linter
  • Loading branch information
jandresh authored Dec 13, 2024
2 parents 2fba6e0 + 6d89b89 commit 208c374
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 3,495 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,23 @@ jobs:
- name: /lintBash
run: nix-env -if . && m . /lintBash

linux_lintGitCommitMsg:
linux_tests_commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@f095bcc56b7c2baf48f3ac70d6d6782f4f553222
with:
fetch-depth: 0
- uses: docker://docker.io/nixos/nix@sha256:c3db4c484f6b1ee6c9bb8ca90307cfbeca8ef88156840911356a677eeaff4845
name: /lintGitCommitMsg
name: /tests/commitlint
with:
args: sh -c "chown -R root:root /github/workspace && nix-env -if . && m . /lintGitCommitMsg"
args: sh -c "chown -R root:root /github/workspace && nix-env -if . && m . /tests/commitlint"
macos_tests_commitlint:
runs-on: macos-latest
steps:
- uses: actions/checkout@f095bcc56b7c2baf48f3ac70d6d6782f4f553222
- uses: cachix/install-nix-action@6ed004b9ccb68dbc28e7c85bee15fa93dbd214ac
- name: /tests/commitlint
run: nix-env -if . && m . /tests/commitlint

linux_lintGitMailMap:
runs-on: ubuntu-latest
Expand Down
15 changes: 12 additions & 3 deletions .github/workflows/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -305,16 +305,25 @@ jobs:
env:
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}

linux_lintGitCommitMsg:
linux_tests_commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@f095bcc56b7c2baf48f3ac70d6d6782f4f553222
with:
fetch-depth: 0
- uses: docker://docker.io/nixos/nix@sha256:c3db4c484f6b1ee6c9bb8ca90307cfbeca8ef88156840911356a677eeaff4845
name: /lintGitCommitMsg
name: /tests/commitlint
with:
args: sh -c "chown -R root:root /github/workspace && nix-env -if . && m . /lintGitCommitMsg"
args: sh -c "chown -R root:root /github/workspace && nix-env -if . && m . /tests/commitlint"
env:
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
macos_tests_commitlint:
runs-on: macos-latest
steps:
- uses: actions/checkout@f095bcc56b7c2baf48f3ac70d6d6782f4f553222
- uses: cachix/install-nix-action@6ed004b9ccb68dbc28e7c85bee15fa93dbd214ac
- name: /tests/commitlint
run: nix-env -if . && m . /tests/commitlint
env:
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}

Expand Down
47 changes: 0 additions & 47 deletions docs/src/api/builtins/lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,53 +37,6 @@ Example:
m . /lintBash
```

## lintGitCommitMsg

It creates a commit diff
between you current branch
and the main branch of the repository.
All commits included in the diff
are linted using [Commitlint](https://commitlint.js.org/#/).

Types:

- lintGitCommitMsg:
- enable (`boolean`): Optional.
Defaults to `false`.
- branch (`str`): Optional.
Name of the main branch.
Defaults to `main`.
- config (`str`): Optional.
Path to a configuration file for Commitlint.
Defaults to
[config.js](/src/evaluator/modules/lint-git-commit-msg/config.js).
- parser (`str`): Optional.
Commitlint parser definitions.
Defaults to
[parser.js](/src/evaluator/modules/lint-git-commit-msg/parser.js).

Example:

=== "makes.nix"

```nix
{
lintGitCommitMsg = {
enable = true;
branch = "my-branch-name";
# If you want to use custom configs or parsers you can do it like this:
# config = "/src/config/config.js";
# parser = "/src/config/parser.js";
};
}
```

=== "Invocation"

```bash
m . /lintGitCommitMsg
```

## lintGitMailMap

Lint the [Git mailmap](https://git-scm.com/docs/gitmailmap)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Make sure to test it with `m . /lintGitMailMap`.
- You must sign your commits by adding a `Signed-off-by` line at the end of your
commit message.
- You can take a look at other commits [here](https://github.com/fluidattacks/makes/commits/main).
- Make sure to test it with `m . /lintGitCommitMsg`.
- Make sure to test it with `m . /tests/commitlint`.

#### Other PR rules

Expand Down
6 changes: 0 additions & 6 deletions makes.nix
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,6 @@
enable = true;
targets = [ "/" ];
};
lintGitCommitMsg = {
enable = true;
branch = "main";
parser = "/test/lint-commit-msg/lint-git-commit-msg-parser.js";
config = "/test/lint-commit-msg/lint-git-commit-msg-config.js";
};
lintGitMailMap = { enable = true; };
lintNix = {
enable = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const HEADERLENGTHMAX = 50;
const HEADERLENGTHMAX = 60;
const LINELENGTHMAX = 72;
const BODYLENGTHMIN = 15;

module.exports = {
parserPreset: "./.commitlint-parser-preset",
parserPreset: "./parser.js",
rules: {
// Body
"body-leading-blank": [2, "always"], // blank line between header and body
Expand Down
13 changes: 13 additions & 0 deletions makes/tests/commitlint/main.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{ makeScript, __nixpkgs__, ... }:
makeScript {
name = "commitlint";
entrypoint = ''
pushd makes/tests/commitlint
commit_hash="$(git --no-pager log --pretty=%h origin/main..HEAD)"
info "Linting commit $commit_hash"
git log -1 --pretty=%B $commit_hash | commitlint --parser-preset ./parser.js --config ./config.js
'';
searchPaths.bin = [ __nixpkgs__.commitlint __nixpkgs__.git ];
}
File renamed without changes.
1 change: 0 additions & 1 deletion src/args/agnostic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ let
inherit (__nixpkgs__.stdenv) isDarwin;
inherit (__nixpkgs__.stdenv) isLinux;
libGit = import ./lib-git/default.nix self;
lintGitCommitMsg = import ./lint-git-commit-msg/default.nix self;
lintGitMailMap = import ./lint-git-mailmap/default.nix self;
lintNix = import ./lint-nix/default.nix self;
lintTerraform = import ./lint-terraform/default.nix self;
Expand Down
Loading

0 comments on commit 208c374

Please sign in to comment.