apply plugin: 'com.github.node-gradle.node' ext { python_executable = 'python3' venv_name = 'venv' } node { // If true, it will download node using above parameters. // If false, it will try to use globally installed node. if (project.hasProperty('useSystemNode') && project.getProperty('useSystemNode').toBoolean()) { download = false } else { download = true } // Version of node to use. version = '21.2.0' // Version of Yarn to use. yarnVersion = '1.22.22' // Base URL for fetching node distributions (set nodeDistBaseUrl if you have a mirror). if (project.hasProperty('nodeDistBaseUrl')) { distBaseUrl = project.getProperty('nodeDistBaseUrl') } else { distBaseUrl = 'https://nodejs.org/dist' } // Set the work directory for unpacking node workDir = file("${project.projectDir}/.gradle/nodejs") // Set the work directory for NPM yarnWorkDir = file("${project.projectDir}/.gradle/yarn") // Set the work directory where node_modules should be located nodeProjectDir = file("${project.projectDir}") } task yarnInstall(type: YarnTask) { println "Root directory: ${project.rootDir}"; environment = ['NODE_OPTIONS': '--openssl-legacy-provider'] args = ['install', '--network-timeout', '300000', '--cwd', "${project.rootDir}/smoke-test/tests/cypress"] } task cypressLint(type: YarnTask, dependsOn: yarnInstall) { environment = ['NODE_OPTIONS': '--openssl-legacy-provider'] // TODO: Run a full lint instead of just format. args = ['--cwd', "${project.rootDir}/smoke-test/tests/cypress", 'run', 'format'] } task cypressLintFix(type: YarnTask, dependsOn: yarnInstall) { environment = ['NODE_OPTIONS': '--openssl-legacy-provider'] // TODO: Run a full lint instead of just format. args = ['--cwd', "${project.rootDir}/smoke-test/tests/cypress", 'run', 'format', '--write'] } task installDev(type: Exec) { inputs.file file('pyproject.toml') inputs.file file('requirements.txt') outputs.file("${venv_name}/.build_install_dev_sentinel") commandLine 'bash', '-c', "set -x && " + "${python_executable} -m venv ${venv_name} && " + "${venv_name}/bin/python -m pip install --upgrade uv && " + "set +x && source ${venv_name}/bin/activate && set -x && " + "uv pip install -r requirements.txt && " + "touch ${venv_name}/.build_install_dev_sentinel" } task pythonLint(type: Exec, dependsOn: installDev) { commandLine 'bash', '-c', "source ${venv_name}/bin/activate && set -x && " + "black --check --diff tests/ && " + "isort --check --diff tests/ && " + "ruff --statistics tests/ && " + "mypy tests/" } task pythonLintFix(type: Exec, dependsOn: installDev) { commandLine 'bash', '-c', "source ${venv_name}/bin/activate && set -x && " + "black tests/ && " + "isort tests/ && " + "ruff --fix tests/ && " + "mypy tests/" } /** * The following tasks assume an already running quickstart. * ./gradlew quickstart (or another variation `quickstartDebug`) */ task noCypressSuite0(type: Exec, dependsOn: [installDev, ':metadata-ingestion:installDev']) { environment 'RUN_QUICKSTART', 'false' environment 'TEST_STRATEGY', 'no_cypress_suite0' workingDir = project.projectDir commandLine 'bash', '-c', "source ${venv_name}/bin/activate && set -x && " + "./smoke.sh" } task noCypressSuite1(type: Exec, dependsOn: [installDev, ':metadata-ingestion:installDev']) { environment 'RUN_QUICKSTART', 'false' environment 'TEST_STRATEGY', 'no_cypress_suite1' workingDir = project.projectDir commandLine 'bash', '-c', "source ${venv_name}/bin/activate && set -x && " + "./smoke.sh" } task cypressSuite1(type: Exec, dependsOn: [installDev, ':metadata-ingestion:installDev']) { environment 'RUN_QUICKSTART', 'false' environment 'TEST_STRATEGY', 'cypress_suite1' workingDir = project.projectDir commandLine 'bash', '-c', "source ${venv_name}/bin/activate && set -x && " + "./smoke.sh" } task cypressRest(type: Exec, dependsOn: [installDev, ':metadata-ingestion:installDev']) { environment 'RUN_QUICKSTART', 'false' environment 'TEST_STRATEGY', 'cypress_rest' workingDir = project.projectDir commandLine 'bash', '-c', "source ${venv_name}/bin/activate && set -x && " + "./smoke.sh" } /** * The following will run Cypress in interactive mode against an already running stack. */ task cypressDev(type: Exec, dependsOn: [installDev, ':metadata-ingestion:installDev']) { environment 'RUN_QUICKSTART', 'false' workingDir = project.projectDir commandLine 'bash', '-c', "source ${venv_name}/bin/activate && set -x && " + "./cypress-dev.sh" } /** * The following will install Cypress data in an already running stack. */ task cypressData(type: Exec, dependsOn: [installDev, ':metadata-ingestion:installDev']) { environment 'RUN_QUICKSTART', 'false' environment 'RUN_UI', 'false' workingDir = project.projectDir commandLine 'bash', '-c', "source ${venv_name}/bin/activate && set -x && " + "./cypress-dev.sh" } task lint { dependsOn pythonLint, cypressLint } task lintFix { dependsOn pythonLintFix }