Skip to content

Commit

Permalink
Removing gitignore.nix flake input since it is not needed (#4099)
Browse files Browse the repository at this point in the history
* Removing gitignore.nix flake input since it is not needed

* also update CODEOWNERS

* build packages in parallel
  • Loading branch information
garbas authored Sep 22, 2022
1 parent 0cf275c commit e58b525
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 60 deletions.
13 changes: 7 additions & 6 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -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
66 changes: 41 additions & 25 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Nix
name: Nix CI
on:
push:
branches:
Expand All @@ -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
21 changes: 0 additions & 21 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 28 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -28,7 +26,6 @@
nixpkgs,
flake-compat,
flake-utils,
gitignore,
pre-commit-hooks,
rust-overlay,
naersk,
Expand Down Expand Up @@ -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 =
[
Expand All @@ -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;
Expand All @@ -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
);
Expand Down Expand Up @@ -240,8 +259,9 @@
in rec {
packages =
workspace
// workspace-nightly
// {
inherit jormungandr-entrypoint;
inherit jormungandr-entrypoint pre-commit;
default = workspace.jormungandr;
};

Expand Down

0 comments on commit e58b525

Please sign in to comment.