Skip to content

Commit

Permalink
build: switch to treefmt
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkolenz committed Oct 1, 2024
1 parent 75a2448 commit 0998381
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 92 deletions.
25 changes: 24 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,47 @@ on:
push:
branches: [main, beta]
jobs:
format:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
outputs:
git-head: ${{ steps.git-push.outputs.git-head }}
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v14
- uses: DeterminateSystems/magic-nix-cache-action@v8
- run: nix fmt
- uses: cihelper/action-git-push@v1
id: git-push
with:
commit-message: "refactor: format code"
check:
runs-on: ubuntu-latest
needs: format
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.format.outputs.git-head }}
- uses: DeterminateSystems/nix-installer-action@v14
- uses: DeterminateSystems/magic-nix-cache-action@v8
- run: nix flake check --show-trace
release:
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'recap-utr' && github.event_name == 'push' }}
needs: check
needs:
- check
- format
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.format.outputs.git-head }}
- uses: DeterminateSystems/nix-installer-action@v14
- uses: DeterminateSystems/magic-nix-cache-action@v8
- uses: cihelper/action-semanticrelease-npm@v1
Expand Down
100 changes: 22 additions & 78 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 17 additions & 13 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
url = "github:mirkolenz/flocken/v2";
inputs.nixpkgs.follows = "nixpkgs";
};
git-hooks = {
url = "github:cachix/git-hooks.nix";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
Expand All @@ -27,7 +27,7 @@
flake-parts.lib.mkFlake { inherit inputs; } {
systems = import systems;
imports = [
inputs.git-hooks.flakeModule
inputs.treefmt-nix.flakeModule
];
perSystem =
{
Expand Down Expand Up @@ -60,24 +60,28 @@
{
devShells.default = pkgs.mkShell {
shellHook = ''
${config.pre-commit.installationScript}
${lib.getExe' nodejs "npm"} install
${lib.getExe nodejs} --version > .node-version
'';
packages = [ nodejs ];
packages = [
nodejs
config.treefmt.build.wrapper
];
};
checks = {
inherit (config.packages) arguemapper server;
};
pre-commit.settings.hooks = {
prettier = {
enable = true;
excludes = [
"flake.lock"
"CHANGELOG.md"
];
treefmt = {
projectRootFile = "flake.nix";
programs = {
prettier = {
enable = true;
excludes = [
"CHANGELOG.md"
];
};
nixfmt.enable = true;
};
nixfmt-rfc-style.enable = true;
};
packages = {
default = npmlock2nix.v2.build {
Expand Down

0 comments on commit 0998381

Please sign in to comment.