diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index a188cd3195..7f2e9e2ad0 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,8 +1,9 @@ # DEVOPS -/.github/action/nix-common-setup* @input-output-hk/jormungandr-devops -/.github/workflows/nix.yml @input-output-hk/jormungandr-devops -/default.nix @input-output-hk/jormungandr-devops -/flake.lock @input-output-hk/jormungandr-devops -/flake.nix @input-output-hk/jormungandr-devops -/shell.nix @input-output-hk/jormungandr-devops +/.github/action/nix-common-setup* @input-output-hk/jormungandr-devops +/.github/workflows/nix.yml @input-output-hk/jormungandr-devops +/.github/workflows/update-flake-lock.yml @input-output-hk/jormungandr-devops +/default.nix @input-output-hk/jormungandr-devops +/flake.lock @input-output-hk/jormungandr-devops +/flake.nix @input-output-hk/jormungandr-devops +/shell.nix @input-output-hk/jormungandr-devops diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index dadb941e59..8838ce67b0 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -1,4 +1,4 @@ -name: Nix +name: Nix CI on: push: branches: @@ -7,47 +7,63 @@ on: pull_request: jobs: - build-jormungandr: - name: Build jormungandr + decision: + name: Decide what we need to build runs-on: ubuntu-latest + + outputs: + packages: ${{ steps.packages.outputs.packages }} + steps: - name: Checkout uses: actions/checkout@v3 + - name: Setup uses: ./.github/actions/nix-common-setup with: CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }} - - name: Flake check - run: nix flake check - - name: Build - run: nix build .#jormungandr + + - name: Packages + id: packages + run: | + packages=$(nix eval .#packages.x86_64-linux --apply builtins.attrNames --json) + echo "PACKAGES -> $packages" + echo "::set-output name=packages::$packages" build: - name: Build ${{ matrix.package }} - needs: build-jormungandr + name: Build ${{ matrix.package }} package + needs: + - decision + runs-on: ubuntu-latest + strategy: fail-fast: false matrix: - package: - - "jormungandr-entrypoint" - - "jormungandr-lib" - - "jcli" - - "explorer" - - "modules/settings" - - "modules/blockchain" - - "testing/jormungandr-automation" - - "testing/jormungandr-integration-tests" - - "testing/loki" - - "testing/mjolnir" - - "testing/hersir" - - "testing/thor" - runs-on: ubuntu-latest + package: ${{ fromJSON(needs.decision.outputs.packages) }} + exclude: + - package: default + steps: + - name: Checkout uses: actions/checkout@v3 + - name: Setup uses: ./.github/actions/nix-common-setup with: CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }} - - name: Build - run: nix build .#${{ matrix.package }} + + - name: Build package + run: | + path=$(nix eval --raw .#packages.x86_64-linux.${{ matrix.package }}) + hash=${path:11:32} + url="https://iog.cachix.org/$hash.narinfo"; + if curl --output /dev/null --silent --head --fail "$url"; then + echo "Nothing to build!!!" + echo "" + echo "See build log with:" + echo " nix log $path" + echo "" + else + nix build .#packages.x86_64-linux.${{ matrix.package }} --show-trace -L + fi diff --git a/flake.lock b/flake.lock index 573b8dffa4..3c3120c35e 100644 --- a/flake.lock +++ b/flake.lock @@ -31,26 +31,6 @@ "type": "github" } }, - "gitignore": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1660459072, - "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "gitignore.nix", - "type": "github" - } - }, "naersk": { "inputs": { "nixpkgs": [ @@ -114,7 +94,6 @@ "inputs": { "flake-compat": "flake-compat", "flake-utils": "flake-utils", - "gitignore": "gitignore", "naersk": "naersk", "nixpkgs": "nixpkgs", "pre-commit-hooks": "pre-commit-hooks", diff --git a/flake.nix b/flake.nix index 1f3af0f2f0..95f43895b5 100644 --- a/flake.nix +++ b/flake.nix @@ -12,8 +12,6 @@ inputs.flake-compat.url = "github:edolstra/flake-compat"; inputs.flake-compat.flake = false; inputs.flake-utils.url = "github:numtide/flake-utils"; - inputs.gitignore.url = "github:hercules-ci/gitignore.nix"; - inputs.gitignore.inputs.nixpkgs.follows = "nixpkgs"; inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix"; inputs.pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs"; inputs.pre-commit-hooks.inputs.flake-utils.follows = "flake-utils"; @@ -28,7 +26,6 @@ nixpkgs, flake-compat, flake-utils, - gitignore, pre-commit-hooks, rust-overlay, naersk, @@ -78,12 +75,20 @@ rust-stable = mkRust {channel = "stable";}; rust-nightly = mkRust {channel = "nightly";}; - naersk-lib = naersk.lib."${system}".override { + naersk-lib-stable = naersk.lib."${system}".override { cargo = rust-stable; rustc = rust-stable; }; - mkPackage = name: let + naersk-lib-nighlty = naersk.lib."${system}".override { + cargo = rust-nightly; + rustc = rust-nightly; + }; + + mkPackage = { + naersk-lib ? naersk-lib-stable, + name, + }: let pkgCargo = readTOML ./${name}/Cargo.toml; cargoOptions = [ @@ -98,7 +103,7 @@ naersk-lib.buildPackage { inherit (pkgCargo.package) name version; - root = gitignore.lib.gitignoreSource self; + root = self; cargoBuildOptions = x: x ++ cargoOptions; cargoTestOptions = x: x ++ cargoOptions; @@ -123,7 +128,21 @@ builtins.map (name: { inherit name; - value = mkPackage name; + value = mkPackage {inherit name;}; + }) + workspaceCargo.workspace.members + ); + + workspace-nightly = + builtins.listToAttrs + ( + builtins.map + (name: { + name = "nightly-${name}"; + value = mkPackage { + inherit name; + naersk-lib = naersk-lib-nighlty; + }; }) workspaceCargo.workspace.members ); @@ -240,8 +259,9 @@ in rec { packages = workspace + // workspace-nightly // { - inherit jormungandr-entrypoint; + inherit jormungandr-entrypoint pre-commit; default = workspace.jormungandr; };