2019-02-14 15:29:42 +08:00
|
|
|
let
|
2019-04-08 23:45:30 +08:00
|
|
|
pkgs = import <nixpkgs> {};
|
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-02-14 15:29:42 +08:00
|
|
|
''
|
2019-07-17 19:19:43 +08:00
|
|
|
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`
|
|
|
|
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`
|
2019-03-31 23:06:46 +08:00
|
|
|
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-06-13 14:05:30 +08:00
|
|
|
echo "{ stdenv, git, fetchgit }: \"$MAJOR_VERSION.$COMMIT_COUNT.`cut -c1-8 <<< $REV`.beta\"" > $out/pkgs/artiq-version.nix
|
2019-04-24 15:05:29 +08:00
|
|
|
echo "{ stdenv, git, fetchgit }: \"$TIMESTAMP\"" > $out/pkgs/artiq-timestamp.nix
|
2019-02-14 15:29:42 +08:00
|
|
|
'';
|
2019-03-14 11:19:18 +08:00
|
|
|
generateTestOkHash = pkgs.runCommand "generate-test-ok-hash" { buildInputs = [ pkgs.nix ]; }
|
|
|
|
''
|
|
|
|
TMPDIR=`mktemp -d`
|
2019-06-13 09:11:06 +08:00
|
|
|
cp ${generatedNix}/pkgs/artiq-version.nix $TMPDIR/passed
|
2019-03-14 11:19:18 +08:00
|
|
|
HASH=`nix-hash --type sha256 --base32 $TMPDIR`
|
|
|
|
echo \"$HASH\" > $out
|
|
|
|
'';
|
2019-02-15 18:17:34 +08:00
|
|
|
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; });
|
2019-04-15 07:12:48 +08:00
|
|
|
windowsRunner = overrides:
|
2019-04-18 21:54:06 +08:00
|
|
|
import "${generatedNix}/windows/run-test.nix" ({
|
2019-04-15 07:12:48 +08:00
|
|
|
inherit pkgs;
|
2019-11-10 15:54:02 +08:00
|
|
|
sipycoPkg = artiqpkgs.conda-sipyco;
|
2019-04-15 07:12:48 +08:00
|
|
|
artiqPkg = artiqpkgs.conda-artiq;
|
|
|
|
} // overrides);
|
2019-07-17 19:21:06 +08:00
|
|
|
jobs = (builtins.mapAttrs (key: value: pkgs.lib.hydraJob value) artiqpkgs);
|
2019-02-14 15:29:42 +08:00
|
|
|
in
|
|
|
|
jobs // {
|
2019-07-17 19:19:43 +08:00
|
|
|
generated-nix = pkgs.lib.hydraJob generatedNix; # used by artiq-full
|
2019-07-17 20:03:36 +08:00
|
|
|
artiq-fast = pkgs.releaseTools.channel {
|
|
|
|
name = "artiq-fast";
|
2019-02-14 17:49:40 +08:00
|
|
|
src = generatedNix;
|
2019-02-14 15:29:42 +08:00
|
|
|
constituents = builtins.attrValues jobs;
|
|
|
|
};
|
2019-03-14 11:19:18 +08:00
|
|
|
|
2019-04-22 06:09:27 +08:00
|
|
|
windows-no-hardware-tests = pkgs.stdenv.mkDerivation {
|
|
|
|
name = "windows-no-hardware-tests";
|
|
|
|
buildInputs = [ (windowsRunner {}) ];
|
|
|
|
phases = [ "buildPhase" ];
|
|
|
|
buildPhase = ''
|
|
|
|
${windowsRunner {}}/bin/run.sh
|
|
|
|
touch $out
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2019-03-14 11:19:18 +08:00
|
|
|
# HACK: Abuse fixed-output derivations to escape the sandbox and run the hardware
|
|
|
|
# unit tests, all integrated in the Hydra interface.
|
|
|
|
# One major downside of this hack is the tests are only run when generateTestOkHash
|
|
|
|
# changes, i.e. when the ARTIQ version changes (and not the dependencies).
|
|
|
|
# Impure derivations, when they land in Nix/Hydra, should improve the situation.
|
2019-04-15 07:12:48 +08:00
|
|
|
extended-tests = pkgs.stdenv.mkDerivation {
|
|
|
|
name = "extended-tests";
|
2019-03-14 17:51:04 +08:00
|
|
|
|
2019-03-14 11:19:18 +08:00
|
|
|
outputHashAlgo = "sha256";
|
|
|
|
outputHashMode = "recursive";
|
|
|
|
outputHash = import generateTestOkHash;
|
2019-03-14 17:51:04 +08:00
|
|
|
__hydraRetry = false;
|
|
|
|
|
2019-03-14 11:19:18 +08:00
|
|
|
buildInputs = [
|
2019-03-14 12:26:03 +08:00
|
|
|
(pkgs.python3.withPackages(ps: [ ps.paramiko artiqpkgs.artiq artiqpkgs.artiq-board-kc705-nist_clock ]))
|
2019-03-14 11:19:18 +08:00
|
|
|
artiqpkgs.binutils-or1k
|
2019-03-14 12:26:03 +08:00
|
|
|
artiqpkgs.openocd
|
2019-03-14 11:19:18 +08:00
|
|
|
pkgs.iputils
|
2019-05-30 06:41:22 +08:00
|
|
|
pkgs.openssh
|
2019-03-14 11:19:18 +08:00
|
|
|
];
|
2019-03-14 17:52:44 +08:00
|
|
|
phases = [ "buildPhase" ];
|
|
|
|
buildPhase =
|
2019-03-14 11:19:18 +08:00
|
|
|
''
|
2019-03-14 14:06:40 +08:00
|
|
|
export HOME=`mktemp -d`
|
|
|
|
mkdir $HOME/.ssh
|
2019-03-14 14:13:42 +08:00
|
|
|
cp /opt/hydra_id_rsa $HOME/.ssh/id_rsa
|
2019-03-14 14:20:28 +08:00
|
|
|
cp /opt/hydra_id_rsa.pub $HOME/.ssh/id_rsa.pub
|
2019-04-06 11:03:06 +08:00
|
|
|
echo "rpi-1,192.168.1.188 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMc7waNkP2HjL5Eo94evoxJhC8CbYj4i2n1THe5TPIR3" > $HOME/.ssh/known_hosts
|
2019-06-04 13:36:46 +08:00
|
|
|
chmod 600 $HOME/.ssh/id_rsa
|
2019-05-30 19:29:30 +08:00
|
|
|
LOCKCTL=$(mktemp -d)
|
|
|
|
mkfifo $LOCKCTL/lockctl
|
2019-04-15 07:12:48 +08:00
|
|
|
|
2019-06-12 06:07:27 +08:00
|
|
|
cat $LOCKCTL/lockctl | ${pkgs.openssh}/bin/ssh \
|
2019-06-13 08:55:45 +08:00
|
|
|
-i $HOME/.ssh/id_rsa \
|
2019-06-12 06:07:27 +08:00
|
|
|
-o UserKnownHostsFile=$HOME/.ssh/known_hosts \
|
2019-06-12 19:00:23 +08:00
|
|
|
sb@rpi-1 \
|
2019-06-12 06:07:27 +08:00
|
|
|
'flock /tmp/board_lock-kc705-1 -c "echo Ok; cat"' \
|
|
|
|
| (
|
2019-05-30 06:49:00 +08:00
|
|
|
# End remote flock via FIFO
|
|
|
|
atexit_unlock() {
|
2019-05-30 19:29:30 +08:00
|
|
|
echo > $LOCKCTL/lockctl
|
2019-05-30 06:49:00 +08:00
|
|
|
}
|
|
|
|
trap atexit_unlock EXIT
|
|
|
|
|
2019-05-30 05:46:03 +08:00
|
|
|
# Read "Ok" line when remote successfully locked
|
|
|
|
read LOCK_OK
|
2019-04-15 07:12:48 +08:00
|
|
|
|
2019-05-30 05:46:03 +08:00
|
|
|
artiq_flash -t kc705 -H rpi-1
|
|
|
|
sleep 15
|
|
|
|
# ping: socket: Operation not permitted
|
|
|
|
#ping kc705-1 -c10 -w30
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
${windowsRunner { testCommand = "set ARTIQ_ROOT=%cd%\\anaconda\\envs\\artiq-env\\Lib\\site-packages\\artiq\\examples\\kc705_nist_clock&&python -m unittest discover -v artiq.test.coredevice"; }}/bin/run.sh
|
|
|
|
)
|
2019-04-15 07:12:48 +08:00
|
|
|
|
2019-03-14 11:19:18 +08:00
|
|
|
mkdir $out
|
2019-06-13 09:11:06 +08:00
|
|
|
cp ${generatedNix}/pkgs/artiq-version.nix $out/passed
|
2019-03-14 11:19:18 +08:00
|
|
|
'';
|
|
|
|
};
|
2019-02-14 15:29:42 +08:00
|
|
|
}
|