2025-01-16 17:32:52 +09:00
|
|
|
name: Test
|
2024-10-17 00:18:20 +09:00
|
|
|
|
|
|
|
on:
|
|
|
|
- push
|
|
|
|
- pull_request
|
|
|
|
|
|
|
|
jobs:
|
2025-01-24 00:22:44 +09:00
|
|
|
test:
|
2025-01-16 17:32:52 +09:00
|
|
|
name: Run NixOS test
|
2024-10-17 00:18:20 +09:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2025-01-16 17:32:52 +09:00
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
|
|
|
|
|
|
- name: Install Nix
|
|
|
|
uses: cachix/install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72 # v30
|
|
|
|
with:
|
|
|
|
# explicitly enable sandbox
|
|
|
|
install_options: --daemon
|
|
|
|
extra_nix_config: |
|
|
|
|
sandbox = true
|
|
|
|
system-features = nixos-test benchmark big-parallel kvm
|
|
|
|
enable_kvm: true
|
2024-12-18 22:00:08 +09:00
|
|
|
|
|
|
|
- name: Ensure environment
|
2024-12-06 03:34:13 +09:00
|
|
|
run: >-
|
2025-01-16 17:32:52 +09:00
|
|
|
apt-get update && apt-get install -y sqlite3
|
2024-12-06 03:34:13 +09:00
|
|
|
if: ${{ runner.os == 'Linux' }}
|
|
|
|
|
2025-01-16 17:32:52 +09:00
|
|
|
- name: Restore Nix store
|
|
|
|
uses: nix-community/cache-nix-action@v5
|
2024-10-17 00:18:20 +09:00
|
|
|
with:
|
2025-01-24 00:22:44 +09:00
|
|
|
primary-key: flake-check-${{ runner.os }}-${{ hashFiles('**/*.nix') }}
|
|
|
|
restore-prefixes-first-match: flake-check-${{ runner.os }}-
|
2025-01-24 00:25:57 +09:00
|
|
|
gc-max-store-size-linux: 1073741824
|
|
|
|
purge: true
|
|
|
|
purge-prefixes: flake-check-${{ runner.os }}-
|
|
|
|
purge-created: 60
|
|
|
|
purge-primary-key: never
|
2024-10-17 00:18:20 +09:00
|
|
|
|
|
|
|
- name: Run tests
|
2025-01-16 17:32:52 +09:00
|
|
|
run: |
|
|
|
|
nix --print-build-logs --experimental-features 'nix-command flakes' flake check --all-systems
|
|
|
|
nix build --out-link "result" --print-out-paths --print-build-logs .#checks.x86_64-linux.nixos-tests
|
2024-12-18 19:57:03 +09:00
|
|
|
|
2025-01-16 17:32:52 +09:00
|
|
|
- name: Upload test output
|
2024-12-18 19:57:03 +09:00
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
2025-01-16 17:32:52 +09:00
|
|
|
name: "result"
|
|
|
|
path: result/*
|
2024-12-18 19:57:03 +09:00
|
|
|
retention-days: 1
|
2025-01-24 00:22:44 +09:00
|
|
|
|
|
|
|
dist:
|
|
|
|
name: Create distribution
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
|
|
|
|
|
|
- name: Install Nix
|
|
|
|
uses: cachix/install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72 # v30
|
|
|
|
with:
|
|
|
|
# explicitly enable sandbox
|
|
|
|
install_options: --daemon
|
|
|
|
extra_nix_config: |
|
|
|
|
sandbox = true
|
|
|
|
system-features = nixos-test benchmark big-parallel kvm
|
|
|
|
enable_kvm: true
|
|
|
|
|
|
|
|
- name: Ensure environment
|
|
|
|
run: >-
|
|
|
|
apt-get update && apt-get install -y sqlite3
|
|
|
|
if: ${{ runner.os == 'Linux' }}
|
|
|
|
|
|
|
|
- name: Restore Nix store
|
|
|
|
uses: nix-community/cache-nix-action@v5
|
|
|
|
with:
|
|
|
|
primary-key: build-dist-${{ runner.os }}-${{ hashFiles('**/*.nix') }}
|
|
|
|
restore-prefixes-first-match: build-dist-${{ runner.os }}-
|
2025-01-24 00:25:57 +09:00
|
|
|
gc-max-store-size-linux: 1073741824
|
|
|
|
purge: true
|
|
|
|
purge-prefixes: build-dist-${{ runner.os }}-
|
|
|
|
purge-created: 60
|
|
|
|
purge-primary-key: never
|
2025-01-24 00:22:44 +09:00
|
|
|
|
|
|
|
- name: Build for test
|
|
|
|
id: build-test
|
|
|
|
run: >-
|
|
|
|
export FORTIFY_REV="$(git rev-parse --short HEAD)" &&
|
|
|
|
sed -i.old 's/version = /version = "0.0.0-'$FORTIFY_REV'"; # version = /' package.nix &&
|
|
|
|
nix build --print-out-paths --print-build-logs .#dist &&
|
|
|
|
mv package.nix.old package.nix &&
|
|
|
|
echo "rev=$FORTIFY_REV" >> $GITHUB_OUTPUT
|
|
|
|
|
|
|
|
- name: Upload test build
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: "fortify-${{ steps.build-test.outputs.rev }}"
|
|
|
|
path: result/*
|
|
|
|
retention-days: 1
|