This commit is contained in:
병준 박 2025-04-26 06:51:00 +00:00
parent fdbf405d2c
commit a0a15361b1
2 changed files with 95 additions and 1 deletions

View File

@ -1,7 +1,7 @@
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: nx-nodejs-analysis
name: nodejs-nx-analysis
spec:
params:
- name: context

View File

@ -0,0 +1,94 @@
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: rust-nx-analysis
spec:
params:
- name: context
type: string
description: context directory
default: ""
- name: source
type: string
default: "source"
description: |
source directory (sub directory of context)
- name: workspaceName
type: string
description: Nx workspace name to lint and test
- name: targetProjects
type: array
description: Nx workspace project names to lint and test
workspaces:
- name: base
description: Git-cloned source code with Nx monorepo
results:
- name: coverage-dir
description: Path to generated coverage directory
- name: coverage-html
description: Path to generated HTML coverage report directory
steps:
- name: lint-and-test
image: rust:ubuntu
workingDir: /workspace/base/$(params.context)/$(params.source)/$(params.workspaceName)
env:
- name: HOME
value: /workspace/base/$(params.context)/home
script: |
#!/usr/bin/env bash
set -e
# Node.js 20.x 설치
apt-get update && apt-get install -y curl
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt-get install -y nodejs
# 버전 확인
rustc --version
cargo --version
node --version
npm --version
export NX_SOCKET_DIR=/tmp/nx-socket
echo "🧩 Using pnpm via corepack"
corepack enable
corepack prepare pnpm@10.8.1 --activate
echo "📦 Installing dependencies with pnpm"
pnpm install --frozen-lockfile
coverage_dirs=()
html_dirs=()
for targetProject in "$@"; do
echo "🔍 Running ESLint for project: $targetProject"
pnpm nx lint $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"
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[*])"