mirror of
https://github.com/dwinkler1/np.git
synced 2026-02-19 22:40:57 -05:00
Merge pull request #61 from dwinkler1/copilot/add-ci-checks-for-template
This commit is contained in:
commit
4a9b9a094a
4 changed files with 301 additions and 3 deletions
196
.github/workflows/check.yml
vendored
196
.github/workflows/check.yml
vendored
|
|
@ -4,6 +4,17 @@ on:
|
||||||
push:
|
push:
|
||||||
paths:
|
paths:
|
||||||
- 'templates/rde/flake.lock'
|
- '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:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
@ -27,5 +38,186 @@ jobs:
|
||||||
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
||||||
extraPullNames: rstats-on-nix, nix-community
|
extraPullNames: rstats-on-nix, nix-community
|
||||||
# - uses: DeterminateSystems/magic-nix-cache-action@main
|
# - uses: DeterminateSystems/magic-nix-cache-action@main
|
||||||
- run: nix build ./templates/rde
|
|
||||||
- run: nix flake check ./templates/rde
|
# Build and basic checks
|
||||||
|
- name: Build template
|
||||||
|
run: nix build ./templates/rde
|
||||||
|
- name: Run flake check
|
||||||
|
run: nix flake check ./templates/rde
|
||||||
|
|
||||||
|
# Test development shell functionality
|
||||||
|
- name: Test dev shell enters successfully
|
||||||
|
run: |
|
||||||
|
cd templates/rde
|
||||||
|
nix develop --command bash -c "echo 'Dev shell works'"
|
||||||
|
|
||||||
|
# Test R functionality (default enabled)
|
||||||
|
- name: Test R command is available
|
||||||
|
run: |
|
||||||
|
cd templates/rde
|
||||||
|
nix develop --command bash -c "which p-r"
|
||||||
|
|
||||||
|
- name: Test R launches and runs basic command
|
||||||
|
run: |
|
||||||
|
cd templates/rde
|
||||||
|
nix develop --command bash -c "p-r --version"
|
||||||
|
|
||||||
|
- name: Test R can execute simple code
|
||||||
|
run: |
|
||||||
|
cd templates/rde
|
||||||
|
nix develop --command bash -c "p-r -e 'print(1+1)'"
|
||||||
|
|
||||||
|
- name: Test Quarto is available in R environment
|
||||||
|
run: |
|
||||||
|
cd templates/rde
|
||||||
|
nix develop --command bash -c "quarto --version"
|
||||||
|
|
||||||
|
# Test Neovim functionality
|
||||||
|
- name: Test Neovim command is available
|
||||||
|
run: |
|
||||||
|
cd templates/rde
|
||||||
|
nix develop --command bash -c "which p"
|
||||||
|
|
||||||
|
- name: Test Neovim launches in headless mode
|
||||||
|
run: |
|
||||||
|
cd templates/rde
|
||||||
|
nix develop --command bash -c "p --headless --version"
|
||||||
|
|
||||||
|
# Test utility commands
|
||||||
|
- name: Test p-initProject command is available
|
||||||
|
run: |
|
||||||
|
cd templates/rde
|
||||||
|
nix develop --command bash -c "which p-initProject"
|
||||||
|
|
||||||
|
- name: Test p-initProject creates project structure
|
||||||
|
run: |
|
||||||
|
TEST_DIR=$(mktemp -d)
|
||||||
|
cd "$TEST_DIR"
|
||||||
|
nix develop $GITHUB_WORKSPACE/templates/rde --command bash -c "p-initProject"
|
||||||
|
# Verify directories were created
|
||||||
|
test -d data/raw || exit 1
|
||||||
|
test -d data/processed || exit 1
|
||||||
|
test -d src || exit 1
|
||||||
|
test -f README.md || exit 1
|
||||||
|
test -f .gitignore || exit 1
|
||||||
|
echo "Project structure created successfully"
|
||||||
|
# Cleanup
|
||||||
|
rm -rf "$TEST_DIR"
|
||||||
|
|
||||||
|
- name: Test p-updateDeps command is available
|
||||||
|
run: |
|
||||||
|
cd templates/rde
|
||||||
|
nix develop --command bash -c "which p-updateDeps"
|
||||||
|
|
||||||
|
# Test that package is built correctly
|
||||||
|
- name: Test default package can be run
|
||||||
|
run: |
|
||||||
|
cd templates/rde
|
||||||
|
nix run . -- --headless --version
|
||||||
|
|
||||||
|
test-with-python:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- uses: wimpysworld/nothing-but-nix@main
|
||||||
|
with:
|
||||||
|
hatchet-protocol: 'carve'
|
||||||
|
- uses: cachix/install-nix-action@v31
|
||||||
|
with:
|
||||||
|
github_access_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- uses: cachix/cachix-action@v16
|
||||||
|
with:
|
||||||
|
name: rde
|
||||||
|
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
||||||
|
extraPullNames: rstats-on-nix, nix-community
|
||||||
|
|
||||||
|
# Create a temporary directory with Python enabled
|
||||||
|
- name: Setup test directory with Python enabled
|
||||||
|
run: |
|
||||||
|
TEST_DIR=$(mktemp -d)
|
||||||
|
cp -r templates/rde/. "$TEST_DIR/"
|
||||||
|
cd "$TEST_DIR"
|
||||||
|
# Enable Python in the config (handle variations in whitespace)
|
||||||
|
sed -i 's/python[[:space:]]*=[[:space:]]*false;/python = true;/' flake.nix
|
||||||
|
# Verify the change was successful
|
||||||
|
grep -q "python[[:space:]]*=[[:space:]]*true;" flake.nix || {
|
||||||
|
echo "Error: Failed to enable Python in flake.nix"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
echo "TEST_PYTHON_DIR=$TEST_DIR" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Build with Python enabled
|
||||||
|
run: |
|
||||||
|
cd "$TEST_PYTHON_DIR"
|
||||||
|
nix build
|
||||||
|
|
||||||
|
- name: Test Python commands are available
|
||||||
|
run: |
|
||||||
|
cd "$TEST_PYTHON_DIR"
|
||||||
|
nix develop --command bash -c "which p-py && which p-ipy && which p-initPython"
|
||||||
|
|
||||||
|
- name: Test Python launches
|
||||||
|
run: |
|
||||||
|
cd "$TEST_PYTHON_DIR"
|
||||||
|
nix develop --command bash -c "p-py --version"
|
||||||
|
|
||||||
|
- name: Test Python can execute code
|
||||||
|
run: |
|
||||||
|
cd "$TEST_PYTHON_DIR"
|
||||||
|
nix develop --command bash -c "p-py -c 'print(1+1)'"
|
||||||
|
|
||||||
|
- name: Test UV package manager is available
|
||||||
|
run: |
|
||||||
|
cd "$TEST_PYTHON_DIR"
|
||||||
|
nix develop --command bash -c "uv --version"
|
||||||
|
|
||||||
|
test-with-julia:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- uses: wimpysworld/nothing-but-nix@main
|
||||||
|
with:
|
||||||
|
hatchet-protocol: 'carve'
|
||||||
|
- uses: cachix/install-nix-action@v31
|
||||||
|
with:
|
||||||
|
github_access_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- uses: cachix/cachix-action@v16
|
||||||
|
with:
|
||||||
|
name: rde
|
||||||
|
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
||||||
|
extraPullNames: rstats-on-nix, nix-community
|
||||||
|
|
||||||
|
# Create a temporary directory with Julia enabled
|
||||||
|
- name: Setup test directory with Julia enabled
|
||||||
|
run: |
|
||||||
|
TEST_DIR=$(mktemp -d)
|
||||||
|
cp -r templates/rde/. "$TEST_DIR/"
|
||||||
|
cd "$TEST_DIR"
|
||||||
|
# Enable Julia in the config (handle variations in whitespace)
|
||||||
|
sed -i 's/julia[[:space:]]*=[[:space:]]*false;/julia = true;/' flake.nix
|
||||||
|
# Verify the change was successful
|
||||||
|
grep -q "julia[[:space:]]*=[[:space:]]*true;" flake.nix || {
|
||||||
|
echo "Error: Failed to enable Julia in flake.nix"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
echo "TEST_JULIA_DIR=$TEST_DIR" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Build with Julia enabled
|
||||||
|
run: |
|
||||||
|
cd "$TEST_JULIA_DIR"
|
||||||
|
nix build
|
||||||
|
|
||||||
|
- name: Test Julia commands are available
|
||||||
|
run: |
|
||||||
|
cd "$TEST_JULIA_DIR"
|
||||||
|
nix develop --command bash -c "which p-jl && which p-initJl"
|
||||||
|
|
||||||
|
- name: Test Julia launches
|
||||||
|
run: |
|
||||||
|
cd "$TEST_JULIA_DIR"
|
||||||
|
nix develop --command bash -c "p-jl --version"
|
||||||
|
|
||||||
|
- name: Test Julia can execute code
|
||||||
|
run: |
|
||||||
|
cd "$TEST_JULIA_DIR"
|
||||||
|
nix develop --command bash -c "p-jl -e 'println(1+1)'"
|
||||||
|
|
|
||||||
70
README.md
Normal file
70
README.md
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
# Nix Project Templates (np)
|
||||||
|
|
||||||
|
A collection of Nix flake templates for reproducible development environments.
|
||||||
|
|
||||||
|
## Templates
|
||||||
|
|
||||||
|
### RDE (Research Development Environment)
|
||||||
|
|
||||||
|
The default template for data science and research projects with support for R, Python, and Julia.
|
||||||
|
|
||||||
|
**Quick start:**
|
||||||
|
```bash
|
||||||
|
nix flake init -t github:dwinkler1/np#rde
|
||||||
|
nix develop
|
||||||
|
```
|
||||||
|
|
||||||
|
**Features:**
|
||||||
|
- 🔬 Multi-language support (R, Python, Julia)
|
||||||
|
- 📦 Reproducible with Nix
|
||||||
|
- 🎨 Neovim-based IDE with LSP support
|
||||||
|
- 📊 Research-focused workflows
|
||||||
|
- 🔧 Modular and customizable
|
||||||
|
|
||||||
|
See [templates/rde/README.md](templates/rde/README.md) for full documentation.
|
||||||
|
|
||||||
|
## CI/CD
|
||||||
|
|
||||||
|
All templates are automatically tested to ensure functionality:
|
||||||
|
|
||||||
|
- **Build Tests**: Templates build successfully on Linux and macOS
|
||||||
|
- **Functionality Tests**: All commands and language support are verified
|
||||||
|
- **Configuration Tests**: Multiple configurations (R, Python, Julia) are tested
|
||||||
|
- **Automated Updates**: Dependencies are updated daily via automated PRs
|
||||||
|
|
||||||
|
### CI Workflows
|
||||||
|
|
||||||
|
- `.github/workflows/check.yml` - Comprehensive functionality tests (Ubuntu)
|
||||||
|
- `.github/workflows/check_macos.yml` - macOS compatibility tests
|
||||||
|
- `.github/workflows/update.yml` - Automated dependency updates
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
1. **Initialize a new project:**
|
||||||
|
```bash
|
||||||
|
nix flake init -t github:dwinkler1/np#rde
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Enter development environment:**
|
||||||
|
```bash
|
||||||
|
nix develop
|
||||||
|
# or with direnv
|
||||||
|
echo "use flake" > .envrc && direnv allow
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Start working:**
|
||||||
|
```bash
|
||||||
|
p-initProject # Create project structure
|
||||||
|
p # Launch Neovim
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Contributions are welcome! Please ensure:
|
||||||
|
- All templates pass CI tests
|
||||||
|
- Documentation is updated for new features
|
||||||
|
- Code follows existing patterns
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
See [LICENSE](LICENSE) file for details.
|
||||||
|
|
@ -337,6 +337,36 @@ p-updateDeps
|
||||||
# Or check overlays/r.nix for package name
|
# Or check overlays/r.nix for package name
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## CI and Testing
|
||||||
|
|
||||||
|
This template is automatically tested on every change to ensure all functionality works correctly. The CI workflow (`.github/workflows/check.yml`) runs comprehensive tests including:
|
||||||
|
|
||||||
|
### Default Configuration Tests (R enabled)
|
||||||
|
- ✅ Template builds successfully
|
||||||
|
- ✅ Flake check passes
|
||||||
|
- ✅ Development shell enters without errors
|
||||||
|
- ✅ Neovim launches in headless mode
|
||||||
|
- ✅ R console is available and runs code
|
||||||
|
- ✅ Utility commands (initProject, updateDeps) are available
|
||||||
|
- ✅ Project structure creation works correctly
|
||||||
|
|
||||||
|
### Python Configuration Tests
|
||||||
|
- ✅ Template builds with Python enabled
|
||||||
|
- ✅ Python commands (p-py, p-ipy, p-initPython) are available
|
||||||
|
- ✅ Python interpreter launches and executes code
|
||||||
|
|
||||||
|
### Julia Configuration Tests
|
||||||
|
- ✅ Template builds with Julia enabled
|
||||||
|
- ✅ Julia commands (p-jl, p-initJl) are available
|
||||||
|
- ✅ Julia REPL launches and executes code
|
||||||
|
|
||||||
|
The CI runs on:
|
||||||
|
- Every push to template files (`.nix`, `.sh`, `.lua`, `flake.lock`)
|
||||||
|
- Every pull request affecting the template
|
||||||
|
- Manual dispatch for testing
|
||||||
|
|
||||||
|
This ensures that users can confidently use the template knowing that all advertised functionality has been verified.
|
||||||
|
|
||||||
## Related Documentation
|
## Related Documentation
|
||||||
|
|
||||||
- [REFACTORING.md](REFACTORING.md) - Technical details about the modular structure
|
- [REFACTORING.md](REFACTORING.md) - Technical details about the modular structure
|
||||||
|
|
|
||||||
|
|
@ -202,10 +202,16 @@
|
||||||
# Development shell configuration
|
# Development shell configuration
|
||||||
devShells = forSystems (system: let
|
devShells = forSystems (system: let
|
||||||
pkgs = import nixpkgs {inherit system;};
|
pkgs = import nixpkgs {inherit system;};
|
||||||
|
# Language-specific packages that should be available in shell
|
||||||
|
languagePackages = with pkgs;
|
||||||
|
[]
|
||||||
|
++ (if config.enabledLanguages.r then [quarto] else [])
|
||||||
|
++ (if config.enabledLanguages.python then [uv] else [])
|
||||||
|
++ (if config.enabledLanguages.julia then [] else []);
|
||||||
in {
|
in {
|
||||||
default = pkgs.mkShell {
|
default = pkgs.mkShell {
|
||||||
name = config.defaultPackageName;
|
name = config.defaultPackageName;
|
||||||
packages = [projectConfig.${system}.default];
|
packages = [projectConfig.${system}.default] ++ languagePackages;
|
||||||
inputsFrom = [];
|
inputsFrom = [];
|
||||||
# Welcome message when entering the shell
|
# Welcome message when entering the shell
|
||||||
shellHook = import ./lib/shell-hook.nix config pkgs;
|
shellHook = import ./lib/shell-hook.nix config pkgs;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue