init
This commit is contained in:
parent
a0a15361b1
commit
398b514490
@ -6,89 +6,101 @@ spec:
|
||||
params:
|
||||
- name: context
|
||||
type: string
|
||||
description: context directory
|
||||
description: Context directory
|
||||
default: ""
|
||||
|
||||
- name: source
|
||||
type: string
|
||||
default: "source"
|
||||
description: |
|
||||
source directory (sub directory of context)
|
||||
|
||||
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
|
||||
- name: lint-test-coverage
|
||||
image: rust:1.75-slim
|
||||
workingDir: /workspace/base/$(params.context)/$(params.source)/$(params.workspaceName)
|
||||
env:
|
||||
- name: HOME
|
||||
value: /workspace/base/$(params.context)/home
|
||||
script: |
|
||||
#!/usr/bin/env bash
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Node.js 20.x 설치
|
||||
apt-get update && apt-get install -y curl
|
||||
# Install dependencies
|
||||
apt-get update && apt-get install -y curl libssl-dev pkg-config build-essential
|
||||
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
||||
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
|
||||
cargo --version
|
||||
node --version
|
||||
npm --version
|
||||
pnpm --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
|
||||
|
||||
# Initialize result arrays
|
||||
coverage_dirs=()
|
||||
html_dirs=()
|
||||
|
||||
for targetProject in "$@"; do
|
||||
echo "🔍 Running ESLint for project: $targetProject"
|
||||
pnpm nx lint $targetProject
|
||||
# Run lint, test, and coverage in parallel using nx run-many
|
||||
echo "🔍 Running lint, test, and coverage for projects: $(params.targetProjects[*])"
|
||||
|
||||
echo "🧪 Running Jest tests for project: $targetProject with coverage"
|
||||
pnpm nx test $targetProject --code-coverage
|
||||
# Lint (cargo clippy via nx)
|
||||
pnpm nx run-many --target=lint --projects=$(params.targetProjects[*]) --parallel=4
|
||||
|
||||
COVERAGE_DIR="coverage/$targetProject"
|
||||
HTML_DIR="$COVERAGE_DIR/lcov-report"
|
||||
# Test (cargo test via nx)
|
||||
pnpm nx run-many --target=test --projects=$(params.targetProjects[*]) --parallel=4
|
||||
|
||||
coverage_dirs+=("\"$COVERAGE_DIR\"")
|
||||
html_dirs+=("\"$HTML_DIR\"")
|
||||
# Coverage (cargo-tarpaulin)
|
||||
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
|
||||
echo "📄 HTML coverage report generated at $HTML_DIR"
|
||||
else
|
||||
echo "⚠️ HTML coverage report not found"
|
||||
echo "⚠️ HTML coverage report not found for $targetProject"
|
||||
fi
|
||||
|
||||
cd /workspace/base/$(params.context)/$(params.source)/$(params.workspaceName)
|
||||
done
|
||||
|
||||
echo -n "[${coverage_dirs[*]}]" > /tekton/results/coverage-dir
|
||||
echo -n "[${html_dirs[*]}]" > /tekton/results/coverage-html
|
||||
|
||||
# Write results to Tekton results
|
||||
echo "[${coverage_dirs[*]}]" > /tekton/results/coverage-dir
|
||||
echo "[${html_dirs[*]}]" > /tekton/results/coverage-html
|
||||
args:
|
||||
- "$(params.targetProjects[*])"
|
Loading…
x
Reference in New Issue
Block a user