nix-installer-action/.github/workflows/ci.yml

180 lines
5.7 KiB
YAML
Raw Normal View History

2023-01-13 19:07:57 +01:00
name: CI
on:
pull_request:
push:
branches: [main]
workflow_dispatch:
2023-01-13 19:07:57 +01:00
jobs:
2024-05-15 23:16:09 +02:00
tests:
runs-on: ubuntu-22.04
needs:
- check-dist-up-to-date
- install-nix
2024-05-17 16:41:26 +02:00
- install-with-non-default-source-inputs
- install-no-id-token
# NOTE(cole-h): GitHub treats "skipped" as "OK" for the purposes of required checks on branch
# protection, so we take advantage of this fact and fail if any of the dependent actions failed,
# or "skip" (which is a success for GHA's purposes) if none of them did.
if: failure()
2024-05-15 23:16:09 +02:00
steps:
- name: Dependent checks failed
run: exit 1
2024-05-15 23:16:09 +02:00
2023-10-23 20:50:08 +02:00
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
2024-05-02 15:56:42 +02:00
- 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
2024-05-15 22:39:35 +02:00
install-nix:
name: "Test: ${{ matrix.runner }}${{ matrix.determinate && ' with determinate' || '' }}"
strategy:
matrix:
runner:
- ubuntu-latest
- nscloud-ubuntu-22.04-amd64-4x16
- namespace-profile-default-arm64
# - macos-12-large # determinate-nixd is broken on macos-12
- macos-13-large
- macos-14-large
- macos-14-xlarge # arm64
determinate:
- true
- false
runs-on: ${{ matrix.runner }}
permissions:
contents: read
id-token: write
2023-01-13 19:07:57 +01:00
steps:
- uses: actions/checkout@v4
2023-01-13 19:13:23 +01:00
- name: Install Nix
2023-01-13 19:07:57 +01:00
uses: ./
with:
logger: pretty
log-directives: nix_installer=trace
backtrace: full
2024-05-22 20:41:57 +02:00
_internal-strict-mode: true
determinate: ${{ matrix.determinate }}
2023-01-13 19:07:57 +01:00
- name: echo $PATH
run: echo $PATH
- name: Render the devshell
if: success() || failure()
run: |
nix develop --command date
2023-01-13 19:07:57 +01:00
- name: Test `nix` with `$GITHUB_PATH`
if: success() || failure()
run: |
2023-05-25 17:54:25 +02:00
nix run nixpkgs#hello
nix profile install nixpkgs#hello
hello
2023-01-13 19:07:57 +01:00
nix store gc
2023-05-25 17:54:25 +02:00
nix run nixpkgs#hello
2023-01-13 19:07:57 +01:00
- 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: if (zsh --help > /dev/null); then zsh --login --interactive -c "nix-instantiate -E 'builtins.currentTime' --eval"; fi
2023-01-13 19:07:57 +01:00
if: success() || failure()
2023-01-13 21:09:36 +01:00
- name: Install Nix again (noop)
uses: ./
with:
logger: pretty
log-directives: nix_installer=trace
backtrace: full
2024-05-22 20:41:57 +02:00
_internal-strict-mode: true
determinate: ${{ matrix.determinate }}
2023-01-13 21:18:14 +01:00
- name: Test `nix` with `$GITHUB_PATH`
if: success() || failure()
run: |
2023-05-25 17:54:25 +02:00
nix run nixpkgs#hello
nix profile install nixpkgs#hello
hello
2023-01-13 21:18:14 +01:00
nix store gc
2023-05-25 17:54:25 +02:00
nix run nixpkgs#hello
2023-01-13 21:09:36 +01:00
- name: Reinstall Nix
uses: ./
with:
logger: pretty
log-directives: nix_installer=trace
backtrace: full
2024-05-02 18:54:44 +02:00
reinstall: true
extra-conf: |
use-sqlite-wal = true
2024-05-22 20:41:57 +02:00
_internal-strict-mode: true
determinate: ${{ matrix.determinate }}
2023-01-13 21:18:14 +01:00
- name: Test `nix` with `$GITHUB_PATH`
if: success() || failure()
run: |
2023-05-25 17:54:25 +02:00
nix run nixpkgs#hello
nix profile install nixpkgs#hello
hello
2023-01-13 21:18:14 +01:00
nix store gc
2023-05-25 17:54:25 +02:00
nix run nixpkgs#hello
- name: Verify the generated nix.conf
run: |
nix config show
cat -n /etc/nix/nix.conf
nix config show | grep -E "^trusted-users = .*$USER"
nix config show | grep -E "^use-sqlite-wal = true"
2024-05-17 02:07:06 +02:00
install-with-non-default-source-inputs:
name: Install Nix using non-default source-${{ matrix.inputs.key }}
runs-on: ubuntu-22.04
strategy:
matrix:
inputs:
# https://github.com/DeterminateSystems/nix-installer/blob/v0.18.0
- key: url
value: https://github.com/DeterminateSystems/nix-installer/releases/download/v0.18.0/nix-installer-x86_64-linux
nix-version: "2.21.2"
# https://github.com/DeterminateSystems/nix-installer/tree/7011c077ec491da410fbc39f68676b0908b9ce7e
- key: revision
value: 7011c077ec491da410fbc39f68676b0908b9ce7e
nix-version: "2.19.2"
2024-05-17 02:02:46 +02:00
steps:
- uses: actions/checkout@v4
- name: Install with alternative source-${{ matrix.inputs.key }}
2024-05-17 02:04:04 +02:00
uses: ./
with:
source-${{ matrix.inputs.key }}: ${{ matrix.inputs.value }}
2024-05-22 20:41:57 +02:00
_internal-strict-mode: true
- name: Ensure that the expected Nix version ${{ matrix.inputs.nix-version }} is installed via alternative source-${{ matrix.inputs.key }}
run: .github/verify-version.sh ${{ matrix.inputs.nix-version }}
install-no-id-token:
name: Install Nix without an ID token
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: ./
with:
_internal-strict-mode: true
determinate: true