diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml new file mode 100644 index 0000000..2137b34 --- /dev/null +++ b/.github/workflows/check.yaml @@ -0,0 +1,25 @@ +name: "Check Codebase" + +on: + pull_request: + workflow_dispatch: + +jobs: + check: + runs-on: "ubuntu-latest" + + steps: + - name: "Checkout Codebase" + uses: "actions/checkout@v4" + + - name: "Install nix" + uses: "cachix/install-nix-action@v25" + with: + nix_path: "nixpkgs=channel:nixos-23.11" + + - name: "Use magic Nix cache" + uses: "DeterminateSystems/magic-nix-cache-action@v3" + + - name: "Check" + run: | + nix-shell --run "dev-test-build" diff --git a/.prettierrc.json b/.prettierrc.json index e7ffdfe..aae5213 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -2,5 +2,13 @@ "tabWidth": 2, "singleQuote": false, "trailingComma": "es5", - "printWidth": 120 + "printWidth": 120, + "overrides": [ + { + "files": "package.yaml", + "options": { + "singleQuote": true + } + } + ] } diff --git a/README.md b/README.md index af27b02..ee38753 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ The codebase comes with a Nix shell. You can use `direnv` for conveience: direnv allow ``` -Big, long build command for the impatient: +Big, long format, lint, build and test command for the impatient: ```sh hpack && @@ -25,4 +25,10 @@ hpack && cabal haddock -O0 ``` +For testing and building: + +```sh +dev-test-build +``` + diff --git a/default.nix b/default.nix index 313d5a0..c6e9684 100644 --- a/default.nix +++ b/default.nix @@ -65,6 +65,26 @@ let ## SHELL ## ########### + dev-test-build = pkgs.writeShellScriptBin "dev-test-build" '' + #!/usr/bin/env bash + + ## Fail on any error: + set -e + + ## Show commands executed: + set -x + + hpack + fourmolu --mode check app/ src/ test/ + prettier --check . + find . -iname "*.nix" -not -path "*/nix/sources.nix" -print0 | xargs --null nixpkgs-fmt --check + hlint app/ src/ test/ + cabal build -O0 + cabal run -O0 lhp -- --version + cabal v1-test + cabal haddock -O0 + ''; + ## Prepare Nix shell: thisShell = thisHaskell.shellFor { ## Define packages for the shell: @@ -91,6 +111,9 @@ let pkgs.nil pkgs.nixpkgs-fmt pkgs.nodePackages.prettier + + ## Our custom scripts: + dev-test-build ]; }; diff --git a/release-please-config.json b/release-please-config.json index ab63ce0..df9d6fb 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -10,9 +10,7 @@ "draft": false, "prerelease": false, "initial-version": "0.0.1", - "extra-files": [ - "package.yaml" - ] + "extra-files": ["package.yaml"] } } }