init
This commit is contained in:
parent
a0a15361b1
commit
398b514490
@ -6,89 +6,101 @@ spec:
|
|||||||
params:
|
params:
|
||||||
- name: context
|
- name: context
|
||||||
type: string
|
type: string
|
||||||
description: context directory
|
description: Context directory
|
||||||
default: ""
|
default: ""
|
||||||
|
|
||||||
- name: source
|
- name: source
|
||||||
type: string
|
type: string
|
||||||
default: "source"
|
default: "source"
|
||||||
description: |
|
description: Source directory (sub directory of context)
|
||||||
source directory (sub directory of context)
|
|
||||||
|
|
||||||
- name: workspaceName
|
- name: workspaceName
|
||||||
type: string
|
type: string
|
||||||
description: Nx workspace name to lint and test
|
description: Nx workspace name to lint and test
|
||||||
|
|
||||||
- name: targetProjects
|
- name: targetProjects
|
||||||
type: array
|
type: array
|
||||||
description: Nx workspace project names to lint and test
|
description: Nx workspace project names to lint and test
|
||||||
|
|
||||||
workspaces:
|
workspaces:
|
||||||
- name: base
|
- name: base
|
||||||
description: Git-cloned source code with Nx monorepo
|
description: Git-cloned source code with Nx monorepo
|
||||||
|
|
||||||
results:
|
results:
|
||||||
- name: coverage-dir
|
- name: coverage-dir
|
||||||
description: Path to generated coverage directory
|
description: Path to generated coverage directory
|
||||||
- name: coverage-html
|
- name: coverage-html
|
||||||
description: Path to generated HTML coverage report directory
|
description: Path to generated HTML coverage report directory
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: lint-and-test
|
- name: lint-test-coverage
|
||||||
image: rust:ubuntu
|
image: rust:1.75-slim
|
||||||
workingDir: /workspace/base/$(params.context)/$(params.source)/$(params.workspaceName)
|
workingDir: /workspace/base/$(params.context)/$(params.source)/$(params.workspaceName)
|
||||||
env:
|
env:
|
||||||
- name: HOME
|
- name: HOME
|
||||||
value: /workspace/base/$(params.context)/home
|
value: /workspace/base/$(params.context)/home
|
||||||
script: |
|
script: |
|
||||||
#!/usr/bin/env bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Node.js 20.x 설치
|
# Install dependencies
|
||||||
apt-get update && apt-get install -y curl
|
apt-get update && apt-get install -y curl libssl-dev pkg-config build-essential
|
||||||
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
||||||
apt-get install -y nodejs
|
apt-get install -y nodejs
|
||||||
|
|
||||||
# 버전 확인
|
# Install Rust tools
|
||||||
|
cargo install cargo-clippy cargo-tarpaulin --locked
|
||||||
|
rustup component add clippy
|
||||||
|
|
||||||
|
# Install pnpm
|
||||||
|
corepack enable
|
||||||
|
corepack prepare pnpm@10.8.1 --activate
|
||||||
|
|
||||||
|
# Install Nx dependencies
|
||||||
|
pnpm install --frozen-lockfile
|
||||||
|
|
||||||
|
# Version checks
|
||||||
rustc --version
|
rustc --version
|
||||||
cargo --version
|
cargo --version
|
||||||
node --version
|
node --version
|
||||||
npm --version
|
npm --version
|
||||||
|
pnpm --version
|
||||||
|
|
||||||
export NX_SOCKET_DIR=/tmp/nx-socket
|
export NX_SOCKET_DIR=/tmp/nx-socket
|
||||||
|
|
||||||
echo "🧩 Using pnpm via corepack"
|
# Initialize result arrays
|
||||||
corepack enable
|
|
||||||
corepack prepare pnpm@10.8.1 --activate
|
|
||||||
|
|
||||||
echo "📦 Installing dependencies with pnpm"
|
|
||||||
pnpm install --frozen-lockfile
|
|
||||||
|
|
||||||
coverage_dirs=()
|
coverage_dirs=()
|
||||||
html_dirs=()
|
html_dirs=()
|
||||||
|
|
||||||
for targetProject in "$@"; do
|
# Run lint, test, and coverage in parallel using nx run-many
|
||||||
echo "🔍 Running ESLint for project: $targetProject"
|
echo "🔍 Running lint, test, and coverage for projects: $(params.targetProjects[*])"
|
||||||
pnpm nx lint $targetProject
|
|
||||||
|
|
||||||
echo "🧪 Running Jest tests for project: $targetProject with coverage"
|
# Lint (cargo clippy via nx)
|
||||||
pnpm nx test $targetProject --code-coverage
|
pnpm nx run-many --target=lint --projects=$(params.targetProjects[*]) --parallel=4
|
||||||
|
|
||||||
COVERAGE_DIR="coverage/$targetProject"
|
# Test (cargo test via nx)
|
||||||
HTML_DIR="$COVERAGE_DIR/lcov-report"
|
pnpm nx run-many --target=test --projects=$(params.targetProjects[*]) --parallel=4
|
||||||
|
|
||||||
coverage_dirs+=("\"$COVERAGE_DIR\"")
|
# Coverage (cargo-tarpaulin)
|
||||||
html_dirs+=("\"$HTML_DIR\"")
|
for targetProject in "${@:1}"; do
|
||||||
|
echo "🧪 Generating coverage for project: $targetProject"
|
||||||
|
PROJECT_PATH=$(pnpm nx show project $targetProject --json | jq -r '.root')
|
||||||
|
cd "$PROJECT_PATH"
|
||||||
|
|
||||||
|
# Run tarpaulin for coverage
|
||||||
|
cargo tarpaulin --out Html --output-dir coverage --timeout 120
|
||||||
|
|
||||||
|
COVERAGE_DIR="coverage"
|
||||||
|
HTML_DIR="$COVERAGE_DIR/html"
|
||||||
|
|
||||||
|
coverage_dirs+=("\"$PROJECT_PATH/$COVERAGE_DIR\"")
|
||||||
|
html_dirs+=("\"$PROJECT_PATH/$HTML_DIR\"")
|
||||||
|
|
||||||
if [ -d "$HTML_DIR" ]; then
|
if [ -d "$HTML_DIR" ]; then
|
||||||
echo "📄 HTML coverage report generated at $HTML_DIR"
|
echo "📄 HTML coverage report generated at $HTML_DIR"
|
||||||
else
|
else
|
||||||
echo "⚠️ HTML coverage report not found"
|
echo "⚠️ HTML coverage report not found for $targetProject"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cd /workspace/base/$(params.context)/$(params.source)/$(params.workspaceName)
|
||||||
done
|
done
|
||||||
|
|
||||||
echo -n "[${coverage_dirs[*]}]" > /tekton/results/coverage-dir
|
# Write results to Tekton results
|
||||||
echo -n "[${html_dirs[*]}]" > /tekton/results/coverage-html
|
echo "[${coverage_dirs[*]}]" > /tekton/results/coverage-dir
|
||||||
|
echo "[${html_dirs[*]}]" > /tekton/results/coverage-html
|
||||||
args:
|
args:
|
||||||
- "$(params.targetProjects[*])"
|
- "$(params.targetProjects[*])"
|
Loading…
x
Reference in New Issue
Block a user