Skip to content

Commit

Permalink
ci: add flake for local testing
Browse files Browse the repository at this point in the history
  • Loading branch information
tboerger committed Aug 8, 2023
1 parent 42a9138 commit 37e8cc0
Show file tree
Hide file tree
Showing 4 changed files with 361 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
__pycache__/
*.py[cod]
*$py.class

# ---> Flake
.direnv/
256 changes: 256 additions & 0 deletions flake.lock

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

101 changes: 101 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
description = "Description for the project";

inputs = {
nixpkgs = {
url = "github:NixOS/nixpkgs/nixos-unstable";
};

pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
};

devshell = {
url = "github:numtide/devshell";
};

moleculepkgs = {
url = "github:dawidd6/nixpkgs/molecule";
};
};

outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.pre-commit-hooks.flakeModule
inputs.devshell.flakeModule
];

systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];

perSystem = { config, self', inputs', pkgs, system, ... }:
let
molecule-plugins = inputs.moleculepkgs.legacyPackages.${system}.python3Packages.molecule-plugins;
molecule = inputs.moleculepkgs.legacyPackages.${system}.molecule;

python310 = pkgs.python310.withPackages (p: with p; [
pytest
pytest-testinfra
molecule
molecule-plugins
]);

in
{
pre-commit = {
check = {
enable = true;
};

settings = {
hooks = {
later = {
enable = true;
name = "ansible-later";
description = "Run ansible-later on all files in the project";
files = "\\.(yml|yaml)$";
entry = "${pkgs.ansible-later}/bin/ansible-later";
};
};
};
};

devshells = {
default = {
commands = [
{
name = "later";
help = "execute later command";
command = "${pkgs.ansible-later}/bin/ansible-later";
}
{
name = "doctor";
help = "execute doctor command";
command = "${pkgs.ansible-doctor}/bin/ansible-doctor -fv";
}
{
name = "testing";
help = "execute molecule command";
command = "${molecule}/bin/molecule test --scenario-name default";
}
];

packages = with pkgs; [
ansible
ansible-doctor
ansible-lint
ansible-later

molecule
python310
];
};
};
};
};
}
2 changes: 1 addition & 1 deletion molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependency:
ANSIBLE_GALAXY_DISPLAY_PROGRESS: "false"

driver:
name: docker
name: containers

platforms:
- name: mariadb-ubuntu-22
Expand Down

0 comments on commit 37e8cc0

Please sign in to comment.