From 5cd7bbb02101295af80f52e8e4b0652ae4e86c39 Mon Sep 17 00:00:00 2001 From: Volker Schukai <volker.schukai@schukai.com> Date: Wed, 15 May 2024 11:43:06 +0200 Subject: [PATCH] fix: wip web tests --- flake.nix | 4 ++-- nix/scripts/run-ci-tests.nix | 3 --- nix/scripts/run-ci-web-tests.nix | 36 ++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 nix/scripts/run-ci-web-tests.nix diff --git a/flake.nix b/flake.nix index f4ef6a14c..d48e89c66 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 1a086977c..260081453 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 000000000..20a366efa --- /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 + + + '' -- GitLab