diff --git a/flake.nix b/flake.nix index f4ef6a14c54816c555c6121a034d6d003670a859..d48e89c66de309d70fac91e4d10423e4789d3d39 100644 --- a/flake.nix +++ b/flake.nix @@ -106,13 +106,13 @@ gitlab = let ciJobToken = builtins.getEnv "CI_JOB_TOKEN"; script-run-ci-tests = pkgs'.callPackage ./nix/scripts/run-ci-tests.nix {}; - script-run-web-tests = pkgs'.callPackage ./nix/scripts/run-web-tests.nix {}; + script-run-ci-web-tests = pkgs'.callPackage ./nix/scripts/run-ci-web-tests.nix {}; gitlabPackages = with pkgs';[ nodejs_21 git script-run-ci-tests - script-run-web-tests + script-run-ci-web-tests ]; in pkgs'.mkShell { diff --git a/nix/scripts/run-ci-tests.nix b/nix/scripts/run-ci-tests.nix index 1a086977ce9c10355e5f4acf396554328be48ed7..260081453a3556d97b59d47f13187ca304e11d54 100644 --- a/nix/scripts/run-ci-tests.nix +++ b/nix/scripts/run-ci-tests.nix @@ -10,9 +10,6 @@ exit 1 fi - set -x - ${pkgs.coreutils}/bin/printenv - cd ''${CI_PROJECT_DIR} || exit 1 echo "This script will run tests in the project working directory: ''${CI_PROJECT_DIR}" diff --git a/nix/scripts/run-ci-web-tests.nix b/nix/scripts/run-ci-web-tests.nix new file mode 100644 index 0000000000000000000000000000000000000000..20a366efadb7117fe6b06d27447b29945bb565d0 --- /dev/null +++ b/nix/scripts/run-ci-web-tests.nix @@ -0,0 +1,36 @@ +{ + pkgs, + lib, + ... +}: let +in + pkgs.writeShellScriptBin "run-web-tests" '' + echo "run ci web tests" + + if [ -z "''${CI_JOB_TOKEN}" ]; then + echo "You are in a CI environment, this shell is not intended for CI, but for local development" + exit 1 + fi + + cd ''${CI_PROJECT_DIR} || exit 1 + + echo "This script will run tests in the project working directory: ''${CI_PROJECT_DIR}" + echo "The command is executed in the current working directory and not in a nix derivation." + + TEST_CASES_PATH="''${CI_PROJECT_DIR}/test/web/" + + if ! ${pkgs.corepack}/bin/pnpm install + then + echo "Failed to install dependencies" + exit 1 + fi + + if ! ${pkgs.nodejs_21}/bin/node "''${TEST_CASES_PATH}/puppeteer.mjs" --browser ${pkgs.ungoogled-chromium}/bin/chromium --path "''${TEST_CASES_PATH}/test.html" + then + echo_fail "Tests failed, check your JS!" + exit 1 + fi + exit 0 + + + ''