You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
4.1 KiB

3 years ago
  1. let
  2. pkgs = import <nixpkgs> { overlays = [ (import ./artiq-fast/mozilla-overlay.nix) ]; };
  3. artiqSrc = <artiqSrc>;
  4. generatedNix = pkgs.runCommand "generated-nix" { buildInputs = [ pkgs.nix pkgs.git ]; }
  5. # keep in sync with artiq-fast/pkgs/artiq-version.nix
  6. ''
  7. cp --no-preserve=mode,ownership -R ${./artiq-fast} $out
  8. REV=`git --git-dir ${artiqSrc}/.git rev-parse HEAD`
  9. MAJOR_VERSION=`cat ${artiqSrc}/MAJOR_VERSION`
  10. if [ -e ${artiqSrc}/BETA ]; then
  11. SUFFIX=".beta"
  12. else
  13. SUFFIX=""
  14. fi
  15. COMMIT_COUNT=`git --git-dir ${artiqSrc}/.git rev-list --count HEAD`
  16. TIMESTAMP=`git --git-dir ${artiqSrc}/.git log -1 --format=%ct`
  17. ARTIQ_SRC_CLEAN=`mktemp -d`
  18. cp -a ${artiqSrc}/. $ARTIQ_SRC_CLEAN
  19. chmod -R 755 $ARTIQ_SRC_CLEAN/.git
  20. chmod 755 $ARTIQ_SRC_CLEAN
  21. rm -rf $ARTIQ_SRC_CLEAN/.git
  22. HASH=`nix-hash --type sha256 --base32 $ARTIQ_SRC_CLEAN`
  23. cat > $out/pkgs/artiq-src.nix << EOF
  24. { fetchgit }:
  25. fetchgit {
  26. url = "git://github.com/m-labs/artiq.git";
  27. rev = "$REV";
  28. sha256 = "$HASH";
  29. }
  30. EOF
  31. echo "{ stdenv, git, fetchgit }: \"$MAJOR_VERSION.$COMMIT_COUNT.`cut -c1-8 <<< $REV`$SUFFIX\"" > $out/pkgs/artiq-version.nix
  32. echo "{ stdenv, git, fetchgit }: \"$TIMESTAMP\"" > $out/pkgs/artiq-timestamp.nix
  33. '';
  34. artiqpkgs = import "${generatedNix}/default.nix" { inherit pkgs; };
  35. artiqVersion = import "${generatedNix}/pkgs/artiq-version.nix" (with pkgs; { inherit stdenv fetchgit git; });
  36. windowsRunner = overrides:
  37. import "${generatedNix}/windows/run-test.nix" ({
  38. inherit pkgs artiqpkgs;
  39. } // overrides);
  40. jobs = (builtins.mapAttrs (key: value: pkgs.lib.hydraJob value) artiqpkgs);
  41. in
  42. jobs // {
  43. generated-nix = pkgs.lib.hydraJob generatedNix; # used by artiq-full
  44. artiq-fast = pkgs.releaseTools.channel {
  45. name = "artiq-fast";
  46. src = generatedNix;
  47. constituents = builtins.attrValues jobs;
  48. };
  49. windows-no-hardware-tests = pkgs.stdenv.mkDerivation {
  50. name = "windows-no-hardware-tests";
  51. phases = [ "buildPhase" ];
  52. buildPhase = ''
  53. ${windowsRunner { testCommand = "python -m unittest discover -v sipyco.test && python -m unittest discover -v artiq.test"; }}/bin/wfvm-run-windows-tests
  54. touch $out
  55. '';
  56. };
  57. extended-tests = pkgs.stdenv.mkDerivation {
  58. name = "extended-tests";
  59. # requires patched Nix
  60. __networked = true;
  61. buildInputs = [
  62. (pkgs.python3.withPackages(ps: [ ps.paramiko artiqpkgs.artiq artiqpkgs.artiq-board-kc705-nist_clock ]))
  63. artiqpkgs.openocd
  64. pkgs.openssh
  65. ] ++ (if (pkgs.lib.versionAtLeast artiqVersion "7.0") then [ pkgs.llvm_11 pkgs.lld_11 ] else [ artiqpkgs.binutils-or1k ]);
  66. phases = [ "buildPhase" ];
  67. buildPhase =
  68. ''
  69. export HOME=`mktemp -d`
  70. mkdir $HOME/.ssh
  71. cp /opt/hydra_id_rsa $HOME/.ssh/id_rsa
  72. cp /opt/hydra_id_rsa.pub $HOME/.ssh/id_rsa.pub
  73. echo "rpi-1 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPOBQVcsvk6WgRj18v4m0zkFeKrcN9gA+r6sxQxNwFpv" > $HOME/.ssh/known_hosts
  74. chmod 600 $HOME/.ssh/id_rsa
  75. LOCKCTL=$(mktemp -d)
  76. mkfifo $LOCKCTL/lockctl
  77. cat $LOCKCTL/lockctl | ${pkgs.openssh}/bin/ssh \
  78. -i $HOME/.ssh/id_rsa \
  79. -o UserKnownHostsFile=$HOME/.ssh/known_hosts \
  80. rpi-1 \
  81. 'mkdir -p /tmp/board_lock && flock /tmp/board_lock/kc705-1 -c "echo Ok; cat"' \
  82. | (
  83. # End remote flock via FIFO
  84. atexit_unlock() {
  85. echo > $LOCKCTL/lockctl
  86. }
  87. trap atexit_unlock EXIT
  88. # Read "Ok" line when remote successfully locked
  89. read LOCK_OK
  90. artiq_flash -t kc705 -H rpi-1
  91. sleep 15
  92. export ARTIQ_ROOT=`python -c "import artiq; print(artiq.__path__[0])"`/examples/kc705_nist_clock
  93. export ARTIQ_LOW_LATENCY=1
  94. python -m unittest discover -v artiq.test.coredevice
  95. ${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
  96. )
  97. touch $out
  98. '';
  99. };
  100. }