Debian Codegraph @

others/mbedtls/tf-psa-crypto/drivers/pqcp/mldsa-native/.github/workflows/nix.yml

raw symbols SCIP
1 # Copyright (c) The mlkem-native project authors
2 # Copyright (c) The mldsa-native project authors
3 # SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4
5 name: Nix
6 permissions:
7 contents: read
8 on:
9 workflow_call:
10 workflow_dispatch:
11
12 concurrency:
13 group: ${{ github.workflow }}-${{ github.ref }}
14 cancel-in-progress: true
15
16 jobs:
17 check_modified_files:
18 runs-on: ubuntu-latest
19 outputs:
20 run_needed: ${{ steps.check_run.outputs.run_needed }}
21 steps:
22 - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
23 if: github.event_name != 'workflow_dispatch'
24 with:
25 fetch-depth: 0
26 - name: Get changed files
27 if: github.event_name != 'workflow_dispatch'
28 id: changed-files
29 uses: tj-actions/changed-files@e0021407031f5be11a464abee9a0776171c79891 # v47.0.1
30 - name: Check if dependencies changed
31 id: check_run
32 shell: bash
33 run: |
34 if [[ ${{ (github.event_name == 'workflow_dispatch' && '1') || '0' }} == "1" ]]; then
35 run_needed=1
36 else
37 run_needed=0
38 changed_files="${{ steps.changed-files.outputs.all_changed_files }}"
39 dependencies="flake.lock flake.nix nix/"
40 for changed in $changed_files; do
41 for needs in $dependencies; do
42 if [[ "$changed" == "$needs"* ]]; then
43 run_needed=1
44 fi
45 done
46 done
47 fi
48 echo "run_needed=${run_needed}" >> $GITHUB_OUTPUT
49
50 build_nix_cache:
51 needs: [ check_modified_files ]
52 if: ${{ needs.check_modified_files.outputs.run_needed == '1' && github.ref == 'refs/heads/main' }}
53 permissions:
54 actions: 'write'
55 contents: 'read'
56 strategy:
57 fail-fast: false
58 matrix:
59 runner: [ ubuntu-24.04, ubuntu-24.04-arm, macos-latest ]
60 name: build nix cache (${{ matrix.runner }})
61 runs-on: ${{ matrix.runner }}
62 steps:
63 - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
64 - uses: ./.github/actions/setup-nix
65 with:
66 cache: true
67 verbose: true
68 save_cache: true
69 devShell: ci
70 gh_token: ${{ secrets.GITHUB_TOKEN }}
71 script: |
72 # We only run cross-compilation checks for x86 on macos-latest,
73 # so restrict caching to the corresponding cross shell.
74 if [[ ${{ runner.os }} == 'macOS' ]]; then
75 nix develop .#ci-cross-x86_64 --profile tmp-cross
76 else
77 nix develop .#ci-cross --profile tmp-cross
78 # GH ubuntu-24.04 image tend to run outof space
79 if [[ ${{ matrix.runner }} == 'ubuntu-24.04' ]]; then
80 nix-collect-garbage
81 fi
82 fi
83 nix develop --profile tmp
84 nix-collect-garbage
85 develop_environment:
86 needs: [ check_modified_files ]
87 if: ${{ needs.check_modified_files.outputs.run_needed == '1' }}
88 strategy:
89 fail-fast: false
90 matrix:
91 target:
92 # nixpkgs requires 2.18 since August 2025, see
93 # https://github.com/NixOS/nixpkgs/pull/428076
94 # TODO: Re-enable tests on Ubuntu 22 once nix has been updated to >= 2.18
95 # - runner: ubuntu-22.04
96 # container:
97 # install: 'apt'
98 - runner: ubuntu-latest
99 container: nixos/nix:2.18.0
100 install: 'native'
101 - runner: ubuntu-24.04
102 container:
103 install: 'apt'
104 - runner: macos-latest
105 container:
106 install: 'installer'
107 - runner: ubuntu-22.04
108 container:
109 install: 'installer'
110 - runner: ubuntu-24.04
111 container:
112 install: 'installer'
113 name: nix setup test (${{ matrix.target.container != '' && matrix.target.container || matrix.target.runner }}, nix via ${{ matrix.target.install }})
114 runs-on: ${{ matrix.target.runner }}
115 container:
116 ${{ matrix.target.container }}
117 steps:
118 - name: Install git
119 shell: bash
120 run: |
121 if ! which git 2>&1 >/dev/null; then
122 ${{ matrix.target.container == '' && 'sudo' || '' }} apt update
123 ${{ matrix.target.container == '' && 'sudo' || '' }} apt install git -y
124 fi
125 - name: Manual checkout
126 shell: bash
127 run: |
128 git init
129 git config --global --add safe.directory $GITHUB_WORKSPACE
130 git remote add origin $GITHUB_SERVER_URL/$GITHUB_REPOSITORY
131 git fetch origin --depth 1 $GITHUB_SHA
132 git checkout FETCH_HEAD
133 - uses: ./.github/actions/setup-nix
134 if: ${{ matrix.target.container == '' }}
135 with:
136 gh_token: ${{ secrets.GITHUB_TOKEN }}
137 devShell: default
138 verbose: true
139 cache: true
140 install: ${{ matrix.target.install }}
141 - name: nix develop (in container)
142 if: ${{ matrix.target.container != '' }}
143 run: |
144 nix develop --experimental-features "nix-command flakes" --access-tokens "github.com=${{ secrets.GITHUB_TOKEN }}"