From 3b10d021de2d1cf89da0a2289d4de3ff85dca99e Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Sat, 15 Jul 2023 17:38:52 +0900 Subject: [PATCH 1/3] Refine cargo-make tasks --- .githooks/pre-commit | 2 ++ Makefile.toml | 35 +++++++++++++---------------------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index a36adc4d..e1a42d9e 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -8,4 +8,6 @@ dprint check shfmt --diff ./**/*.bash shellcheck ./**/*.bash nixpkgs-fmt ./**/*.nix +# https://github.com/crate-ci/typos/issues/779 +typos . .github gitleaks detect diff --git a/Makefile.toml b/Makefile.toml index 7baf1318..0528e3f0 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -1,56 +1,54 @@ [config] skip_core_tasks = true +[tasks.default] +alias = "help" + +[tasks.help] +script = [ + 'makers --list-all-steps', +] + [tasks.setup] -category = "Tools" -description = "Install and configure dependencies (WIP)" script = [ "git config --local core.hooksPath .githooks", ] [tasks.update] -category = "Tools" script = [ "dprint config update --yes", ] [tasks.format-check] -category = "Tools" -description = "Run formatters without changes" script = [ "dprint check", ] [tasks.format-apply] -category = "Tools" -description = "Run formatters with changes" script = [ "dprint fmt", ] +[tasks.fmt] +alias = "format-apply" + [tasks.typos-check] -category = "Tools" -description = "Run formatters without changes" script = [ "typos", ] [tasks.prevent-secret] -category = "Tools" script = [ "gitleaks detect", ] [tasks.check] -category = "Tools" -description = 'Parallel runner for all tests and linters' run_task = { name = ["typos-check", "format-check", "prevent-secret"] } -[tasks.versions] -category = "Tools" -description = 'Print dependency versions' +[tasks.deps] script = [ "makers --version", + "nix --version", "dprint --version", "shellcheck --version", "shfmt --version", @@ -60,10 +58,3 @@ script = [ "fd --version", "typos --version", ] - -[tasks.help] -category = "Tools" -description = 'Might help you - (This one)' -script = [ - 'makers --list-category-steps Tools', -] From 5504ec35a29242c44dffef65728f4ae61fa7c3c0 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Sat, 15 Jul 2023 18:14:57 +0900 Subject: [PATCH 2/3] Extract basic development tasks --- .githooks/pre-commit | 9 ++------- .github/workflows/ci-dev.yml | 2 +- Makefile.toml | 38 +++++------------------------------- scripts/fmt.bash | 10 ++++++++++ scripts/lint.bash | 12 ++++++++++++ scripts/print-deps.bash | 17 ++++++++++++++++ 6 files changed, 47 insertions(+), 41 deletions(-) create mode 100755 scripts/fmt.bash create mode 100755 scripts/lint.bash create mode 100755 scripts/print-deps.bash diff --git a/.githooks/pre-commit b/.githooks/pre-commit index e1a42d9e..b3e96b20 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -4,10 +4,5 @@ set -euxo pipefail shopt -s globstar -dprint check -shfmt --diff ./**/*.bash -shellcheck ./**/*.bash -nixpkgs-fmt ./**/*.nix -# https://github.com/crate-ci/typos/issues/779 -typos . .github -gitleaks detect +./scripts/fmt.bash +./scripts/lint.bash diff --git a/.github/workflows/ci-dev.yml b/.github/workflows/ci-dev.yml index b2193d43..1b196b7a 100644 --- a/.github/workflows/ci-dev.yml +++ b/.github/workflows/ci-dev.yml @@ -27,6 +27,6 @@ jobs: - uses: DeterminateSystems/magic-nix-cache-action@v2 - run: nix-build - name: Log current versions - run: nix-shell --run 'makers versions' + run: nix-shell --run 'makers deps' - name: Run linters run: nix-shell --run 'makers check' diff --git a/Makefile.toml b/Makefile.toml index 0528e3f0..977e67a0 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -19,42 +19,14 @@ script = [ "dprint config update --yes", ] -[tasks.format-check] -script = [ - "dprint check", -] - -[tasks.format-apply] -script = [ - "dprint fmt", -] +[tasks.lint] +command = './scripts/lint.bash' [tasks.fmt] -alias = "format-apply" - -[tasks.typos-check] -script = [ - "typos", -] - -[tasks.prevent-secret] -script = [ - "gitleaks detect", -] +command = './scripts/fmt.bash' [tasks.check] -run_task = { name = ["typos-check", "format-check", "prevent-secret"] } +alias = "lint" [tasks.deps] -script = [ - "makers --version", - "nix --version", - "dprint --version", - "shellcheck --version", - "shfmt --version", - # Returns NON 0, why...? :< - # "nixpkgs-fmt --version", - "gitleaks version", - "fd --version", - "typos --version", -] +command = './scripts/print-deps.bash' diff --git a/scripts/fmt.bash b/scripts/fmt.bash new file mode 100755 index 00000000..3861d293 --- /dev/null +++ b/scripts/fmt.bash @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -euxo pipefail + +shopt -s globstar + +# fixing typo is a fmt ...? +typos . .github .config .vscode --write-changes + +dprint fmt diff --git a/scripts/lint.bash b/scripts/lint.bash new file mode 100755 index 00000000..965c2100 --- /dev/null +++ b/scripts/lint.bash @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -euxo pipefail + +shopt -s globstar + +dprint check +shfmt --diff ./**/*.bash +shellcheck ./**/*.bash +nixpkgs-fmt --check ./**/*.nix +typos . .github .config .vscode +gitleaks detect diff --git a/scripts/print-deps.bash b/scripts/print-deps.bash new file mode 100755 index 00000000..8ebd242d --- /dev/null +++ b/scripts/print-deps.bash @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -euxo pipefail + +shopt -s globstar + +makers --version +nix --version +dprint --version +shellcheck --version +shfmt --version +gitleaks version +fd --version +typos --version + +# Returns NON 0, why...? :< +# "nixpkgs-fmt --version", From d984880635064b219d1c6e81a2c168bb81107e52 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Sat, 15 Jul 2023 18:17:20 +0900 Subject: [PATCH 3/3] Simplify nix CI naming --- .github/workflows/{ci-dev.yml => ci-nix.yml} | 6 +++--- README.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename .github/workflows/{ci-dev.yml => ci-nix.yml} (86%) diff --git a/.github/workflows/ci-dev.yml b/.github/workflows/ci-nix.yml similarity index 86% rename from .github/workflows/ci-dev.yml rename to .github/workflows/ci-nix.yml index 1b196b7a..5cf0cd22 100644 --- a/.github/workflows/ci-dev.yml +++ b/.github/workflows/ci-nix.yml @@ -1,14 +1,14 @@ -name: CI - Development Environment +name: CI - Nix on: push: branches: [main] paths: - - '.github/workflows/ci-dev.yml' + - '.github/workflows/ci-nix.yml' - '*.nix' - 'Makefile.toml' pull_request: paths: - - '.github/workflows/ci-dev.yml' + - '.github/workflows/ci-nix.yml' - '*.nix' - 'Makefile.toml' schedule: diff --git a/README.md b/README.md index 01f98424..fe9eea75 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # dotfiles [![Linter Status](https://github.com/kachick/dotfiles/actions/workflows/lint.yml/badge.svg?branch=main)](https://github.com/kachick/dotfiles/actions/workflows/lint.yml?query=branch%3Amain+) -[![Development Environment Status](https://github.com/kachick/dotfiles/actions/workflows/ci-dev.yml/badge.svg?branch=main)](https://github.com/kachick/dotfiles/actions/workflows/ci-dev.yml?query=branch%3Amain+) +[![Nix Status](https://github.com/kachick/dotfiles/actions/workflows/ci-nix.yml/badge.svg?branch=main)](https://github.com/kachick/dotfiles/actions/workflows/ci-nix.yml?query=branch%3Amain+) Personal dotfiles that can be placed in the public repository