Skip to content

nix 2.25

nix 2.25 #272

name: Nix actions
on:
pull_request:
push:
branches:
- main
- staging
- release-*
jobs:
nix-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- id: set-matrix
name: Generate Nix Matrix
run: |
set -Eeu
echo "matrix=$(nix eval --json '.#githubActions.matrix')" >> "$GITHUB_OUTPUT"
nix-build:
needs: nix-matrix
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
steps:
- name: Figure out if we are running in a Namespace.so runner or not
shell: bash
run: |
if [ -n "$NSC_CONTAINER_REGISTRY" ]; then
echo "NAMESPACE_RUNNER=1" >> $GITHUB_ENV
fi
- name: namespacelabs/nscloud-cache-action cannot mkdir /nix so we do it manually
if: env.NAMESPACE_RUNNER
shell: bash
run: |
sudo mkdir /nix
sudo chown $USER /nix
- uses: namespacelabs/nscloud-cache-action@v1
if: env.NAMESPACE_RUNNER
with:
path: /nix
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- run: nix build -L ".#${{ matrix.attr }}"
tests:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
# Nix Flakes doesn't work on shallow clones
fetch-depth: 0
- uses: cachix/install-nix-action@v30
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
extra_nix_config: |
accept-flake-config = true
- name: Build
run: nix develop -c bash -c 'meson setup -Db_sanitize=address,undefined build && ninja -C build'
- name: Run tests
run: nix develop -c pytest ./tests -m 'not infiniterecursion'
# address sanitizer will lead to out-of-memory in the infinite recursion case
- name: Build without sanitizer
run: nix develop -c bash -c 'rm -rf build && meson setup build && ninja -C build'
- name: Run tests
run: nix develop -c pytest ./tests -m 'infiniterecursion'
collect:
runs-on: ubuntu-latest
needs:
- nix-build
- tests
steps:
- run: "true"