init
This commit is contained in:
parent
aca83283f1
commit
7dde9de9bf
@ -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)"
|
||||
echo "🧪 Running Jest tests for project: $targetProject with coverage"
|
||||
pnpm nx test $targetProject --code-coverage
|
||||
|
||||
COVERAGE_DIR="coverage/$targetProject"
|
||||
HTML_DIR="$COVERAGE_DIR/lcov-report"
|
||||
|
||||
echo "📁 Saving coverage path: $COVERAGE_DIR"
|
||||
echo -n "$COVERAGE_DIR" > /tekton/results/coverage-dir
|
||||
echo -n "$HTML_DIR" > /tekton/results/coverage-html
|
||||
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[*])"
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user