diff --git a/tasks/nodejs-nx-analysis/task.yaml b/tasks/nodejs-nx-analysis/task.yaml index e5fe9c8..cdc06cd 100644 --- a/tasks/nodejs-nx-analysis/task.yaml +++ b/tasks/nodejs-nx-analysis/task.yaml @@ -9,9 +9,13 @@ spec: description: context directory default: "" - - name: targetProject + - name: workspaceName type: string - description: Nx workspace project name to lint and test + description: Nx workspace name to lint and test + + - name: targetProjects + type: array + description: Nx workspace project names to lint and test - name: nodejsImageName type: string @@ -48,21 +52,31 @@ spec: echo "๐Ÿ“ฆ Installing dependencies with pnpm" pnpm install --frozen-lockfile - echo "๐Ÿ” Running ESLint for project: $(params.targetProject)" - pnpm nx lint $(params.targetProject) + coverage_dirs=() + html_dirs=() - echo "๐Ÿงช Running Jest tests for project: $(params.targetProject) with coverage" - pnpm nx test $(params.targetProject) --code-coverage + for targetProject in "$@"; do + echo "๐Ÿ” Running ESLint for project: $targetProject" + pnpm nx lint $targetProject - COVERAGE_DIR="coverage/$(params.targetProject)" - HTML_DIR="$COVERAGE_DIR/lcov-report" + echo "๐Ÿงช Running Jest tests for project: $targetProject with coverage" + pnpm nx test $targetProject --code-coverage - echo "๐Ÿ“ Saving coverage path: $COVERAGE_DIR" - echo -n "$COVERAGE_DIR" > /tekton/results/coverage-dir - echo -n "$HTML_DIR" > /tekton/results/coverage-html + COVERAGE_DIR="coverage/$targetProject" + HTML_DIR="$COVERAGE_DIR/lcov-report" - if [ -d "$HTML_DIR" ]; then - echo "๐Ÿ“„ HTML coverage report generated at $HTML_DIR" - else - echo "โš ๏ธ HTML coverage report not found" - fi + coverage_dirs+=("\"$COVERAGE_DIR\"") + html_dirs+=("\"$HTML_DIR\"") + + if [ -d "$HTML_DIR" ]; then + echo "๐Ÿ“„ HTML coverage report generated at $HTML_DIR" + else + echo "โš ๏ธ HTML coverage report not found" + fi + done + + echo -n "[${coverage_dirs[*]}]" > /tekton/results/coverage-dir + echo -n "[${html_dirs[*]}]" > /tekton/results/coverage-html + + args: + - "$(params.targetProjects[*])" \ No newline at end of file diff --git a/tasks/nodejs-nx-version/task.yaml b/tasks/nodejs-nx-version/task.yaml index dafb013..a1152dd 100644 --- a/tasks/nodejs-nx-version/task.yaml +++ b/tasks/nodejs-nx-version/task.yaml @@ -8,7 +8,7 @@ spec: type: string description: context directory default: "" - - name: targetProject + - name: workspaceName type: string description: Nx workspace project name to lint and test @@ -40,16 +40,16 @@ spec: FULL_REF="$(params.ref)" TAG_FROM_REF=$(basename "$FULL_REF") # โ†’ v0.2.0 - echo "๐Ÿ“„ Reading version from package.json of $(params.targetProject)..." - VERSION=$(node -p "require('./$(params.targetProject)/package.json').version") - TAG_FROM_PROJECT="${VERSION}" + echo "๐Ÿ“„ Reading version from package.json of $(params.workspaceName)..." + VERSION=$(node -p "require('./$(params.workspaceName)/package.json').version") + TAG_FROM_WORKSPACE="${VERSION}" - echo "๐Ÿ” Comparing Git tag and project version:" + echo "๐Ÿ” Comparing Git tag and workspace version:" echo " - Git ref tag: $TAG_FROM_REF" - echo " - Project version: $TAG_FROM_PROJECT" + echo " - Workspace version: $TAG_FROM_WORKSPACE" - if [ "$TAG_FROM_REF" != "$TAG_FROM_PROJECT" ]; then - echo "โŒ Mismatch! Git tag and project version are not the same." + if [ "$TAG_FROM_REF" != "$TAG_FROM_WORKSPACE" ]; then + echo "โŒ Mismatch! Git tag and workspace version are not the same." exit 1 fi