Skip to content

Commit

Permalink
fix: Move test to example
Browse files Browse the repository at this point in the history
  • Loading branch information
leomayleomay committed Jun 23, 2024
1 parent 109a6db commit 079ba71
Show file tree
Hide file tree
Showing 11 changed files with 161 additions and 26 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
# created when `just run <service>` is used
/test/data

/nix/cargo-doc-live/target

# created when `just run ex-*` is used
/example/share-services/pgweb/data/
/example/simple/data/
/example/grafana-tempo/data/
/example/cargo-doc-live/target

/.pre-commit-config.yaml

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

2 changes: 2 additions & 0 deletions example/cargo-doc-live/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[package]
name = "test"
106 changes: 106 additions & 0 deletions example/cargo-doc-live/flake.lock

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

44 changes: 44 additions & 0 deletions example/cargo-doc-live/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
systems.url = "github:nix-systems/default";
process-compose-flake.url = "github:Platonic-Systems/process-compose-flake";
services-flake.url = "github:juspay/services-flake";
};
outputs = inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = import inputs.systems;
imports = [
inputs.process-compose-flake.flakeModule
];
perSystem = { self', pkgs, lib, ... }: {
# `process-compose.foo` will add a flake package output called "foo".
# Therefore, this will add a default package that you can build using
# `nix build` and run using `nix run`.
process-compose."default" = { ... }:
{
imports = [
inputs.services-flake.processComposeModules.default
];

services.cargo-doc-live."cargo-doc-live1" = {
src = ./.;
enable = true;
port = 8009;
};

settings.processes.test = {
command = pkgs.writeShellApplication {
name = "cargo-doc-live-test";
runtimeInputs = [ pkgs.curl ];
text = ''
curl http://127.0.0.1:8009/test
'';
};
depends_on."cargo-doc-live1".condition = "process_healthy";
};
};
};
};
}
File renamed without changes.
7 changes: 6 additions & 1 deletion nix/cargo-doc-live/default.nix → nix/cargo-doc-live.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ in
options = {
enable = lib.mkEnableOption name;

src = lib.mkOption {
type = types.path;
description = "The src of the cargo";
};

port = lib.mkOption {
type = types.port;
description = "The port for 'cargo doc'";
Expand All @@ -16,7 +21,7 @@ in
type = types.str;
description = "The crate to use when opening docs in browser";
default = builtins.replaceStrings [ "-" ] [ "_" ]
((lib.trivial.importTOML ./Cargo.toml).package.name);
((lib.trivial.importTOML "${config.src}/Cargo.toml").package.name);
defaultText = "The crate name is derived from the Cargo.toml file";
};

Expand Down
2 changes: 0 additions & 2 deletions nix/cargo-doc-live/Cargo.toml

This file was deleted.

18 changes: 0 additions & 18 deletions nix/cargo-doc-live/cargo-doc-live_test.nix

This file was deleted.

2 changes: 1 addition & 1 deletion nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ in
./tempo.nix
./weaviate.nix
./searxng.nix
./cargo-doc-live
./cargo-doc-live.nix
];
}
1 change: 0 additions & 1 deletion test/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"${inputs.services-flake}/nix/cassandra_test.nix"
"${inputs.services-flake}/nix/tempo_test.nix"
"${inputs.services-flake}/nix/weaviate_test.nix"
"${inputs.services-flake}/nix/cargo-doc-live/cargo-doc-live_test.nix"
] ++ lib.optionals pkgs.stdenv.isLinux [
# Broken on Darwin: https://github.com/NixOS/nixpkgs/issues/316954
"${inputs.services-flake}/nix/grafana_test.nix"
Expand Down

0 comments on commit 079ba71

Please sign in to comment.