Files
media-map/nix/test-vm.nix
Danilo Reyes 4709a05ad4
Some checks failed
Test Suite / test (push) Failing after 16s
Refactor CI/CD workflow to utilize NixOS VM for testing
- Changed the CI workflow to run tests inside a NixOS virtual machine instead of directly on the runner.
- Updated the NixOS VM configuration to include necessary dependencies and services for testing.
- Added a script to handle test execution within the VM, including setup for Python and Node.js environments.
- Implemented SSH access to the VM for remote operations and streamlined the process of starting and stopping the VM during tests.
- Enhanced the workflow to build the VM and copy the codebase for testing, ensuring a more isolated and consistent testing environment.
2025-12-28 22:53:25 -06:00

93 lines
1.9 KiB
Nix

# NixOS VM configuration for testing Movie Map in CI/CD
# This VM includes all dependencies needed for testing
# Usage: nixos-rebuild build-vm -I nixos-config=./nix/test-vm.nix
{ config, pkgs, lib, ... }:
{
imports = [
<nixpkgs/nixos/modules/virtualisation/qemu-vm.nix>
];
# VM-specific configuration
virtualisation = {
memorySize = 2048; # 2GB RAM
cores = 2;
graphics = false; # Headless
};
networking = {
hostName = "moviemap-test-vm";
firewall = {
enable = true;
allowedTCPPorts = [
8080 # Movie Map backend
5432 # PostgreSQL
22 # SSH
];
};
};
# Enable SSH for remote access
services.openssh = {
enable = true;
settings = {
PermitRootLogin = "yes";
PasswordAuthentication = true;
};
};
# Set root password for SSH access
users.users.root.password = "test";
# PostgreSQL configuration
services.postgresql = {
enable = true;
ensureDatabases = [ "moviemap_test" ];
ensureUsers = [
{
name = "moviemap";
ensureDBOwnership = true;
}
];
authentication = ''
local all all trust
host all all 0.0.0.0/0 trust
'';
settings = {
listen_addresses = "'*'";
};
};
# Python and Node.js for testing
environment.systemPackages = with pkgs; [
python3
python3Packages.pip
nodejs_20
nodePackages.npm
postgresql
curl
jq
git
vim
# Testing tools
python3Packages.pytest
python3Packages.pytest-asyncio
python3Packages.pytest-cov
python3Packages.httpx
];
# Create a test user
users.users.test = {
isNormalUser = true;
extraGroups = [ "wheel" ];
password = "test";
openssh.authorizedKeys.keys = [];
};
# Allow passwordless sudo for test user
security.sudo.wheelNeedsPassword = false;
# System configuration
system.stateVersion = "23.11";
}