From 85466e66d0f4e08bd45bb9e843ee6036621dec38 Mon Sep 17 00:00:00 2001 From: "Thing-han, Lim" <15379156+potsrevennil@users.noreply.github.com> Date: Mon, 22 Jul 2024 11:51:16 +0800 Subject: [PATCH 1/3] ci: add nix setup composite action Signed-off-by: Thing-han, Lim <15379156+potsrevennil@users.noreply.github.com> --- .github/actions/setup-nix/action.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/actions/setup-nix/action.yml diff --git a/.github/actions/setup-nix/action.yml b/.github/actions/setup-nix/action.yml new file mode 100644 index 00000000..983e283c --- /dev/null +++ b/.github/actions/setup-nix/action.yml @@ -0,0 +1,28 @@ +# SPDX-License-Identifier: Apache-2.0 + +name: Setup nix +description: Setup nix + +inputs: + script: + description: The script to be run in the nix shell + required: false + devShell: + description: The name of the devShell + required: true + default: 'default' + +runs: + using: composite + steps: + - uses: DeterminateSystems/nix-installer-action@v12 + - uses: DeterminateSystems/magic-nix-cache-action@main + - name: Prepare nix dev shell + shell: nix develop .#${{ inputs.devShell }} -c bash -e {0} + run: | + - name: Dependency check + shell: nix develop .#${{ inputs.devShell }} -c bash -e {0} + if: inputs.script != '' + env: + INPUT_SCRIPT: ${{ inputs.script }} + run: eval "$INPUT_SCRIPT" From fe6bc2ed6d2ad59ffff85a9838b234ec29160cf6 Mon Sep 17 00:00:00 2001 From: "Thing-han, Lim" <15379156+potsrevennil@users.noreply.github.com> Date: Mon, 22 Jul 2024 14:09:37 +0800 Subject: [PATCH 2/3] ci: refactor with the private nix action Signed-off-by: Thing-han, Lim <15379156+potsrevennil@users.noreply.github.com> --- .github/workflows/amd64-linux-main-proof.yml | 21 ++--- .github/workflows/amd64-linux-main.yml | 81 ++++++++------------ 2 files changed, 43 insertions(+), 59 deletions(-) diff --git a/.github/workflows/amd64-linux-main-proof.yml b/.github/workflows/amd64-linux-main-proof.yml index 1a423860..50e7b87a 100644 --- a/.github/workflows/amd64-linux-main-proof.yml +++ b/.github/workflows/amd64-linux-main-proof.yml @@ -7,6 +7,10 @@ on: - main pull_request: +defaults: + run: + shell: nix develop -c bash -e {0} + jobs: @@ -17,18 +21,15 @@ jobs: - name: checkout uses: actions/checkout@v4 - - uses: DeterminateSystems/magic-nix-cache-action@v4 + - name: Setup nix + uses: ./.github/actions/setup-nix - name: extract and check - uses: workflow/nix-shell-action@v3.3.0 - with: - flakes: . - flakes-from-devshell: true - script: | - # extract and check - make -j$JOBS -C proof/ CI=1 default - # dist - ./scripts/ci/releaser/jdist-proof + run: | + # extract and check + make -j$JOBS -C proof/ CI=1 default + # dist + ./scripts/ci/releaser/jdist-proof - name: print logs run: make -C proof/ CI=1 reporter diff --git a/.github/workflows/amd64-linux-main.yml b/.github/workflows/amd64-linux-main.yml index e16bcb7f..c5ca2d67 100644 --- a/.github/workflows/amd64-linux-main.yml +++ b/.github/workflows/amd64-linux-main.yml @@ -7,6 +7,10 @@ on: - main pull_request: +defaults: + run: + shell: nix develop -c bash -e {0} + jobs: @@ -17,15 +21,10 @@ jobs: - name: checkout uses: actions/checkout@v4 - - uses: DeterminateSystems/magic-nix-cache-action@v4 - + - name: Setup nix + uses: ./.github/actions/setup-nix - name: compile - uses: workflow/nix-shell-action@v3.3.0 - with: - flakes: . - flakes-from-devshell: true - script: make -j$JOBS -C src/ CI=1 default - + run: make -j$JOBS -C src/ CI=1 default - name: print logs run: make -C src/ CI=1 reporter - name: return error if there are any errors @@ -47,15 +46,11 @@ jobs: - name: checkout uses: actions/checkout@v4 - - uses: DeterminateSystems/magic-nix-cache-action@v4 + - name: Setup nix + uses: ./.github/actions/setup-nix - name: compile and run - uses: workflow/nix-shell-action@v3.3.0 - with: - flakes: . - flakes-from-devshell: true - script: make -j$JOBS -C test/ CI=1 default - + run: make -j$JOBS -C test/ CI=1 default - name: print logs run: make -C test/ CI=1 reporter - name: return error if there are any errors @@ -77,14 +72,11 @@ jobs: - name: checkout uses: actions/checkout@v4 - - uses: DeterminateSystems/magic-nix-cache-action@v4 + - name: Setup nix + uses: ./.github/actions/setup-nix - name: compile - uses: workflow/nix-shell-action@v3.3.0 - with: - flakes: . - flakes-from-devshell: true - script: make -j$JOBS -C src/ CI=1 default + run: make -j$JOBS -C src/ CI=1 default - name: run run: make -j$JOBS -C bench/ CI=1 DEFINE='-DTIMINGS=10' run @@ -111,14 +103,11 @@ jobs: - name: checkout uses: actions/checkout@v4 - - uses: DeterminateSystems/magic-nix-cache-action@v4 + - name: Setup nix + uses: ./.github/actions/setup-nix - name: compile - uses: workflow/nix-shell-action@v3.3.0 - with: - flakes: . - flakes-from-devshell: true - script: make -j$JOBS -C src/ CI=1 default + run: make -j$JOBS -C src/ CI=1 default - name: run run: make -j$JOBS -C bench/ CI=1 run DEFINE='-DTIMINGS=10 -DRUNS=2 -DST_ON' RANDINC='../test/common/' RANDLIB='../test/common/notrandombytes.c'; @@ -145,18 +134,15 @@ jobs: - name: checkout uses: actions/checkout@v4 - - uses: DeterminateSystems/magic-nix-cache-action@v4 + - name: Setup nix + uses: ./.github/actions/setup-nix - name: extract and check - uses: workflow/nix-shell-action@v3.3.0 - with: - flakes: . - flakes-from-devshell: true - script: | - # extract and check - make -j$JOBS -C proof/ CI=1 check-extracted - # dist - ./scripts/ci/releaser/jdist-proof + run: | + # extract and check + make -j$JOBS -C proof/ CI=1 check-extracted + # dist + ./scripts/ci/releaser/jdist-proof - name: print logs run: make -C proof/ CI=1 reporter @@ -187,20 +173,17 @@ jobs: - name: checkout uses: actions/checkout@v4 - - uses: DeterminateSystems/magic-nix-cache-action@v4 + - name: Setup nix + uses: ./.github/actions/setup-nix - name: dist amd64 - uses: workflow/nix-shell-action@v3.3.0 - with: - flakes: . - flakes-from-devshell: true - script: | - # compile amd64 - make -j$JOBS -C src/ CI=1 default - # dist amd64 - ./scripts/ci/releaser/jdist-src-v1 amd64 - # check dist amd64 - ./scripts/ci/releaser/jdist-src-test-v1 amd64 + run: | + # compile amd64 + make -j$JOBS -C src/ CI=1 default + # dist amd64 + ./scripts/ci/releaser/jdist-src-v1 amd64 + # check dist amd64 + ./scripts/ci/releaser/jdist-src-test-v1 amd64 - name: libjade-dist-src-amd64.tar.gz - contains assembly, Jasmin, and how-to-use code if: always() From 7624713ac3fd55f25130205fd73a0088e36cfb82 Mon Sep 17 00:00:00 2001 From: "Thing-han, Lim" <15379156+potsrevennil@users.noreply.github.com> Date: Mon, 22 Jul 2024 14:32:31 +0800 Subject: [PATCH 3/3] ci: make init system of nix installer configurable to support docker Signed-off-by: Thing-han, Lim <15379156+potsrevennil@users.noreply.github.com> --- .github/actions/setup-nix/action.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/actions/setup-nix/action.yml b/.github/actions/setup-nix/action.yml index 983e283c..388b86e7 100644 --- a/.github/actions/setup-nix/action.yml +++ b/.github/actions/setup-nix/action.yml @@ -11,11 +11,17 @@ inputs: description: The name of the devShell required: true default: 'default' + init: + description: The init system to configure ('systemd' or 'none') + required: false + default: 'none' runs: using: composite steps: - uses: DeterminateSystems/nix-installer-action@v12 + with: + init: ${{ inputs.init }} - uses: DeterminateSystems/magic-nix-cache-action@main - name: Prepare nix dev shell shell: nix develop .#${{ inputs.devShell }} -c bash -e {0}