mirror of
https://github.com/DeterminateSystems/nix-installer-action.git
synced 2024-12-23 21:42:11 +01:00
237 lines
7 KiB
YAML
237 lines
7 KiB
YAML
name: CI
|
|
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
tests:
|
|
runs-on: ubuntu-22.04
|
|
needs:
|
|
- check-dist-up-to-date
|
|
- install-nix-linux
|
|
- install-nix-macos
|
|
steps:
|
|
- run: true
|
|
|
|
check-dist-up-to-date:
|
|
name: Check the dist/ folder is up to date
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: DeterminateSystems/nix-installer-action@main
|
|
- uses: DeterminateSystems/magic-nix-cache-action@main
|
|
- name: pnpm install
|
|
run: nix develop --command pnpm install
|
|
- name: prettier format
|
|
run: nix develop --command pnpm run check-fmt
|
|
- name: ESLint
|
|
run: nix develop --command pnpm run lint
|
|
- name: tsup build
|
|
run: nix develop --command pnpm run build
|
|
- name: ncc package
|
|
run: nix develop --command pnpm run package
|
|
- name: Git status
|
|
run: git status --porcelain=v1
|
|
- name: Ensure no staged changes
|
|
run: git diff --exit-code
|
|
|
|
install-nix-linux:
|
|
name: Run test suite for Linux systems
|
|
strategy:
|
|
matrix:
|
|
runner:
|
|
- ubuntu-latest
|
|
- nscloud-ubuntu-22.04-amd64-4x16
|
|
- namespace-profile-default-arm64
|
|
runs-on: ${{ matrix.runner }}
|
|
permissions:
|
|
contents: read
|
|
id-token: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install Nix
|
|
uses: ./
|
|
with:
|
|
logger: pretty
|
|
log-directives: nix_installer=trace
|
|
backtrace: full
|
|
- name: echo $PATH
|
|
run: echo $PATH
|
|
|
|
- name: Render the devshell
|
|
if: success() || failure()
|
|
run: |
|
|
nix develop --command date
|
|
|
|
- name: Test `nix` with `$GITHUB_PATH`
|
|
if: success() || failure()
|
|
run: |
|
|
nix run nixpkgs#hello
|
|
nix profile install nixpkgs#hello
|
|
hello
|
|
nix store gc
|
|
nix run nixpkgs#hello
|
|
|
|
- name: Test bash
|
|
run: nix-instantiate -E 'builtins.currentTime' --eval
|
|
if: success() || failure()
|
|
shell: bash --login {0}
|
|
- name: Test sh
|
|
run: nix-instantiate -E 'builtins.currentTime' --eval
|
|
if: success() || failure()
|
|
shell: sh -l {0}
|
|
- name: Install Nix again (noop)
|
|
uses: ./
|
|
with:
|
|
logger: pretty
|
|
log-directives: nix_installer=trace
|
|
backtrace: full
|
|
- name: Test `nix` with `$GITHUB_PATH`
|
|
if: success() || failure()
|
|
run: |
|
|
nix run nixpkgs#hello
|
|
nix profile install nixpkgs#hello
|
|
hello
|
|
nix store gc
|
|
nix run nixpkgs#hello
|
|
- name: Reinstall Nix
|
|
uses: ./
|
|
with:
|
|
logger: pretty
|
|
log-directives: nix_installer=trace
|
|
backtrace: full
|
|
reinstall: true
|
|
extra-conf: |
|
|
use-sqlite-wal = true
|
|
- name: Test `nix` with `$GITHUB_PATH`
|
|
if: success() || failure()
|
|
run: |
|
|
nix run nixpkgs#hello
|
|
nix profile install nixpkgs#hello
|
|
hello
|
|
nix store gc
|
|
nix run nixpkgs#hello
|
|
- name: Verify the generated nix.conf
|
|
run: |
|
|
cat -n /etc/nix/nix.conf
|
|
grep -E "^trusted-users = .*$USER" /etc/nix/nix.conf
|
|
grep -E "^use-sqlite-wal = true" /etc/nix/nix.conf
|
|
- name: Breakpoint if tests failed
|
|
if: failure()
|
|
uses: namespacelabs/breakpoint-action@v0
|
|
with:
|
|
duration: 5m
|
|
authorized-users: grahamc
|
|
|
|
install-nix-macos:
|
|
name: Run test suite for macOS systems
|
|
strategy:
|
|
matrix:
|
|
runner:
|
|
# x86_64-darwin
|
|
- macos-12
|
|
# aarch64-darwin
|
|
- macos-latest-xlarge
|
|
runs-on: ${{ matrix.runner }}
|
|
permissions:
|
|
contents: read
|
|
id-token: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install Nix
|
|
uses: ./
|
|
with:
|
|
logger: pretty
|
|
log-directives: nix_installer=trace
|
|
backtrace: full
|
|
- name: echo $PATH
|
|
run: echo $PATH
|
|
- name: Test `nix` with `$GITHUB_PATH`
|
|
if: success() || failure()
|
|
run: |
|
|
nix run nixpkgs#hello
|
|
nix profile install nixpkgs#hello
|
|
hello
|
|
nix store gc
|
|
nix run nixpkgs#hello
|
|
- name: Test bash
|
|
run: nix-instantiate -E 'builtins.currentTime' --eval
|
|
if: success() || failure()
|
|
shell: bash --login {0}
|
|
- name: Test sh
|
|
run: nix-instantiate -E 'builtins.currentTime' --eval
|
|
if: success() || failure()
|
|
shell: sh -l {0}
|
|
- name: Test zsh
|
|
run: nix-instantiate -E 'builtins.currentTime' --eval
|
|
if: success() || failure()
|
|
shell: zsh --login --interactive {0}
|
|
- name: Install Nix again (noop)
|
|
uses: ./
|
|
with:
|
|
logger: pretty
|
|
log-directives: nix_installer=trace
|
|
backtrace: full
|
|
- name: Test `nix` with `$GITHUB_PATH`
|
|
if: success() || failure()
|
|
run: |
|
|
nix run nixpkgs#hello
|
|
nix profile install nixpkgs#hello
|
|
hello
|
|
nix store gc
|
|
nix run nixpkgs#hello
|
|
- name: Reinstall Nix
|
|
uses: ./
|
|
with:
|
|
logger: pretty
|
|
log-directives: nix_installer=trace
|
|
backtrace: full
|
|
reinstall: true
|
|
extra-conf: |
|
|
use-sqlite-wal = true
|
|
- name: Test `nix` with `$GITHUB_PATH`
|
|
if: success() || failure()
|
|
run: |
|
|
nix run nixpkgs#hello
|
|
nix profile install nixpkgs#hello
|
|
hello
|
|
nix store gc
|
|
nix run nixpkgs#hello
|
|
- name: Verify the generated nix.conf
|
|
run: |
|
|
cat /etc/nix/nix.conf
|
|
grep -E "^trusted-users = .*$USER" /etc/nix/nix.conf
|
|
grep -E "^use-sqlite-wal = true" /etc/nix/nix.conf
|
|
- name: Breakpoint if tests failed
|
|
if: failure()
|
|
uses: namespacelabs/breakpoint-action@v0
|
|
with:
|
|
duration: 5m
|
|
authorized-users: grahamc
|
|
|
|
install-with-non-default-source-url:
|
|
name: Install Nix using non-default source-url inputs
|
|
runs-on: ubuntu-22.04
|
|
strategy:
|
|
matrix:
|
|
versions:
|
|
- { nix-installer: "0.12.0", nix: "2.20.0" }
|
|
- { nix-installer: "0.14.0", nix: "2.20.0" }
|
|
- { nix-installer: "0.18.0", nix: "2.20.0" }
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: DeterminateSystems/nix-installer-action@main
|
|
with:
|
|
source-url: https://github.com/DeterminateSystems/nix-installer/releases/download/v${{ matrix.versions.nix-installer }}/nix-installer-x86_64-linux
|
|
- name: Compare Nix version with expected version
|
|
run: |
|
|
NIX_VERSION_OUTPUT=$(nix --version)
|
|
NIX_VERSION=$(echo "${NIX_VERSION}" | awk '{print $NF}')
|
|
EXPECTED_OUTPUT="nix (Nix) ${{ matrix.versions.nix }}"
|
|
if [ "${NIX_VERSION_OUTPUT}" != "${EXPECTED_OUTPUT}" ]; then
|
|
echo "Nix version ${NIX_VERSION} didn't match expected version ${{ matrix.versions.nix }}"
|
|
exit 1
|
|
fi
|