aboutsummaryrefslogtreecommitdiffhomepage
path: root/.gitea/workflows/test.yml
blob: 970759d16d3cada08ec8d3afcc4c65247a44d3db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Test

on:
  - push
  - pull_request

jobs:
  test:
    name: Run NixOS test
    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: flake-check-${{ runner.os }}-${{ hashFiles('**/*.nix') }}
          restore-prefixes-first-match: flake-check-${{ runner.os }}-
          gc-max-store-size-linux: 1073741824
          purge: true
          purge-prefixes: flake-check-${{ runner.os }}-
          purge-created: 60
          purge-primary-key: never

      - name: Run tests
        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

      - name: Upload test output
        uses: actions/upload-artifact@v3
        with:
          name: "result"
          path: result/*
          retention-days: 1

  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 }}-
          gc-max-store-size-linux: 1073741824
          purge: true
          purge-prefixes: build-dist-${{ runner.os }}-
          purge-created: 60
          purge-primary-key: never

      - 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