From b35c295670bbf85d5fa41f836c9e2a596ef2936f Mon Sep 17 00:00:00 2001 From: Peter Murphy <26548438+ptrfrncsmrph@users.noreply.github.com> Date: Sat, 2 Dec 2023 12:13:40 -0500 Subject: [PATCH 1/2] fix: Fix CI (#16) --- .github/workflows/ci.yaml | 43 ++++-------------------------- flake.nix | 55 +++++++++++++++++++++++++++------------ 2 files changed, 44 insertions(+), 54 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8f040bf..cb29b3c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,44 +10,11 @@ on: # Run CI on all 3 latest OSes jobs: - build: + check: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - uses: purescript-contrib/setup-purescript@main - with: - purescript: "0.15.9" - purs-tidy: "0.10.0" - psa: "0.8.2" - spago: "unstable" - - - name: Cache PureScript dependencies - uses: actions/cache@v2 - with: - key: ${{ runner.os }}-spago-${{ hashFiles('**/*.dhall') }} - path: | - .spago - output - - - name: Set up Node toolchain - uses: actions/setup-node@v2 - with: - node-version: "18" - - # Compile the library/project - # censor-lib: ignore warnings emitted by dependencies - # strict: convert warnings into errors - # Note: `purs-args` actually forwards these args to `psa` - - name: Build the project - run: | - spago build --purs-args "--censor-lib --strict" - - - name: Run tests - run: | - spago -x test.dhall test + - uses: actions/checkout@v3 + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main + - run: nix flake check - - name: Check Formatting - run: | - purs-tidy check src test diff --git a/flake.nix b/flake.nix index e5f8648..6547ee8 100644 --- a/flake.nix +++ b/flake.nix @@ -6,20 +6,43 @@ purescript-overlay.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = { self, nixpkgs, flake-utils, purescript-overlay }: - flake-utils.lib.eachDefaultSystem (system: - let - overlays = [ purescript-overlay.overlays.default ]; - pkgs = import nixpkgs { inherit system overlays; }; - in { - devShells.default = pkgs.mkShell { - buildInputs = with pkgs; [ - purs - purs-tidy - purs-backend-es - nodejs - spago-unstable - ]; - }; - }); + outputs = { + self, + nixpkgs, + flake-utils, + purescript-overlay, + }: + flake-utils.lib.eachDefaultSystem (system: let + overlays = [purescript-overlay.overlays.default]; + pkgs = import nixpkgs {inherit system overlays;}; + in { + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ + # PureScript tools + purs + purs-tidy + purs-backend-es + spago-unstable + # Node + nodejs + # Nix + alejandra + ]; + }; + + checks = { + format = + pkgs.runCommand "check-format" + { + buildInputs = with pkgs; [ + alejandra + purs-tidy + ]; + } '' + ${pkgs.alejandra}/bin/alejandra --check ${./.} + ${pkgs.purs-tidy}/bin/purs-tidy check ${./src} + touch $out + ''; + }; + }); } From a4ca7ce767247499fed6e4e19ac1a4b230bbc80f Mon Sep 17 00:00:00 2001 From: Peter Murphy <26548438+ptrfrncsmrph@users.noreply.github.com> Date: Sat, 2 Dec 2023 12:57:18 -0500 Subject: [PATCH 2/2] fix: Add CI scripts --- .github/workflows/ci.yaml | 13 +++++++++++-- flake.nix | 20 ++++++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cb29b3c..1d578c5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,7 +8,6 @@ on: pull_request: branches: [main] -# Run CI on all 3 latest OSes jobs: check: runs-on: ubuntu-latest @@ -16,5 +15,15 @@ jobs: - uses: actions/checkout@v3 - uses: DeterminateSystems/nix-installer-action@main - uses: DeterminateSystems/magic-nix-cache-action@main - - run: nix flake check + + - name: "Nix check" + run: nix flake check + + - name: "Run tests" + run: | + nix develop --command 'run-install' + nix develop --command 'run-test' + + - name: "Check format" + run: nix develop --command 'run-check-format' diff --git a/flake.nix b/flake.nix index 6547ee8..acfb7ff 100644 --- a/flake.nix +++ b/flake.nix @@ -15,9 +15,27 @@ flake-utils.lib.eachDefaultSystem (system: let overlays = [purescript-overlay.overlays.default]; pkgs = import nixpkgs {inherit system overlays;}; + scripts = pkgs.symlinkJoin { + name = "scripts"; + paths = pkgs.lib.mapAttrsToList pkgs.writeShellScriptBin { + run-install = '' + spago install + ''; + + run-test = '' + spago test + ''; + + run-check-format = '' + purs-tidy check src test + ''; + }; + }; in { devShells.default = pkgs.mkShell { buildInputs = with pkgs; [ + scripts + # PureScript tools purs purs-tidy @@ -36,11 +54,9 @@ { buildInputs = with pkgs; [ alejandra - purs-tidy ]; } '' ${pkgs.alejandra}/bin/alejandra --check ${./.} - ${pkgs.purs-tidy}/bin/purs-tidy check ${./src} touch $out ''; };