Skip to content

Commit 5bfc928

Browse files
committed
[nix] move test to derivation inside gcd vcs
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]>
1 parent 2b9ed4f commit 5bfc928

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
ref: ${{ github.event.pull_request.head.sha }}
5757
- name: "Run VCS"
5858
run: |
59-
nix run '.#gcd.vcs' --impure
59+
nix build '.#gcd.vcs.tests' --impure
6060
6161
run-verilator:
6262
name: "Run Verilator"

templates/chisel/nix/gcd/vcs.nix

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# SPDX-FileCopyrightText: 2024 Jiuyang Liu <[email protected]>
33

4-
{ lib, bash, stdenv, rtl, dpi-lib, vcs-fhs-env }:
5-
let binName = "gcd-vcs-simulator";
6-
in stdenv.mkDerivation {
4+
{ lib
5+
, bash
6+
, stdenv
7+
, rtl
8+
, dpi-lib
9+
, vcs-fhs-env
10+
, runCommand
11+
}:
12+
13+
let
14+
binName = "gcd-vcs-simulator";
15+
in
16+
stdenv.mkDerivation (finalAttr: {
717
name = "vcs";
818

919
# Add "sandbox = relaxed" into /etc/nix/nix.conf, and run `systemctl restart nix-daemon`
@@ -46,6 +56,10 @@ in stdenv.mkDerivation {
4656
inherit vcs-fhs-env;
4757
inherit dpi-lib;
4858
inherit rtl;
59+
60+
tests.run-sim = runCommand "run-gcd-vcs-simulator" { __noChroot = true; } ''
61+
${finalAttr.finalPackage}/bin/${binName}
62+
'';
4963
};
5064

5165
shellHook = ''
@@ -71,4 +85,4 @@ in stdenv.mkDerivation {
7185
7286
runHook postInstall
7387
'';
74-
}
88+
})

0 commit comments

Comments
 (0)