This commit is contained in:
병준 박 2025-04-17 08:58:02 +00:00
parent aca83283f1
commit 7dde9de9bf
2 changed files with 38 additions and 24 deletions

View File

@ -9,9 +9,13 @@ spec:
description: context directory description: context directory
default: "" default: ""
- name: targetProject - name: workspaceName
type: string 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 - name: nodejsImageName
type: string type: string
@ -48,21 +52,31 @@ spec:
echo "📦 Installing dependencies with pnpm" echo "📦 Installing dependencies with pnpm"
pnpm install --frozen-lockfile pnpm install --frozen-lockfile
echo "🔍 Running ESLint for project: $(params.targetProject)" coverage_dirs=()
pnpm nx lint $(params.targetProject) html_dirs=()
echo "🧪 Running Jest tests for project: $(params.targetProject) with coverage" for targetProject in "$@"; do
pnpm nx test $(params.targetProject) --code-coverage echo "🔍 Running ESLint for project: $targetProject"
pnpm nx lint $targetProject
COVERAGE_DIR="coverage/$(params.targetProject)" echo "🧪 Running Jest tests for project: $targetProject with coverage"
HTML_DIR="$COVERAGE_DIR/lcov-report" pnpm nx test $targetProject --code-coverage
echo "📁 Saving coverage path: $COVERAGE_DIR" COVERAGE_DIR="coverage/$targetProject"
echo -n "$COVERAGE_DIR" > /tekton/results/coverage-dir HTML_DIR="$COVERAGE_DIR/lcov-report"
echo -n "$HTML_DIR" > /tekton/results/coverage-html
if [ -d "$HTML_DIR" ]; then coverage_dirs+=("\"$COVERAGE_DIR\"")
echo "📄 HTML coverage report generated at $HTML_DIR" html_dirs+=("\"$HTML_DIR\"")
else
echo "⚠️ HTML coverage report not found" if [ -d "$HTML_DIR" ]; then
fi 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[*])"

View File

@ -8,7 +8,7 @@ spec:
type: string type: string
description: context directory description: context directory
default: "" default: ""
- name: targetProject - name: workspaceName
type: string type: string
description: Nx workspace project name to lint and test description: Nx workspace project name to lint and test
@ -40,16 +40,16 @@ spec:
FULL_REF="$(params.ref)" FULL_REF="$(params.ref)"
TAG_FROM_REF=$(basename "$FULL_REF") # → v0.2.0 TAG_FROM_REF=$(basename "$FULL_REF") # → v0.2.0
echo "📄 Reading version from package.json of $(params.targetProject)..." echo "📄 Reading version from package.json of $(params.workspaceName)..."
VERSION=$(node -p "require('./$(params.targetProject)/package.json').version") VERSION=$(node -p "require('./$(params.workspaceName)/package.json').version")
TAG_FROM_PROJECT="${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 " - 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 if [ "$TAG_FROM_REF" != "$TAG_FROM_WORKSPACE" ]; then
echo "❌ Mismatch! Git tag and project version are not the same." echo "❌ Mismatch! Git tag and workspace version are not the same."
exit 1 exit 1
fi fi