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 = '22.12.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 && " + "ruff check tests/ && " + "ruff format --check tests/ && " + "mypy tests/" } task pythonLintFix(type: Exec, dependsOn: installDev) { commandLine 'bash', '-c', "source ${venv_name}/bin/activate && set -x && " + "ruff check --fix tests/ && " + "ruff format tests/ && " + "mypy tests/" } /** * The following tasks assume an already running quickstart. * ./gradlew quickstart (or another variation `quickstartDebug`) */ // ./gradlew :smoke-test:pytest -PbatchNumber=2 (default 0) task pytest(type: Exec, dependsOn: [installDev, ':metadata-ingestion:installDev']) { // Get BATCH_NUMBER from command line argument with default value of 0 def batchNumber = project.hasProperty('batchNumber') ? project.property('batchNumber') : '0' environment 'RUN_QUICKSTART', 'false' environment 'TEST_STRATEGY', 'pytests' environment 'BATCH_COUNT', 3 environment 'BATCH_NUMBER', batchNumber workingDir = project.projectDir commandLine 'bash', '-c', "source ${venv_name}/bin/activate && set -x && " + "./smoke.sh" } // ./gradlew :smoke-test:cypressTest -PbatchNumber=2 (default 0) task cypressTest(type: Exec, dependsOn: [installDev, ':metadata-ingestion:installDev']) { // Get BATCH_NUMBER from command line argument with default value of 0 def batchNumber = project.hasProperty('batchNumber') ? project.property('batchNumber') : '0' environment 'RUN_QUICKSTART', 'false' environment 'TEST_STRATEGY', 'cypress' environment 'BATCH_COUNT', 11 environment 'BATCH_NUMBER', batchNumber 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 cypressRemote(type: Exec) { environment 'CYPRESS_BASE_URL', project.findProperty('baseUrl') ?: 'http://localhost:4173' environment 'CYPRESS_ADMIN_USERNAME', project.findProperty('username') ?: 'admin' environment 'CYPRESS_ADMIN_PASSWORD', project.findProperty('password') workingDir = "${project.rootDir}/smoke-test/tests/cypress" commandLine 'bash', '-c', './cypress-remote.sh' } task lint { dependsOn pythonLint, cypressLint } task lintFix { dependsOn pythonLintFix } task cleanPythonCache(type: Exec) { commandLine 'bash', '-c', "find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete -o -type d -empty -delete" } clean { delete venv_name delete 'build' delete 'dist' delete '.ruff_cache' delete '.mypy_cache' delete '.pytest_cache' } clean.dependsOn cleanPythonCache