nix-scripts/artiq-fast.nix

122 lines
4.3 KiB
Nix
Raw Permalink Normal View History

let
pkgs = import <nixpkgs> { overlays = [ (import ./artiq-fast/mozilla-overlay.nix) ]; };
2019-02-14 20:16:56 +08:00
artiqSrc = <artiqSrc>;
2019-02-14 19:31:46 +08:00
generatedNix = pkgs.runCommand "generated-nix" { buildInputs = [ pkgs.nix pkgs.git ]; }
2019-11-14 17:44:36 +08:00
# keep in sync with artiq-fast/pkgs/artiq-version.nix
''
cp --no-preserve=mode,ownership -R ${./artiq-fast} $out
2019-02-14 19:31:46 +08:00
REV=`git --git-dir ${artiqSrc}/.git rev-parse HEAD`
2019-06-13 14:05:30 +08:00
MAJOR_VERSION=`cat ${artiqSrc}/MAJOR_VERSION`
2019-11-14 18:33:00 +08:00
if [ -e ${artiqSrc}/BETA ]; then
2019-11-14 17:44:36 +08:00
SUFFIX=".beta"
else
SUFFIX=""
fi
2019-06-13 14:05:30 +08:00
COMMIT_COUNT=`git --git-dir ${artiqSrc}/.git rev-list --count HEAD`
2019-04-24 04:25:34 +08:00
TIMESTAMP=`git --git-dir ${artiqSrc}/.git log -1 --format=%ct`
ARTIQ_SRC_CLEAN=`mktemp -d`
cp -a ${artiqSrc}/. $ARTIQ_SRC_CLEAN
chmod -R 755 $ARTIQ_SRC_CLEAN/.git
chmod 755 $ARTIQ_SRC_CLEAN
rm -rf $ARTIQ_SRC_CLEAN/.git
HASH=`nix-hash --type sha256 --base32 $ARTIQ_SRC_CLEAN`
2019-02-14 19:31:46 +08:00
cat > $out/pkgs/artiq-src.nix << EOF
{ fetchgit }:
fetchgit {
url = "git://github.com/m-labs/artiq.git";
rev = "$REV";
sha256 = "$HASH";
}
EOF
2019-11-14 17:56:19 +08:00
echo "{ stdenv, git, fetchgit }: \"$MAJOR_VERSION.$COMMIT_COUNT.`cut -c1-8 <<< $REV`$SUFFIX\"" > $out/pkgs/artiq-version.nix
echo "{ stdenv, git, fetchgit }: \"$TIMESTAMP\"" > $out/pkgs/artiq-timestamp.nix
'';
artiqpkgs = import "${generatedNix}/default.nix" { inherit pkgs; };
2019-04-24 15:17:40 +08:00
artiqVersion = import "${generatedNix}/pkgs/artiq-version.nix" (with pkgs; { inherit stdenv fetchgit git; });
windowsRunner =
if (pkgs.lib.versionAtLeast artiqVersion "7.0")
then
(overrides:
pkgs.writeScriptBin "wfvm-run-windows-tests"
''
#!${pkgs.bash}/bin/bash
echo "Windows tests skipped"
''
)
else
(overrides:
import "${generatedNix}/windows/run-test.nix" ({
2020-06-22 17:45:18 +08:00
inherit pkgs artiqpkgs;
} // overrides));
2019-07-17 19:21:06 +08:00
jobs = (builtins.mapAttrs (key: value: pkgs.lib.hydraJob value) artiqpkgs);
in
jobs // {
generated-nix = pkgs.lib.hydraJob generatedNix; # used by artiq-full
artiq-fast = pkgs.releaseTools.channel {
name = "artiq-fast";
src = generatedNix;
constituents = builtins.attrValues jobs;
};
2019-04-22 06:09:27 +08:00
windows-no-hardware-tests = pkgs.stdenv.mkDerivation {
name = "windows-no-hardware-tests";
phases = [ "buildPhase" ];
buildPhase = ''
2020-06-22 17:53:01 +08:00
${windowsRunner { testCommand = "python -m unittest discover -v sipyco.test && python -m unittest discover -v artiq.test"; }}/bin/wfvm-run-windows-tests
2019-04-22 06:09:27 +08:00
touch $out
'';
};
extended-tests = pkgs.stdenv.mkDerivation {
name = "extended-tests";
# requires patched Nix
__networked = true;
buildInputs = [
(pkgs.python3.withPackages(ps: [ ps.paramiko artiqpkgs.artiq artiqpkgs.artiq-board-kc705-nist_clock ]))
artiqpkgs.openocd
2019-05-30 06:41:22 +08:00
pkgs.openssh
2021-09-13 07:07:41 +08:00
] ++ (if (pkgs.lib.versionAtLeast artiqVersion "7.0") then [ pkgs.llvm_11 pkgs.lld_11 ] else [ artiqpkgs.binutils-or1k ]);
phases = [ "buildPhase" ];
buildPhase =
''
export HOME=`mktemp -d`
mkdir $HOME/.ssh
2021-12-03 18:36:41 +08:00
cp /opt/hydra_id_ed25519 $HOME/.ssh/id_ed25519
cp /opt/hydra_id_ed25519.pub $HOME/.ssh/id_ed25519.pub
2021-04-24 16:53:52 +08:00
echo "rpi-1 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPOBQVcsvk6WgRj18v4m0zkFeKrcN9gA+r6sxQxNwFpv" > $HOME/.ssh/known_hosts
2021-12-03 18:36:41 +08:00
chmod 600 $HOME/.ssh/id_ed25519
LOCKCTL=$(mktemp -d)
mkfifo $LOCKCTL/lockctl
cat $LOCKCTL/lockctl | ${pkgs.openssh}/bin/ssh \
2021-12-03 18:36:41 +08:00
-i $HOME/.ssh/id_ed25519 \
-o UserKnownHostsFile=$HOME/.ssh/known_hosts \
rpi-1 \
'mkdir -p /tmp/board_lock && flock /tmp/board_lock/kc705-1 -c "echo Ok; cat"' \
| (
# End remote flock via FIFO
atexit_unlock() {
echo > $LOCKCTL/lockctl
}
trap atexit_unlock EXIT
# Read "Ok" line when remote successfully locked
read LOCK_OK
artiq_flash -t kc705 -H rpi-1
sleep 15
export ARTIQ_ROOT=`python -c "import artiq; print(artiq.__path__[0])"`/examples/kc705_nist_clock
export ARTIQ_LOW_LATENCY=1
python -m unittest discover -v artiq.test.coredevice
2020-06-22 17:45:18 +08:00
${windowsRunner { testCommand = "set ARTIQ_ROOT=%cd%\\Anaconda3\\envs\\artiq-env\\Lib\\site-packages\\artiq\\examples\\kc705_nist_clock&& python -m unittest discover -v artiq.test.coredevice"; }}/bin/wfvm-run-windows-tests
)
touch $out
'';
};
}