init
This commit is contained in:
parent
398b514490
commit
1fd5e1be1d
@ -16,18 +16,18 @@ spec:
|
||||
type: string
|
||||
description: Nx workspace name to lint and test
|
||||
- name: targetProjects
|
||||
type: array
|
||||
description: Nx workspace project names to lint and test
|
||||
type: string
|
||||
description: Comma-separated list of Nx workspace project names to lint and test (e.g., "api-client-request,openapi-project")
|
||||
workspaces:
|
||||
- name: base
|
||||
description: Git-cloned source code with Nx monorepo
|
||||
results:
|
||||
- name: coverage-dir
|
||||
description: Path to generated coverage directory
|
||||
description: Comma-separated paths to generated coverage directories
|
||||
- name: coverage-html
|
||||
description: Path to generated HTML coverage report directory
|
||||
description: Comma-separated paths to generated HTML coverage report directories
|
||||
steps:
|
||||
- name: lint-test-coverage
|
||||
- name: install-dependencies
|
||||
image: rust:1.75-slim
|
||||
workingDir: /workspace/base/$(params.context)/$(params.source)/$(params.workspaceName)
|
||||
env:
|
||||
@ -37,8 +37,8 @@ spec:
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Install dependencies
|
||||
apt-get update && apt-get install -y curl libssl-dev pkg-config build-essential
|
||||
# Install system dependencies
|
||||
apt-get update && apt-get install -y curl libssl-dev pkg-config build-essential jq
|
||||
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
||||
apt-get install -y nodejs
|
||||
|
||||
@ -59,48 +59,62 @@ spec:
|
||||
node --version
|
||||
npm --version
|
||||
pnpm --version
|
||||
- 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: |
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
export NX_SOCKET_DIR=/tmp/nx-socket
|
||||
|
||||
# Initialize result arrays
|
||||
coverage_dirs=()
|
||||
html_dirs=()
|
||||
# Convert comma-separated targetProjects to space-separated for Bash
|
||||
PROJECTS=$(echo "$(params.targetProjects)" | tr ',' ' ')
|
||||
|
||||
# Run lint, test, and coverage in parallel using nx run-many
|
||||
echo "🔍 Running lint, test, and coverage for projects: $(params.targetProjects[*])"
|
||||
# Run lint and test in parallel using nx run-many
|
||||
echo "🔍 Running lint for projects: $PROJECTS"
|
||||
pnpm nx run-many --target=lint --projects="$(params.targetProjects)" --parallel=4
|
||||
|
||||
# Lint (cargo clippy via nx)
|
||||
pnpm nx run-many --target=lint --projects=$(params.targetProjects[*]) --parallel=4
|
||||
echo "🧪 Running tests for projects: $PROJECTS"
|
||||
pnpm nx run-many --target=test --projects="$(params.targetProjects)" --parallel=4
|
||||
|
||||
# Test (cargo test via nx)
|
||||
pnpm nx run-many --target=test --projects=$(params.targetProjects[*]) --parallel=4
|
||||
# Initialize result variables
|
||||
COVERAGE_DIRS=""
|
||||
HTML_DIRS=""
|
||||
|
||||
# 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')
|
||||
# Run coverage for each project
|
||||
for project in $PROJECTS; do
|
||||
echo "📊 Generating coverage for project: $project"
|
||||
PROJECT_PATH=$(pnpm nx show project "$project" --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\"")
|
||||
# Append to results (comma-separated)
|
||||
if [ -z "$COVERAGE_DIRS" ]; then
|
||||
COVERAGE_DIRS="$PROJECT_PATH/$COVERAGE_DIR"
|
||||
HTML_DIRS="$PROJECT_PATH/$HTML_DIR"
|
||||
else
|
||||
COVERAGE_DIRS="$COVERAGE_DIRS,$PROJECT_PATH/$COVERAGE_DIR"
|
||||
HTML_DIRS="$HTML_DIRS,$PROJECT_PATH/$HTML_DIR"
|
||||
fi
|
||||
|
||||
if [ -d "$HTML_DIR" ]; then
|
||||
echo "📄 HTML coverage report generated at $HTML_DIR"
|
||||
else
|
||||
echo "⚠️ HTML coverage report not found for $targetProject"
|
||||
echo "⚠️ HTML coverage report not found for $project"
|
||||
fi
|
||||
|
||||
cd /workspace/base/$(params.context)/$(params.source)/$(params.workspaceName)
|
||||
done
|
||||
|
||||
# Write results to Tekton results
|
||||
echo "[${coverage_dirs[*]}]" > /tekton/results/coverage-dir
|
||||
echo "[${html_dirs[*]}]" > /tekton/results/coverage-html
|
||||
args:
|
||||
- "$(params.targetProjects[*])"
|
||||
echo "$COVERAGE_DIRS" > /tekton/results/coverage-dir
|
||||
echo "$HTML_DIRS" > /tekton/results/coverage-html
|
Loading…
x
Reference in New Issue
Block a user