Skip to content

Commit 51e22f2

Browse files
committed
wip: github actions - nix
1 parent e5c0ceb commit 51e22f2

File tree

2 files changed

+108
-104
lines changed

2 files changed

+108
-104
lines changed

.github/workflows/cargo-test.yaml

+7-7
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ jobs:
5959
with:
6060
shared-key: "build" # share the cache across jobs
6161

62-
- uses: hoverkraft-tech/compose-action@v1.5.1
63-
with:
64-
compose-file: "./docker-compose.yaml"
65-
up-flags: "--pull=always --wait"
66-
down-flags: "--volumes"
67-
services: |
68-
bigquery
62+
# - uses: hoverkraft-tech/compose-action@v1.5.1
63+
# with:
64+
# compose-file: "./docker-compose.yaml"
65+
# up-flags: "--pull=always --wait"
66+
# down-flags: "--volumes"
67+
# services: |
68+
# bigquery
6969

7070
- name: run tests
7171
run: |

flake.nix

+101-97
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
{
2-
description = "PostgreSQL data connector";
2+
description = "BiiQuery data connector";
33

44
inputs = {
5-
nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
6-
flake-utils.url = github:numtide/flake-utils;
5+
nixpkgs.url = "github:NixOS/nixpkgs?branch=nixos-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
77

88
crane = {
99
url = "github:ipetkov/crane";
1010
inputs.nixpkgs.follows = "nixpkgs";
11-
inputs.rust-overlay.follows = "rust-overlay";
12-
inputs.flake-utils.follows = "flake-utils";
1311
};
1412

1513
rust-overlay = {
1614
url = "github:oxalica/rust-overlay";
1715
inputs = {
1816
nixpkgs.follows = "nixpkgs";
19-
flake-utils.follows = "flake-utils";
2017
};
2118
};
2219
};
@@ -29,79 +26,46 @@
2926
overlays = [ rust-overlay.overlays.default ];
3027
};
3128

