Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OPS-1384] Introduce NixOS VM tests #264

Merged
merged 1 commit into from
Mar 29, 2024

Conversation

Sereja313
Copy link
Member

Problem: Currently, the only way to test deploy-rs deployments is to actually do a deployment to an existing NixOS instance (either in VM, or a real machine) manually. This is a bit inconvenient and one can forget to test changes when developing/reviewing deploy-rs changes.

Solution: Add NixOS VM tests.

@Sereja313 Sereja313 force-pushed the sereja/OPS-1384-add-nixos-vm-test branch from 064e305 to b8fd011 Compare March 27, 2024 09:33
@Sereja313 Sereja313 requested a review from rvem March 27, 2024 09:36
};

flake = builtins.toFile "flake.nix" ''
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is a .nix file embedded in another .nix file 😅

Will it be viable to extract it as a dedicated .nix file that consumes inputs as an import argument to simplify its editing in the future?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, nix will attempt to eval the entire file that is intended to be evaluated during the test. Substituting the inputs block seems to me the simplest solution.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough

server.succeed("su ${user} -l -c 'hello | figlet' >&2")
'';
};
in {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had some issues with options overriding in the past (see #197, #218), so it would be nice to extend tests to ensure that cmd line options work as expected and do actually override corresponding options from the flake

let
inherit (pkgs) system lib;

privateKey = pkgs.writeText "privateKey" ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to ignore my nitpick, but nixpkgs has snakeOil keypair that is used in NixOS tests within the nixpkgs repo, perhaps we can reuse it instead of using newly generated key

- name: check flake
run: nix flake check -L
- name: deploy-rs
run: nix build -L .#checks.x86_64-linux.deploy-rs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another nitpick, but at this point, it becomes a bit tedious to enumerate all checks (given that I also propose to extend the list of tests a bit), so perhaps, it's time to use a build-matrix instead

@Sereja313 Sereja313 requested a review from rvem March 28, 2024 18:23
Problem: Currently, the only way to test deploy-rs deployments is to
actually do a deployment to an existing NixOS instance (either in VM,
or a real machine) manually. This is a bit inconvenient and one can
forget to test changes when developing/reviewing deploy-rs changes.

Solution: Add NixOS VM tests.
@Sereja313 Sereja313 force-pushed the sereja/OPS-1384-add-nixos-vm-test branch from a096697 to a928352 Compare March 29, 2024 17:25
@Sereja313 Sereja313 merged commit 2bad218 into master Mar 29, 2024
6 checks passed
@delete-merged-branch delete-merged-branch bot deleted the sereja/OPS-1384-add-nixos-vm-test branch March 29, 2024 17:29
Sereja313 added a commit that referenced this pull request Apr 1, 2024
Problem: In my recent PR(#264), I accidentally picked overlay output
changes from the philtaken/nixos-vm-tests branch, which broke existing
overlay imports after updating the deployment-rs input.

Solution: Add backwards compatibility so that users don't have to make
changes to their nix flakes.
@Sereja313 Sereja313 mentioned this pull request Apr 1, 2024
Sereja313 added a commit that referenced this pull request Apr 1, 2024
Problem: In my recent PR(#264), I accidentally picked overlay output
changes from the philtaken/nixos-vm-tests branch, which broke existing
overlay imports after updating the deploy-rs input.

Solution: Add backwards compatibility so that users don't have to make
changes to their nix flakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants