This is Tuleap 16.4.99.10
[tuleap.git] / tests / actions.groovy
blobfd2a36c0952b68a4b90ae232d246ace64292ce9f
1 #!/usr/bin/env groovy
3 def runInsideNixShell(String command, String tool_flavor = 'build') {
4 sh """
5 nix-shell -I nixpkgs="\$(pwd)/tools/utils/nix/pinned-nixpkgs.nix" "\$(pwd)/tools/utils/nix/${tool_flavor}-tools/" --run "${command}"
6 """
9 def prepareSources(String prepare_flavor) {
10 runInsideNixShell("tools/utils/scripts/generated-files-builder.sh ${prepare_flavor}")
13 def runFilesStatusChangesDetection(String repository_to_inspect, String name_of_verified_files, String verified_files) {
14 dir ('sources') {
15 sh "tests/files_status_checker/verify.sh '${repository_to_inspect}' '${name_of_verified_files}' ${verified_files}"
19 def runPHPUnitTests(String version, Boolean with_coverage = false) {
20 def coverage_enabled='0'
21 if (with_coverage) {
22 coverage_enabled='1'
24 sh "make -C $WORKSPACE/sources phpunit-ci PHP_VERSION=${version} COVERAGE_ENABLED=${coverage_enabled}"
27 def runJSUnitTests(Boolean with_coverage = false) {
28 def coverage_env=''
29 if (with_coverage) {
30 coverage_env='COLLECT_COVERAGE=true'
32 sh("mkdir -p ${WORKSPACE}/results/")
33 dir ('sources') {
34 runInsideNixShell("${coverage_env} lib/frontend/build-system-configurator/bin/run-js-units-ci.sh")
38 def runRESTTests(String db, String php) {
39 sh """
40 mkdir -p \$WORKSPACE/results/api-rest/php${php}-${db}
41 TESTS_RESULT=\$WORKSPACE/results/api-rest/php${php}-${db} sources/tests/rest/bin/run-compose.sh "${php}" "${db}"
42 """
45 def runDBTests(String db, String php) {
46 sh """
47 mkdir -p \$WORKSPACE/results/db/php${php}-${db}
48 TESTS_RESULT=\$WORKSPACE/results/db/php${php}-${db} sources/tests/integration/bin/run-compose.sh "${php}" "${db}"
49 """
52 def runEndToEndTests(String flavor, String db) {
53 dir ('sources') {
54 sh "tests/e2e/${flavor}/wrap.sh '${db}' '$WORKSPACE/results/e2e/${flavor}/'"
58 def runBuildAndRun(String os) {
59 dir ('sources') {
60 sh "OS='${os}' tests/build_and_run/test.sh"
64 def runESLint() {
65 sh("mkdir -p ${WORKSPACE}/results/eslint/")
66 dir ('sources') {
67 runInsideNixShell("pnpm run eslint --quiet --format=checkstyle --output-file=${WORKSPACE}/results/eslint/checkstyle.xml .")
71 def runStylelint() {
72 dir ('sources') {
73 runInsideNixShell('pnpm run stylelint **/*.scss **/*.vue')
77 def runTabFilesCheck() {
78 dir ('sources') {
79 runInsideNixShell('src/utils/analyse_language_files.pl ./')
83 def runPsalm(String configPath, String root='.') {
84 withEnv(['XDG_CACHE_HOME=/tmp/psalm_cache/']) {
85 dir ('sources') {
86 sh """
87 mkdir -p ../results/psalm/
88 scl enable php82 "src/vendor/bin/psalm --find-unused-code --show-info=false --report-show-info=false --config='${configPath}' --no-cache --root='${root}' --report=../results/psalm/checkstyle.xml"
89 """
94 def runPsalmTaintAnalysis(String configPath, String root='.') {
95 withEnv(['XDG_CACHE_HOME=/tmp/psalm_cache/']) {
96 dir ('sources') {
97 sh """
98 mkdir -p ../results/psalm/
99 scl enable php82 "src/vendor/bin/psalm --taint-analysis --memory-limit=4096M --threads=1 --config='${configPath}' --no-cache --root='${root}' --report=../results/psalm/checkstyle.xml"
105 def runPHPCodingStandards(String phpcsPath, String rulesetPath, String filesToAnalyze) {
106 if (filesToAnalyze == '') {
107 return;
109 sh """
110 docker run --rm -v $WORKSPACE/sources:/sources:ro -w /sources --network none \${DOCKER_REGISTRY:-ghcr.io}/enalean/tuleap-test-phpunit:el9-php82 \
111 scl enable php82 "php -d memory_limit=2536M ${phpcsPath} --extensions=php,phpstub --encoding=utf-8 --standard="${rulesetPath}" -p ${filesToAnalyze}"
115 def runDeptrac() {
116 dir ('sources') {
117 sh """
118 export CI_REPORT_OUTPUT_PATH="\$WORKSPACE/results/deptrac/"
119 mkdir -p "\$CI_REPORT_OUTPUT_PATH"
120 scl enable php82 "./tests/deptrac/run.sh"
125 return this;