diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f56b72d..248030d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,33 +22,14 @@ jobs: steps: - uses: actions/checkout@v6 - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - - - name: Cache Rust build artifacts - uses: Swatinem/rust-cache@v2 - with: - shared-key: rust-${{ runner.os }}-native - - - name: Install Janet - shell: bash - run: | - if [[ "$RUNNER_OS" == "Linux" ]]; then - sudo apt-get update && sudo apt-get install -y libssl-dev - git clone --depth 1 --branch v1.37.1 https://github.com/janet-lang/janet.git /tmp/janet - cd /tmp/janet && make -j$(nproc) && sudo make install - elif [[ "$RUNNER_OS" == "macOS" ]]; then - brew install janet - fi - - - name: Build - run: cargo build + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@main - - name: Janet tests - run: janet janet/test/run.janet + - name: Setup Nix cache + uses: DeterminateSystems/magic-nix-cache-action@main - - name: Rust tests - run: cargo test + - name: Run all checks (build, cargo test, janet tests, parinfer) + run: nix flake check -L - name: Installer smoke tests run: bash test/install.sh diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index f7afb14..406c812 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -27,28 +27,14 @@ jobs: steps: - uses: actions/checkout@v6 - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - - - name: Cache Rust build artifacts - uses: Swatinem/rust-cache@v2 - with: - shared-key: rust-${{ runner.os }}-native + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@main - - name: Install Janet - shell: bash - run: | - if [[ "$RUNNER_OS" == "Linux" ]]; then - git clone --depth 1 --branch v1.37.1 https://github.com/janet-lang/janet.git /tmp/janet - cd /tmp/janet && make -j$(nproc) && sudo make install - elif [[ "$RUNNER_OS" == "macOS" ]]; then - brew install janet - fi + - name: Setup Nix cache + uses: DeterminateSystems/magic-nix-cache-action@main - - name: Run tests - run: | - cargo build - janet janet/test/run.janet + - name: Run all checks (build, cargo test, janet tests, parinfer) + run: nix flake check -L build: name: Build ${{ matrix.target }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 127e447..ec54ddc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,28 +35,14 @@ jobs: with: ref: ${{ inputs.tag || github.ref }} - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - - - name: Cache Rust build artifacts - uses: Swatinem/rust-cache@v2 - with: - shared-key: rust-${{ runner.os }}-native + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@main - - name: Install Janet - shell: bash - run: | - if [[ "$RUNNER_OS" == "Linux" ]]; then - git clone --depth 1 --branch v1.37.1 https://github.com/janet-lang/janet.git /tmp/janet - cd /tmp/janet && make -j$(nproc) && sudo make install - elif [[ "$RUNNER_OS" == "macOS" ]]; then - brew install janet - fi + - name: Setup Nix cache + uses: DeterminateSystems/magic-nix-cache-action@main - - name: Run tests - run: | - cargo build - janet janet/test/run.janet + - name: Run all checks (build, cargo test, janet tests, parinfer) + run: nix flake check -L build: name: Build ${{ matrix.target }} diff --git a/flake.nix b/flake.nix index 001e313..08b93b0 100644 --- a/flake.nix +++ b/flake.nix @@ -165,42 +165,60 @@ ''; }; - checks.parinfer = let - parinfer = parinfer-rust.packages.${system}.default; - checkScript = pkgs.writeShellScript "parinfer-check.sh" '' - set -uo pipefail - failed=0 - skipped=0 - src="$1" - out="$2" - for f in $(find "$src/janet" -name '*.janet'); do - name="''${f#$src/}" - tmpfile=$(mktemp) - if ! ${parinfer}/bin/parinfer-rust --mode paren --language janet --no-janet-long-strings < "$f" > "$tmpfile" 2>/dev/null; then - echo "SKIP: $name (parinfer-rust cannot process this file)" - skipped=$((skipped + 1)) + checks = { + # Verify the project compiles (reuses the package derivation) + build = self.packages.${system}.gent; + + # Run the Janet test suite + janet-tests = pkgs.runCommand "janet-tests" { + nativeBuildInputs = [pkgs.janet]; + src = self; + } '' + cp -r $src/janet janet + chmod -R u+w janet + cd janet/.. + HOME=$(mktemp -d) janet janet/test/run.janet + touch $out + ''; + + # Parinfer formatting check + parinfer = let + parinfer = parinfer-rust.packages.${system}.default; + checkScript = pkgs.writeShellScript "parinfer-check.sh" '' + set -uo pipefail + failed=0 + skipped=0 + src="$1" + out="$2" + for f in $(find "$src/janet" -name '*.janet'); do + name="''${f#$src/}" + tmpfile=$(mktemp) + if ! ${parinfer}/bin/parinfer-rust --mode paren --language janet --no-janet-long-strings < "$f" > "$tmpfile" 2>/dev/null; then + echo "SKIP: $name (parinfer-rust cannot process this file)" + skipped=$((skipped + 1)) + rm -f "$tmpfile" + continue + fi + if ! diff -u "$f" "$tmpfile" > /dev/null 2>&1; then + echo "FAIL: $name needs parinfer formatting" + diff -u "$f" "$tmpfile" || true + failed=1 + fi rm -f "$tmpfile" - continue - fi - if ! diff -u "$f" "$tmpfile" > /dev/null 2>&1; then - echo "FAIL: $name needs parinfer formatting" - diff -u "$f" "$tmpfile" || true - failed=1 + done + if [ "$failed" = "1" ]; then + echo "" + echo "Run 'parinfer-rust -m paren -l janet < file.janet' to fix" + exit 1 fi - rm -f "$tmpfile" - done - if [ "$failed" = "1" ]; then - echo "" - echo "Run 'parinfer-rust -m paren -l janet < file.janet' to fix" - exit 1 - fi - echo "All processable .janet files pass parinfer check (skipped $skipped)" - touch "$out" - ''; - in - pkgs.runCommand "parinfer-check" {nativeBuildInputs = [parinfer pkgs.diffutils];} '' - ${checkScript} ${self} $out - ''; + echo "All processable .janet files pass parinfer check (skipped $skipped)" + touch "$out" + ''; + in + pkgs.runCommand "parinfer-check" {nativeBuildInputs = [parinfer pkgs.diffutils];} '' + ${checkScript} ${self} $out + ''; + }; # For `nix run` apps = {