32-
# Edit ./nix/ndc-agent.nix to adjust library and buildtime
33-
# dependencies or other build configuration for postgres-agent
34-
crateExpression = import ./nix/ndc-agent.nix;
35-
36-
# cockroachExpression = import ./nix/cockroach-agent.nix;
37-
cargoBuild = import ./nix/cargo-build.nix;
38-
39-
# create binaries for a given NDC
40-
make-binaries = (binary-name: {
41-
inherit binary-name;
29+
rust = import ./nix/rust.nix {
30+
inherit nixpkgs rust-overlay crane localSystem;
31+
};
32+
in
33+
{
34+
packages = {
4235
# a binary for whichever is the local computer
43-
local-system = cargoBuild {
44-
inherit binary-name crateExpression nixpkgs crane rust-overlay localSystem;
45-
};
36+
default = rust.callPackage ./nix/app.nix { };
37+
4638
# cross compiler an x86_64 linux binary
47-
x86_64-linux = cargoBuild {
48-
inherit binary-name crateExpression nixpkgs crane rust-overlay localSystem;
39+
x86_64-linux = (import ./nix/rust.nix {
40+
inherit nixpkgs rust-overlay crane localSystem;
4941
crossSystem = "x86_64-linux";
50-
};
42+
}).callPackage ./nix/app.nix
43+
{ };
5144
# cross compile a aarch64 linux binary
52-
aarch64-linux = cargoBuild {
53-
inherit binary-name crateExpression nixpkgs crane rust-overlay localSystem;
45+
aarch64-linux = (import ./nix/rust.nix {
46+
inherit nixpkgs rust-overlay crane localSystem;
5447
crossSystem = "aarch64-linux";
48+
}).callPackage ./nix/app.nix
49+
{ };
50+
51+
# docker for local system
52+
docker = pkgs.callPackage ./nix/docker.nix {
53+
package = self.packages.${localSystem}.default;
54+
image-name = "ghcr.io/hasura/ndc-bigquery";
55+
tag = "dev";
56+
};
57+
# docker for x86_64-linux
58+
docker-x86_64-linux = pkgs.callPackage ./nix/docker.nix {
59+
package = self.packages.${localSystem}.x86_64-linux;
60+
architecture = "amd64";
61+
image-name = "ghcr.io/hasura/ndc-bigquery-x86_64";
62+
};
63+
# docker for aarch64-linux
64+
docker-aarch64-linux = pkgs.callPackage ./nix/docker.nix {
65+
package = self.packages.${localSystem}.aarch64-linux;
66+
architecture = "arm64";
67+
image-name = "ghcr.io/hasura/ndc-bigquery-aarch64";
5568
};
56-
});
57-
58-
# given the binaries, return the flake targets that build Docker etc
59-
make-packages =
60-
(ndc-binaries:
61-
let name = ndc-binaries.binary-name; in {
62-
# binary compiled on local system
63-
"${name}" = ndc-binaries.local-system;
64-
# binary compiled for x86_64-linux
65-
"${name}-x86_64-linux" = ndc-binaries.x86_64-linux;
66-
# binary compiled for aarch64-linux
67-
"${name}-aarch64-linux" = ndc-binaries.aarch64-linux;
68-
# docker for local system
69-
"${name}-docker" = pkgs.callPackage ./nix/docker.nix {
70-
ndc-agent = ndc-binaries.local-system;
71-
binary-name = name;
72-
image-name = "ghcr.io/hasura/${name}";
73-
tag = "dev";
74-
};
75-
# docker for x86_64-linux
76-
"${name}-docker-x86_64-linux" = pkgs.callPackage ./nix/docker.nix {
77-
ndc-agent = ndc-binaries.x86_64-linux;
78-
architecture = "amd64";
79-
binary-name = name;
80-
image-name = "ghcr.io/hasura/${name}-x86_64";
81-
};
82-
# docker for aarch64-linux
83-
"${name}-docker-aarch64-linux" = pkgs.callPackage ./nix/docker.nix {
84-
ndc-agent = ndc-binaries.aarch64-linux;
85-
architecture = "arm64";
86-
binary-name = name;
87-
image-name = "ghcr.io/hasura/${name}-aarch64";
88-
};
89-
});
90-
91-
postgres-binaries = make-binaries "ndc-postgres";
92-
cockroach-binaries = make-binaries "ndc-cockroach";
93-
citus-binaries = make-binaries "ndc-citus";
94-
95-
inherit (postgres-binaries.local-system) cargoArtifacts rustToolchain craneLib buildArgs;
96-
97-
in
98-
{
99-
packages = builtins.foldl' (x: y: x // y) { } [
100-
(make-packages postgres-binaries)
101-
(make-packages cockroach-binaries)
102-
(make-packages citus-binaries)
103-
] // {
104-
default = postgres-binaries.local-system;
10569

10670
publish-docker-image = pkgs.writeShellApplication {
10771
name = "publish-docker-image";
@@ -110,35 +74,75 @@
11074
};
11175
};
11276

77+
apps = {
78+
default = self.apps.${localSystem}.connector;
79+
80+
connector = {
81+
type = "app";
82+
program = "${self.packages.${localSystem}.default}/bin/ndc-bigquery";
83+
};
84+
85+
cli = {
86+
type = "app";
87+
program = "${self.packages.${localSystem}.default}/bin/ndc-bigquery-cli";
88+
};
89+
};
90+
11391
checks = {
11492
# Build the crate as part of `nix flake check`
115-
ndc-postgres = postgres-binaries.local-system;
93+
ndc-bigquery = self.packages.${localSystem}.default;
11694
};
11795

11896
formatter = pkgs.nixpkgs-fmt;
11997

120-
devShells.default = pkgs.mkShell {
121-
inputsFrom = builtins.attrValues self.checks.${localSystem};
122-
nativeBuildInputs = [
123-
# runtime
124-
pkgs.protobuf
125-
126-
# development
127-
pkgs.cargo-edit
128-
pkgs.cargo-flamegraph
129-
pkgs.cargo-insta
130-
pkgs.cargo-machete
131-
pkgs.cargo-watch
132-
pkgs.just
133-
pkgs.k6
134-
pkgs.nixpkgs-fmt
135-
pkgs.nodePackages.prettier
136-
pkgs.pkg-config
137-
pkgs.rnix-lsp
138-
pkgs.skopeo
139-
pkgs.nodePackages.prettier
140-
rustToolchain
141-
];
98+
devShells = {
99+
default = pkgs.mkShell {
100+
# include dependencies of the default package
101+
inputsFrom = [ self.packages.${localSystem}.default ];
102+
103+
# build-time inputs
104+
nativeBuildInputs = [
105+
# Development
106+
pkgs.just
107+
pkgs.nixpkgs-fmt
108+
pkgs.nodePackages.prettier
109+
pkgs.moreutils
110+
111+
# Rust
112+
pkgs.bacon
113+
pkgs.cargo-audit
114+
pkgs.cargo-edit
115+
pkgs.cargo-expand
116+
pkgs.cargo-flamegraph
117+
pkgs.cargo-insta
118+
pkgs.cargo-machete
119+
pkgs.cargo-nextest
120+
pkgs.cargo-watch
121+
rust.rustToolchain
122+
123+
# Benchmarks
124+
pkgs.k6
125+
126+
# Deployment
127+
pkgs.skopeo
128+
];
129+
};
130+
} // pkgs.lib.attrsets.optionalAttrs pkgs.hostPlatform.isLinux {
131+
# This performance-testing shell will only work on Linux.
132+
perf = pkgs.mkShell {
133+
inputsFrom = [
134+
self.devShells.${localSystem}.default
135+
];
136+
137+
# build-time inputs
138+
nativeBuildInputs = [
139+
pkgs.heaptrack
140+
pkgs.linuxPackages_latest.perf
141+
pkgs.mold-wrapped
142+
pkgs.valgrind
143+
];
144+
};
142145
};
143-
});
146+
}
147+
);
144148
}

0 commit comments

Comments
 (0)