From 7dd78a6e29dc771949d2000327f4dfda6fbd5ecf Mon Sep 17 00:00:00 2001 From: "guillem.cordoba" Date: Tue, 4 Jun 2024 10:54:00 +0200 Subject: [PATCH] Fixed sweettest --- .github/workflows/test-nix.yml | 41 +++++------------- flake.lock | 38 ++++++++--------- flake.nix | 2 - nix/fixtures/module-repo/flake.lock | 64 ++++++++++++++--------------- nix/sweettest.nix | 56 +++++++++++++++++++++---- nix/zome.nix | 6 ++- 6 files changed, 113 insertions(+), 94 deletions(-) diff --git a/.github/workflows/test-nix.yml b/.github/workflows/test-nix.yml index 3def140..eed5c93 100644 --- a/.github/workflows/test-nix.yml +++ b/.github/workflows/test-nix.yml @@ -9,7 +9,11 @@ on: jobs: linux-build-and-cache: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -22,6 +26,12 @@ jobs: with: name: holochain-ci + - name: Test flake + env: + CACHIX_AUTH_TOKEN: "${{ secrets.CACHIX_TOKEN_HOLOCHAIN_OPEN_DEV }}" + run: | + cachix watch-exec holochain-open-dev -- nix flake check -L + - name: Build zomes env: CACHIX_AUTH_TOKEN: "${{ secrets.CACHIX_TOKEN_HOLOCHAIN_OPEN_DEV }}" @@ -37,32 +47,3 @@ jobs: run: | cd ./nix/fixtures/module-repo cachix watch-exec holochain-open-dev -- nix flake check -L - - macos-just-get-from-cache: - needs: linux-build-and-cache - runs-on: macos-latest - steps: - - uses: actions/checkout@v4 - - - name: Install nix - uses: cachix/install-nix-action@v25 - with: - nix_path: nixpkgs=channel:nixos-unstable - - - uses: cachix/cachix-action@v14 - with: - name: holochain-ci - - - uses: cachix/cachix-action@v14 - with: - name: holochain-open-dev - - - name: Install coreutils for macOS - run: brew install coreutils - - - name: Build zomes - run: | - cd ./nix/fixtures/module-repo - nix flake update - nix build -L .#my_zome - sha256sum result diff --git a/flake.lock b/flake.lock index c3db1fd..54736d9 100644 --- a/flake.lock +++ b/flake.lock @@ -192,11 +192,11 @@ ] }, "locked": { - "lastModified": 1717397430, - "narHash": "sha256-mYjWQVvUQZ58GdeyBppN8Lz2dnpxg6m+CaCqv8ijUaU=", + "lastModified": 1717482700, + "narHash": "sha256-JxnEyQ/GkBmAIRa6C+QU8BfMLfZXga8HhsKuvMIcz0k=", "owner": "holochain", "repo": "holochain", - "rev": "d5a17433b5e8772a6b06dcf9f7c58616ef4376cd", + "rev": "feff99c570ab9e9f73c627683e081a3fbcab5ef6", "type": "github" }, "original": { @@ -208,16 +208,16 @@ "holochain_2": { "flake": false, "locked": { - "lastModified": 1715896367, - "narHash": "sha256-jRxb8HsXUV7Fba3hMCL+TycbvF7v+JT53eIryZPu878=", + "lastModified": 1717415946, + "narHash": "sha256-Fjvmz9JKwwKzluJqax8dk3Y8gjnKW2ec2+rBwujK+nA=", "owner": "holochain", "repo": "holochain", - "rev": "9f293072c41bd053e9cd88f746a456ee1dee1990", + "rev": "dc34e4e851f1a8e4bfa3a36ff1adf6c8a2c64e47", "type": "github" }, "original": { "owner": "holochain", - "ref": "holochain-0.3.1-rc.0", + "ref": "holochain-0.3.1-rc.1", "repo": "holochain", "type": "github" } @@ -242,11 +242,11 @@ "launcher": { "flake": false, "locked": { - "lastModified": 1716406557, - "narHash": "sha256-6eWndYspznXKYIJcuPCWFZ3lxdh7TrlEUGP1zaE5Mgs=", + "lastModified": 1717431387, + "narHash": "sha256-+VvWwBmxcgePV1L6kU2mSkg3emMiMgpdQnCqvQJkRPk=", "owner": "holochain", "repo": "launcher", - "rev": "f20844aa5041432547c55176d71e67b32e302f77", + "rev": "9d9cab5e6b57e1c278113921ff203e515c8bbd2e", "type": "github" }, "original": { @@ -372,11 +372,11 @@ ] }, "locked": { - "lastModified": 1717381101, - "narHash": "sha256-TcM4+oHTSLw8neTxk/Q0beODr8YiL+oI2j0ENYnNfk4=", + "lastModified": 1717467480, + "narHash": "sha256-9Fbar+ycxdfZ6HbwOCgD+jWG3du/12TFisKRQm4Zhfc=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "07098b424d114cd2dddec40be8d5586da339fddc", + "rev": "260ff391290a2b23958d04db0d3e7015c8417401", "type": "github" }, "original": { @@ -388,11 +388,11 @@ "scaffolding": { "flake": false, "locked": { - "lastModified": 1717056432, - "narHash": "sha256-zsSoSsqrDKI/ETGkkjKAIl9GXZ8Qe1T6/TpMvlVRc8M=", + "lastModified": 1717435938, + "narHash": "sha256-cF4TNX5gz8AvBsdbWanwMaLV4gXuobfpUTN5f9PIFNY=", "owner": "holochain", "repo": "scaffolding", - "rev": "a14167ccf966d1b7ef9b35a68bb359864c2c6fae", + "rev": "341d6a43fc357398a7361e58ad33df91f48177e6", "type": "github" }, "original": { @@ -426,11 +426,11 @@ }, "locked": { "dir": "versions/0_3_rc", - "lastModified": 1717397430, - "narHash": "sha256-mYjWQVvUQZ58GdeyBppN8Lz2dnpxg6m+CaCqv8ijUaU=", + "lastModified": 1717482700, + "narHash": "sha256-JxnEyQ/GkBmAIRa6C+QU8BfMLfZXga8HhsKuvMIcz0k=", "owner": "holochain", "repo": "holochain", - "rev": "d5a17433b5e8772a6b06dcf9f7c58616ef4376cd", + "rev": "feff99c570ab9e9f73c627683e081a3fbcab5ef6", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 8c5300e..0ee1cf6 100644 --- a/flake.nix +++ b/flake.nix @@ -96,7 +96,6 @@ commonArgs = { inherit src; doCheck = false; - strictDeps = true; CARGO_BUILD_TARGET = "wasm32-unknown-unknown"; }; cargoArtifacts = craneLib.buildDepsOnly (commonArgs // { @@ -124,7 +123,6 @@ src = craneLib.cleanCargoSource (craneLib.path ./nix/reference-happ); doCheck = false; - strictDeps = true; # RUSTFLAGS = # "--remap-path-prefix ${cargoVendorDir}=/build/source/"; # CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS = diff --git a/nix/fixtures/module-repo/flake.lock b/nix/fixtures/module-repo/flake.lock index 72b1626..9fa6c9a 100644 --- a/nix/fixtures/module-repo/flake.lock +++ b/nix/fixtures/module-repo/flake.lock @@ -612,7 +612,7 @@ }, "locked": { "lastModified": 0, - "narHash": "sha256-//W7IdSoINO+cP3UiQTT1bZJuXzt7zbQVmJJGTZi9A4=", + "narHash": "sha256-LeSaOjFHZrBzg5Xsy7vfmIe6mOZRBVBPQX10YK2RRfQ=", "path": "../../..", "type": "path" }, @@ -693,11 +693,11 @@ ] }, "locked": { - "lastModified": 1717397430, - "narHash": "sha256-mYjWQVvUQZ58GdeyBppN8Lz2dnpxg6m+CaCqv8ijUaU=", + "lastModified": 1717482700, + "narHash": "sha256-JxnEyQ/GkBmAIRa6C+QU8BfMLfZXga8HhsKuvMIcz0k=", "owner": "holochain", "repo": "holochain", - "rev": "d5a17433b5e8772a6b06dcf9f7c58616ef4376cd", + "rev": "feff99c570ab9e9f73c627683e081a3fbcab5ef6", "type": "github" }, "original": { @@ -709,16 +709,16 @@ "holochain_2": { "flake": false, "locked": { - "lastModified": 1715896367, - "narHash": "sha256-jRxb8HsXUV7Fba3hMCL+TycbvF7v+JT53eIryZPu878=", + "lastModified": 1717415946, + "narHash": "sha256-Fjvmz9JKwwKzluJqax8dk3Y8gjnKW2ec2+rBwujK+nA=", "owner": "holochain", "repo": "holochain", - "rev": "9f293072c41bd053e9cd88f746a456ee1dee1990", + "rev": "dc34e4e851f1a8e4bfa3a36ff1adf6c8a2c64e47", "type": "github" }, "original": { "owner": "holochain", - "ref": "holochain-0.3.1-rc.0", + "ref": "holochain-0.3.1-rc.1", "repo": "holochain", "type": "github" } @@ -758,11 +758,11 @@ ] }, "locked": { - "lastModified": 1717418271, - "narHash": "sha256-tseJOx6mouuEzp6cawUXnAfD87J9FELGW6JQIE5omiE=", + "lastModified": 1717482700, + "narHash": "sha256-JxnEyQ/GkBmAIRa6C+QU8BfMLfZXga8HhsKuvMIcz0k=", "owner": "holochain", "repo": "holochain", - "rev": "a13e522072aa239cb5b8ce78a14716d8e601846b", + "rev": "feff99c570ab9e9f73c627683e081a3fbcab5ef6", "type": "github" }, "original": { @@ -1004,11 +1004,11 @@ "launcher": { "flake": false, "locked": { - "lastModified": 1716406557, - "narHash": "sha256-6eWndYspznXKYIJcuPCWFZ3lxdh7TrlEUGP1zaE5Mgs=", + "lastModified": 1717431387, + "narHash": "sha256-+VvWwBmxcgePV1L6kU2mSkg3emMiMgpdQnCqvQJkRPk=", "owner": "holochain", "repo": "launcher", - "rev": "f20844aa5041432547c55176d71e67b32e302f77", + "rev": "9d9cab5e6b57e1c278113921ff203e515c8bbd2e", "type": "github" }, "original": { @@ -1369,11 +1369,11 @@ "versions": "versions_3" }, "locked": { - "lastModified": 1717148630, - "narHash": "sha256-pJ0d0jA1RzqZwx6jL4sEXT2bjDvLXMwjZQWXwoVGbEs=", + "lastModified": 1717434000, + "narHash": "sha256-bUM+dUEuHu45C5ZUCun/NTdRb48fPvBhej84/zAKQxI=", "owner": "holochain-open-dev", "repo": "profiles", - "rev": "decbb755bfa4432d672a58783eb7d4985fcadcba", + "rev": "63aafdb8e4f9eb97741b98634859cb48f3d1f046", "type": "github" }, "original": { @@ -1453,11 +1453,11 @@ ] }, "locked": { - "lastModified": 1717381101, - "narHash": "sha256-TcM4+oHTSLw8neTxk/Q0beODr8YiL+oI2j0ENYnNfk4=", + "lastModified": 1717467480, + "narHash": "sha256-9Fbar+ycxdfZ6HbwOCgD+jWG3du/12TFisKRQm4Zhfc=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "07098b424d114cd2dddec40be8d5586da339fddc", + "rev": "260ff391290a2b23958d04db0d3e7015c8417401", "type": "github" }, "original": { @@ -1475,11 +1475,11 @@ ] }, "locked": { - "lastModified": 1717406456, - "narHash": "sha256-voWbxOZu1DM6hLOlOkLqSrZ8BsOY6F9h/tYB9C0jOXs=", + "lastModified": 1717467480, + "narHash": "sha256-9Fbar+ycxdfZ6HbwOCgD+jWG3du/12TFisKRQm4Zhfc=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "711ff40be18b09bf096930f52e1fb2fcbee9adf0", + "rev": "260ff391290a2b23958d04db0d3e7015c8417401", "type": "github" }, "original": { @@ -1538,11 +1538,11 @@ "scaffolding": { "flake": false, "locked": { - "lastModified": 1717056432, - "narHash": "sha256-zsSoSsqrDKI/ETGkkjKAIl9GXZ8Qe1T6/TpMvlVRc8M=", + "lastModified": 1717435938, + "narHash": "sha256-cF4TNX5gz8AvBsdbWanwMaLV4gXuobfpUTN5f9PIFNY=", "owner": "holochain", "repo": "scaffolding", - "rev": "a14167ccf966d1b7ef9b35a68bb359864c2c6fae", + "rev": "341d6a43fc357398a7361e58ad33df91f48177e6", "type": "github" }, "original": { @@ -1672,11 +1672,11 @@ }, "locked": { "dir": "versions/0_3_rc", - "lastModified": 1717397430, - "narHash": "sha256-mYjWQVvUQZ58GdeyBppN8Lz2dnpxg6m+CaCqv8ijUaU=", + "lastModified": 1717482700, + "narHash": "sha256-JxnEyQ/GkBmAIRa6C+QU8BfMLfZXga8HhsKuvMIcz0k=", "owner": "holochain", "repo": "holochain", - "rev": "d5a17433b5e8772a6b06dcf9f7c58616ef4376cd", + "rev": "feff99c570ab9e9f73c627683e081a3fbcab5ef6", "type": "github" }, "original": { @@ -1741,11 +1741,11 @@ }, "locked": { "dir": "versions/weekly", - "lastModified": 1717418271, - "narHash": "sha256-tseJOx6mouuEzp6cawUXnAfD87J9FELGW6JQIE5omiE=", + "lastModified": 1717482700, + "narHash": "sha256-JxnEyQ/GkBmAIRa6C+QU8BfMLfZXga8HhsKuvMIcz0k=", "owner": "holochain", "repo": "holochain", - "rev": "a13e522072aa239cb5b8ce78a14716d8e601846b", + "rev": "feff99c570ab9e9f73c627683e081a3fbcab5ef6", "type": "github" }, "original": { diff --git a/nix/sweettest.nix b/nix/sweettest.nix index d7f2e26..ca04fc3 100644 --- a/nix/sweettest.nix +++ b/nix/sweettest.nix @@ -1,30 +1,68 @@ -{ dna, cargoArtifacts, buildInputs, nativeBuildInputs, workspacePath, craneLib -, crateCargoToml, ... }: +{ pkgs, dna, lib, cargoArtifacts, buildInputs, nativeBuildInputs, workspacePath +, craneLib, crateCargoToml, ... }: let cargoToml = builtins.fromTOML (builtins.readFile crateCargoToml); crate = cargoToml.package.name; src = craneLib.cleanCargoSource (craneLib.path workspacePath); - commonArgs = { - inherit cargoArtifacts buildInputs nativeBuildInputs src; - strictDeps = true; - CARGO_PROFILE = "release"; - }; + commonArgs = { inherit cargoArtifacts buildInputs nativeBuildInputs src; }; + + listCratesFromWorkspace = src: + let + allFiles = lib.filesystem.listFilesRecursive src; + allCargoTomlsPaths = + builtins.filter (path: lib.strings.hasSuffix "/Cargo.toml" path) + allFiles; + allCratesPaths = + builtins.map (path: builtins.dirOf path) allCargoTomlsPaths; + cratesCargoToml = builtins.map + (path: builtins.fromTOML (builtins.readFile (path + "/Cargo.toml"))) + allCratesPaths; + nonWorkspaceCrates = + builtins.filter (toml: builtins.hasAttr "package" toml) cratesCargoToml; + cratesNames = builtins.map (toml: toml.package.name) nonWorkspaceCrates; + in cratesNames; + packageList = listCratesFromWorkspace src; + packages = + builtins.toString (builtins.map (c: " --package ${c}") packageList); workspaceCargoArtifacts = (craneLib.callPackage ./buildDepsOnlyWithArtifacts.nix { }) (commonArgs // { doCheck = false; + cargoBuildCommand = "cargoWorkspace build --tests"; + cargoTestCommand = "cargoWorkspace test"; + cargoCheckCommand = ""; + preBuild = '' + cargoWorkspace() { + command=$(shift) + for package in ${builtins.toString packageList}; do + ( + cargoWithProfile $command "$@" -p $package + ) + done + } + ''; + pname = "workspace-sweettest"; - cargoExtraArgs = "--workspace --tests"; version = cargoToml.package.version; }); + # workspaceCargoArtifacts = + # (craneLib.callPackage ./buildDepsOnlyWithArtifacts.nix { }) (commonArgs // { + # doCheck = false; + # cargoExtraArgs = "--workspace --locked --all-targets"; + + # pname = "workspace-sweettest"; + # version = cargoToml.package.version; + # }); in craneLib.cargoNextest (commonArgs // { cargoArtifacts = workspaceCargoArtifacts; - pname = "${crate}-sweettest"; + pname = "${crate}-test"; version = cargoToml.package.version; + # cargoTestArgs = "-p ${crate} -j 1"; + # cargoExtraArgs = "--locked"; cargoNextestExtraArgs = "-p ${crate} -j 1"; DNA_PATH = dna; diff --git a/nix/zome.nix b/nix/zome.nix index 4b7479a..2c94515 100644 --- a/nix/zome.nix +++ b/nix/zome.nix @@ -45,11 +45,13 @@ let commonArgs = { inherit src; doCheck = false; - strictDeps = true; CARGO_BUILD_TARGET = "wasm32-unknown-unknown"; pname = "workspace"; version = cargoToml.package.version; - cargoExtraArgs = "--workspace ${excludedCrates}"; + cargoBuildCommand = + "cargo build --release --locked --workspace ${excludedCrates}"; + cargoCheckCommand = ""; + cargoExtraArgs = ""; }; buildPackageCommonArgs = commonArgs // {