{
  pkgs,
  lib,
  ...
}: pkgs.writeShellScriptBin "run-ci-tests" ''
    echo "run ci 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
    
    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}"
    echo "The command is executed in the current working directory and not in a nix derivation."

    TEST_CASES_PATH="''${CI_PROJECT_DIR}/test/cases/"
    
    if ! ${pkgs.corepack}/bin/pnpm install
    then
       echo "Failed to install dependencies"
       exit 1
    fi

    if ! ${pkgs.nodePackages.mocha}/bin/mocha --colors --jobs 1 --bail --recursive ''${TEST_CASES_PATH}
    then
       echo "Tests failed, check your JS!"
       exit 1
    fi

    echo "Tests passed!"

  ''