Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 6 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 6 additions & 20 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
26 changes: 6 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
86 changes: 52 additions & 34 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Loading