Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nix installer cache issue #138

Merged
merged 4 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions .github/actions/bench/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ inputs:
runs:
using: composite
steps:
- name: Setup nix
if: ${{ inputs.nix-shell != '' }}
uses: ./.github/actions/setup-nix
- uses: ./.github/actions/setup-shell
with:
devShell: ${{ inputs.nix-shell }}
nix-shell: ${{ inputs.nix-shell }}
custom_shell: ${{ inputs.custom_shell }}
script: |
ARCH=$(uname -m)
cat >> $GITHUB_STEP_SUMMARY <<-EOF
Expand All @@ -59,14 +58,6 @@ runs:
## CPU Info
$(cat /proc/cpuinfo)
EOF
- name: Set shell
shell: bash
run: |
if [[ ${{ inputs.nix-shell }} != '' ]]; then
echo SHELL="nix develop .#${{ inputs.nix-shell }} -c bash -e {0}" >> $GITHUB_ENV
else
echo SHELL="${{ inputs.custom_shell }}" >> $GITHUB_ENV
fi
- name: Run benchmark
shell: ${{ env.SHELL }}
run: |
Expand Down
15 changes: 3 additions & 12 deletions .github/actions/cbmc/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ runs:
using: composite
steps:
- uses: actions/checkout@v4
- name: Setup nix
if: ${{ inputs.nix-shell != '' }}
uses: ./.github/actions/setup-nix
- uses: ./.github/actions/setup-shell
with:
devShell: ${{ inputs.nix-shell }}
nix-shell: ${{ inputs.nix-shell }}
custom_shell: ${{ inputs.custom_shell }}
script: |
cat >> $GITHUB_STEP_SUMMARY << EOF
## Setup
Expand All @@ -33,14 +32,6 @@ runs:
- $(${{ inputs.cross_prefix }}gcc --version | grep -m1 "")
- $(bash --version | grep -m1 "")
EOF
- name: Set shell
shell: bash
run: |
if [[ ${{ inputs.nix-shell }} != '' ]]; then
echo SHELL="nix develop .#${{ inputs.nix-shell }} -c bash -e {0}" >> $GITHUB_ENV
else
echo SHELL="${{ inputs.custom_shell }}" >> $GITHUB_ENV
fi
- name: Run CBMC proofs
shell: ${{ env.SHELL }}
run: |
Expand Down
14 changes: 3 additions & 11 deletions .github/actions/functest/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ runs:
using: composite
steps:
- name: Setup nix
uses: ./.github/actions/setup-nix
if: ${{ inputs.nix-shell != '' }}
uses: ./.github/actions/setup-shell
with:
devShell: ${{ inputs.nix-shell }}
nix-shell: ${{ inputs.nix-shell }}
custom_shell: ${{ inputs.custom_shell }}
script: |
ARCH=$(uname -m)
cat >> $GITHUB_STEP_SUMMARY <<-EOF
Expand All @@ -37,14 +37,6 @@ runs:
- $(${{ inputs.cross-prefix }}gcc --version | grep -m1 "")
- $(bash --version | grep -m1 "")
EOF
- name: Set shell
shell: bash
run: |
if [[ ${{ inputs.nix-shell }} != '' ]]; then
echo SHELL="nix develop .#${{ inputs.nix-shell }} -c bash -e {0}" >> $GITHUB_ENV
else
echo SHELL="${{ inputs.custom_shell }}" >> $GITHUB_ENV
fi
- name: Run functional tests
id: func_test
shell: ${{ env.SHELL }}
Expand Down
15 changes: 3 additions & 12 deletions .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ inputs:
runs:
using: composite
steps:
- name: Setup nix
if: ${{ inputs.nix-shell != '' }}
uses: ./.github/actions/setup-nix
- uses: ./.github/actions/setup-shell
with:
devShell: ${{ inputs.nix-shell }}
nix-shell: ${{ inputs.nix-shell }}
custom_shell: ${{ inputs.custom_shell }}
script: |
cat >> $GITHUB_STEP_SUMMARY << EOF
## Setup
Expand All @@ -31,14 +30,6 @@ runs:
- $(${{ matrix.target.cross-prefix }}gcc --version | grep -m1 "")
- $(bash --version | grep -m1 "")
EOF
- name: Set shell
shell: bash
run: |
if [[ ${{ inputs.nix-shell }} != '' ]]; then
echo SHELL="nix develop .#${{ inputs.nix-shell }} -c bash -e {0}" >> $GITHUB_ENV
else
echo SHELL="${{ inputs.custom_shell }}" >> $GITHUB_ENV
fi
- name: Run linter
shell: ${{ env.SHELL }}
run: |
Expand Down
37 changes: 31 additions & 6 deletions .github/actions/setup-nix/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,39 @@ inputs:
runs:
using: composite
steps:
- uses: DeterminateSystems/nix-installer-action@v14
- name: Pre-check nix
id: pre-check-nix
continue-on-error: true
shell: bash -leo pipefail {0}
run: |
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
nix --version
nix config show | grep -E "^trusted-users = .*$USER"
nix config show | grep -E "^experimental-features = .*flakes"
nix config show | grep -E "^experimental-features = .*nix-command"

echo SHELL="$(which nix) develop --quiet .#${{ inputs.devShell }} -c bash -e {0}" >> $GITHUB_ENV
- name: Install nix
if: steps.pre-check-nix.outcome == 'failure'
shell: bash -leo pipefail {0}
run: |
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm \
--extra-conf "trusted-users = root ${USER:-}" \
--extra-conf "experimental-features = nix-command flakes"

. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
echo SHELL="$(which nix) develop --quiet .#${{ inputs.devShell }} -c bash -e {0}" >> $GITHUB_ENV
- name: Post-check nix
continue-on-error: true
shell: bash -leo pipefail {0}
run: |
nix config check
- uses: DeterminateSystems/magic-nix-cache-action@v8
continue-on-error: true
- name: Prepare nix dev shell
shell: nix develop --quiet .#${{ inputs.devShell }} -c bash -e {0}
shell: ${{ env.SHELL }}
run: |
- name: Dependency check
shell: nix develop --quiet .#${{ inputs.devShell }} -c bash -e {0}
shell: ${{ env.SHELL }}
if: inputs.script != ''
env:
INPUT_SCRIPT: ${{ inputs.script }}
run: eval "$INPUT_SCRIPT"
run: eval ${{ inputs.script }}
37 changes: 37 additions & 0 deletions .github/actions/setup-shell/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# SPDX-License-Identifier: Apache-2.0

name: Set Shell
description: Setup nix or custom shell for workflows

inputs:
use-nix:
description: Indicate whether to use nix or not
default: 'true'
nix-shell:
description: Run in the specified Nix environment if exists
default: 'ci'
custom_shell:
description: The shell to use. Only relevant if no nix-shell specified
default: 'bash'
script:
description: The script to be run in the nix shell
required: false

runs:
using: composite
steps:
- name: Setup nix
uses: ./.github/actions/setup-nix
if: ${{ inputs.use-nix == 'true' && env.SHELL == '' }}
with:
devShell: ${{ inputs.nix-shell }}
script: ${{ inputs.script }}
- name: Set custom shell
shell: bash
if: ${{ inputs.use-nix != 'true' && env.SHELL == '' }}
run: |
echo SHELL="${{ inputs.custom_shell }}" >> $GITHUB_ENV

if [[ "${{ inputs.script }}" != '' ]]; then
eval ${{ inputs.script }}
fi
Loading