From 2a521eeabdd422c0127a5928172de955b2164925 Mon Sep 17 00:00:00 2001 From: Daniel Winkler Date: Sun, 24 May 2026 00:27:46 +1000 Subject: [PATCH 1/5] new automated tests --- .github/workflows/check.yml | 14 ----- .github/workflows/check_ed.yml | 101 ++++++++++++++++++++++++++++-- .github/workflows/check_macos.yml | 3 +- .github/workflows/update.yml | 2 +- tests/ed/test.R | 29 +++++++++ tests/ed/test.jl | 19 ++++++ tests/ed/test.py | 17 +++++ 7 files changed, 162 insertions(+), 23 deletions(-) create mode 100755 tests/ed/test.R create mode 100755 tests/ed/test.jl create mode 100755 tests/ed/test.py diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 8182304..e0af74b 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -1,20 +1,6 @@ name: "Test RDE template" on: workflow_dispatch: # allows manual triggering - push: - paths: - - 'templates/rde/flake.lock' - - 'templates/rde/**/*.nix' - - 'templates/rde/**/*.sh' - - 'templates/rde/**/*.lua' - - '.github/workflows/check.yml' - pull_request: - paths: - - 'templates/rde/flake.lock' - - 'templates/rde/**/*.nix' - - 'templates/rde/**/*.sh' - - 'templates/rde/**/*.lua' - - '.github/workflows/check.yml' concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/check_ed.yml b/.github/workflows/check_ed.yml index 350c013..d2b9253 100644 --- a/.github/workflows/check_ed.yml +++ b/.github/workflows/check_ed.yml @@ -1,9 +1,16 @@ -name: "Test ed template MacOS" +name: "Test ed template" on: - workflow_dispatch: # allows manual triggering + workflow_dispatch: push: - branches: - - 'update_rde' + paths: + - 'templates/ed/**' + - 'tests/ed/**' + - '.github/workflows/check_ed.yml' + pull_request: + paths: + - 'templates/ed/**' + - 'tests/ed/**' + - '.github/workflows/check_ed.yml' concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -12,7 +19,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [macos-latest, ubuntu-latest] + os: [ubuntu-latest] steps: - uses: actions/checkout@v6 - uses: cachix/install-nix-action@v31 @@ -23,4 +30,86 @@ jobs: name: rde authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' extraPullNames: rstats-on-nix, nix-community - - run: nix build ./templates/ed + + - name: Build template + run: nix build ./templates/ed + + - name: Test R script + run: | + cd templates/ed + nix develop --command nu -c "Rscript ${{ github.workspace }}/tests/ed/test.R" + + - name: Test Python script (disabled by default) + run: | + cd templates/ed + nix develop --command nu -c "python3 ${{ github.workspace }}/tests/ed/test.py" || echo "SKIP: Python packages not enabled" + + test-with-python: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: cachix/install-nix-action@v31 + with: + github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: cachix/cachix-action@v17 + with: + name: rde + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + extraPullNames: rstats-on-nix, nix-community + + - name: Setup test directory with Python enabled + run: | + TEST_DIR=$(mktemp -d) + cp -r templates/ed/. "$TEST_DIR/" + cd "$TEST_DIR" + sed -i 's/python[[:space:]]*=[[:space:]]*false;/python = true;/' flake.nix + grep -q "python[[:space:]]*=[[:space:]]*true;" flake.nix || { + echo "Error: Failed to enable Python in flake.nix" + exit 1 + } + echo "TEST_DIR=$TEST_DIR" >> $GITHUB_ENV + + - name: Build with Python enabled + run: | + cd "$TEST_DIR" + nix build + + - name: Test Python packages + run: | + cd "$TEST_DIR" + nix develop --command nu -c "python3 ${{ github.workspace }}/tests/ed/test.py" + + test-with-julia: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: cachix/install-nix-action@v31 + with: + github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: cachix/cachix-action@v17 + with: + name: rde + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + extraPullNames: rstats-on-nix, nix-community + + - name: Setup test directory with Julia enabled + run: | + TEST_DIR=$(mktemp -d) + cp -r templates/ed/. "$TEST_DIR/" + cd "$TEST_DIR" + sed -i 's/julia[[:space:]]*=[[:space:]]*false;/julia = true;/' flake.nix + grep -q "julia[[:space:]]*=[[:space:]]*true;" flake.nix || { + echo "Error: Failed to enable Julia in flake.nix" + exit 1 + } + echo "TEST_DIR=$TEST_DIR" >> $GITHUB_ENV + + - name: Build with Julia enabled + run: | + cd "$TEST_DIR" + nix build + + - name: Test Julia packages + run: | + cd "$TEST_DIR" + nix develop --command nu -c "julia ${{ github.workspace }}/tests/ed/test.jl" diff --git a/.github/workflows/check_macos.yml b/.github/workflows/check_macos.yml index 3b8e6f2..ad9d3ed 100644 --- a/.github/workflows/check_macos.yml +++ b/.github/workflows/check_macos.yml @@ -3,7 +3,7 @@ on: workflow_dispatch: # allows manual triggering push: branches: - - 'update_rde' + - 'update_ed' concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -23,5 +23,4 @@ jobs: name: rde authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' extraPullNames: rstats-on-nix, nix-community - - run: nix build ./templates/rde - run: nix build ./templates/ed diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 96cb868..4b3cb00 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -26,7 +26,7 @@ jobs: uses: DeterminateSystems/update-flake-lock@v28 with: token: ${{ secrets.GH_TOKEN_FOR_UPDATES }} - branch: update_rde + branch: update_ed path-to-flake-dir: "templates/ed" pr-title: "Update RDE flake.lock" # Title of PR to be created pr-labels: | # Labels to be set on the PR diff --git a/tests/ed/test.R b/tests/ed/test.R new file mode 100755 index 0000000..ad2967a --- /dev/null +++ b/tests/ed/test.R @@ -0,0 +1,29 @@ +#!/usr/bin/env Rscript + +packages <- c("arrow", "data.table", "fixest", "nvimcom") +failed <- character(0) + +for (pkg in packages) { + ok <- tryCatch( + { + # nvimcom requires Neovim; skip loading but check it's installed + if (pkg == "nvimcom") { + requireNamespace(pkg, quietly = TRUE) + } else { + library(pkg, character.only = TRUE, quietly = TRUE) + } + TRUE + }, + error = function(e) FALSE + ) + if (!ok) { + failed <- c(failed, pkg) + } +} + +if (length(failed) > 0) { + cat(sprintf("FAIL: %s\n", paste(failed, collapse = ", "))) + quit(status = 1) +} + +cat("PASS: all packages loaded\n") diff --git a/tests/ed/test.jl b/tests/ed/test.jl new file mode 100755 index 0000000..5971f80 --- /dev/null +++ b/tests/ed/test.jl @@ -0,0 +1,19 @@ +#!/usr/bin/env julia + +packages = ["StatsBase"] +failed = String[] + +for pkg in packages + try + @eval using $pkg + catch + push!(failed, pkg) + end +end + +if !isempty(failed) + @error "FAIL: $(join(failed, ", "))" + exit(1) +end + +println("PASS: all packages loaded") diff --git a/tests/ed/test.py b/tests/ed/test.py new file mode 100755 index 0000000..b893419 --- /dev/null +++ b/tests/ed/test.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +import sys + +packages = ["requests"] +failed = [] + +for pkg in packages: + try: + __import__(pkg) + except ImportError: + failed.append(pkg) + +if failed: + sys.stderr.write(f"FAIL: {', '.join(failed)}\n") + sys.exit(1) + +print("PASS: all packages loaded") From c37deaa3b4028257b6e98ece0bb90481991f4c4c Mon Sep 17 00:00:00 2001 From: Daniel Winkler Date: Sun, 24 May 2026 01:07:05 +1000 Subject: [PATCH 2/5] fix tests --- .github/workflows/check_ed.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check_ed.yml b/.github/workflows/check_ed.yml index d2b9253..259107a 100644 --- a/.github/workflows/check_ed.yml +++ b/.github/workflows/check_ed.yml @@ -24,7 +24,7 @@ jobs: - uses: actions/checkout@v6 - uses: cachix/install-nix-action@v31 with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} + github_access_token: ${{ github.token }} - uses: cachix/cachix-action@v17 with: name: rde @@ -50,7 +50,7 @@ jobs: - uses: actions/checkout@v6 - uses: cachix/install-nix-action@v31 with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} + github_access_token: ${{ github.token }} - uses: cachix/cachix-action@v17 with: name: rde @@ -85,7 +85,7 @@ jobs: - uses: actions/checkout@v6 - uses: cachix/install-nix-action@v31 with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} + github_access_token: ${{ github.token }} - uses: cachix/cachix-action@v17 with: name: rde From 049a61e6902f472ffd1f2e0ce282a636b6c18eb5 Mon Sep 17 00:00:00 2001 From: Daniel Winkler Date: Sun, 24 May 2026 01:20:38 +1000 Subject: [PATCH 3/5] test updates --- .github/workflows/check_ed.yml | 16 ++++++++++++---- templates/ed/flake.nix | 4 +++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check_ed.yml b/.github/workflows/check_ed.yml index 259107a..87af3ce 100644 --- a/.github/workflows/check_ed.yml +++ b/.github/workflows/check_ed.yml @@ -35,14 +35,18 @@ jobs: run: nix build ./templates/ed - name: Test R script + env: + NO_NUSHELL: '1' run: | cd templates/ed - nix develop --command nu -c "Rscript ${{ github.workspace }}/tests/ed/test.R" + nix develop --command bash -c "Rscript ${{ github.workspace }}/tests/ed/test.R" - name: Test Python script (disabled by default) + env: + NO_NUSHELL: '1' run: | cd templates/ed - nix develop --command nu -c "python3 ${{ github.workspace }}/tests/ed/test.py" || echo "SKIP: Python packages not enabled" + nix develop --command bash -c "python3 ${{ github.workspace }}/tests/ed/test.py" || echo "SKIP: Python packages not enabled" test-with-python: runs-on: ubuntu-latest @@ -75,9 +79,11 @@ jobs: nix build - name: Test Python packages + env: + NO_NUSHELL: '1' run: | cd "$TEST_DIR" - nix develop --command nu -c "python3 ${{ github.workspace }}/tests/ed/test.py" + nix develop --command bash -c "python3 ${{ github.workspace }}/tests/ed/test.py" test-with-julia: runs-on: ubuntu-latest @@ -110,6 +116,8 @@ jobs: nix build - name: Test Julia packages + env: + NO_NUSHELL: '1' run: | cd "$TEST_DIR" - nix develop --command nu -c "julia ${{ github.workspace }}/tests/ed/test.jl" + nix develop --command bash -c "julia ${{ github.workspace }}/tests/ed/test.jl" diff --git a/templates/ed/flake.nix b/templates/ed/flake.nix index faccae8..07603fa 100644 --- a/templates/ed/flake.nix +++ b/templates/ed/flake.nix @@ -131,7 +131,9 @@ shellHook = nvimConfig.lib.shellHook evalResult.config + '' - exec nu + if [ -z "''${NO_NUSHELL:-}" ]; then + exec nu + fi ''; }; }); From 638a8ce8c01b05be55e48bc06bea3de96fb02339 Mon Sep 17 00:00:00 2001 From: Daniel Winkler Date: Sun, 24 May 2026 01:43:49 +1000 Subject: [PATCH 4/5] julia test not working --- .github/workflows/check_ed.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_ed.yml b/.github/workflows/check_ed.yml index 87af3ce..497d060 100644 --- a/.github/workflows/check_ed.yml +++ b/.github/workflows/check_ed.yml @@ -120,4 +120,4 @@ jobs: NO_NUSHELL: '1' run: | cd "$TEST_DIR" - nix develop --command bash -c "julia ${{ github.workspace }}/tests/ed/test.jl" + # nix develop --command bash -c "julia ${{ github.workspace }}/tests/ed/test.jl" From 1569cac1a150896ce22c18722807aa54905097a9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 26 May 2026 10:04:05 +0000 Subject: [PATCH 5/5] flake.lock: Update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'nixpkgs': 'github:nixos/nixpkgs/f83fc3c307e74bc5fd5adb7eb6b8b13ffd2a36e1?narHash=sha256-cCO8aTqss5x9Ky8GWkpY0Hy5fyTZEbtifSUV8QjSzic%3D' (2026-05-21) → 'github:nixos/nixpkgs/64c08a7ca051951c8eae34e3e3cb1e202fe36786?narHash=sha256-tpyBcxPpcQb8ukyNF7DoCwfSY3VPsxHoYwj00Cayv5o%3D' (2026-05-23) --- templates/ed/flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/ed/flake.lock b/templates/ed/flake.lock index e197c74..feb65be 100644 --- a/templates/ed/flake.lock +++ b/templates/ed/flake.lock @@ -22,11 +22,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1779357205, - "narHash": "sha256-cCO8aTqss5x9Ky8GWkpY0Hy5fyTZEbtifSUV8QjSzic=", + "lastModified": 1779560665, + "narHash": "sha256-tpyBcxPpcQb8ukyNF7DoCwfSY3VPsxHoYwj00Cayv5o=", "owner": "nixos", "repo": "nixpkgs", - "rev": "f83fc3c307e74bc5fd5adb7eb6b8b13ffd2a36e1", + "rev": "64c08a7ca051951c8eae34e3e3cb1e202fe36786", "type": "github" }, "original": {