Skip to content

Commit

Permalink
[nix] move test to derivation inside gcd vcs
Browse files Browse the repository at this point in the history
For all chipsalliance CI runner, RestrictNamespaces and RestrictSUIDSGID
properties are set for best safety ensurance. So running VCS directly
inside the GitHub Runner is not possible.

This commit give an example of how to get out of the boundary of the
GitHub Action by integrating all simulation into derivation.

Signed-off-by: Avimitin <[email protected]>
  • Loading branch information
Avimitin committed Sep 9, 2024
1 parent 2b9ed4f commit 5bfc928
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}
- name: "Run VCS"
run: |
nix run '.#gcd.vcs' --impure
nix build '.#gcd.vcs.tests' --impure
run-verilator:
name: "Run Verilator"
Expand Down
22 changes: 18 additions & 4 deletions templates/chisel/nix/gcd/vcs.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2024 Jiuyang Liu <[email protected]>

{ lib, bash, stdenv, rtl, dpi-lib, vcs-fhs-env }:
let binName = "gcd-vcs-simulator";
in stdenv.mkDerivation {
{ lib
, bash
, stdenv
, rtl
, dpi-lib
, vcs-fhs-env
, runCommand
}:

let
binName = "gcd-vcs-simulator";
in
stdenv.mkDerivation (finalAttr: {
name = "vcs";

# Add "sandbox = relaxed" into /etc/nix/nix.conf, and run `systemctl restart nix-daemon`
Expand Down Expand Up @@ -46,6 +56,10 @@ in stdenv.mkDerivation {
inherit vcs-fhs-env;
inherit dpi-lib;
inherit rtl;

tests.run-sim = runCommand "run-gcd-vcs-simulator" { __noChroot = true; } ''
${finalAttr.finalPackage}/bin/${binName}
'';
};

shellHook = ''
Expand All @@ -71,4 +85,4 @@ in stdenv.mkDerivation {
runHook postInstall
'';
}
})

0 comments on commit 5bfc928

Please sign in to comment.