init
This commit is contained in:
parent
30c8c51620
commit
ed6dcb252f
@ -1,7 +1,7 @@
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: gitops-repository
|
||||
name: git-gitops-sync
|
||||
annotations:
|
||||
tekton.dev/pipelines.minVersion: "0.19.0"
|
||||
tekton.dev/categories: GitOps
|
71
tasks/nodejs-nx-analysis/task.yaml
Normal file
71
tasks/nodejs-nx-analysis/task.yaml
Normal file
@ -0,0 +1,71 @@
|
||||
---
|
||||
apiVersion: tekton.dev/v1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: nx-nodejs-analysis
|
||||
spec:
|
||||
params:
|
||||
- name: subdirectory
|
||||
type: string
|
||||
description: Subdirectory within the repo where the source code is located
|
||||
default: ""
|
||||
|
||||
- name: targetProject
|
||||
type: string
|
||||
description: Nx workspace project name to lint and test
|
||||
|
||||
- name: node-version
|
||||
type: string
|
||||
default: "18"
|
||||
description: Node.js version (e.g., 18, 20)
|
||||
|
||||
workspaces:
|
||||
- name: source
|
||||
description: Git-cloned source code with Nx monorepo
|
||||
- name: npm-auth
|
||||
optional: true
|
||||
description: |
|
||||
A workspace containing authentication credentials for a private npm repository.
|
||||
Should include:
|
||||
- username
|
||||
- password
|
||||
|
||||
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: node:$(params.node-version)
|
||||
workingDir: /workspace/source
|
||||
script: |
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
if [ -n "$(params.subdirectory)" ]; then
|
||||
cd "$(params.subdirectory)"
|
||||
fi
|
||||
|
||||
echo "📦 Installing dependencies"
|
||||
npm ci
|
||||
|
||||
echo "🔍 Running ESLint for project: $(params.targetProject)"
|
||||
npx nx lint $(params.targetProject)
|
||||
|
||||
echo "🧪 Running Jest tests for project: $(params.targetProject) with coverage"
|
||||
npx nx test $(params.targetProject) --code-coverage
|
||||
|
||||
COVERAGE_DIR="coverage/$(params.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
|
||||
|
||||
if [ -d "$HTML_DIR" ]; then
|
||||
echo "📄 HTML coverage report generated at $HTML_DIR"
|
||||
else
|
||||
echo "⚠️ HTML coverage report not found"
|
||||
fi
|
54
tasks/nodejs-nx-version/task.yaml
Normal file
54
tasks/nodejs-nx-version/task.yaml
Normal file
@ -0,0 +1,54 @@
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: nx-nodejs-version
|
||||
spec:
|
||||
params:
|
||||
- name: subdirectory
|
||||
type: string
|
||||
description: Subdirectory within the repo where the source code is located
|
||||
default: ""
|
||||
- name: ref
|
||||
type: string
|
||||
description: Full Git ref string (e.g., refs/tags/v0.2.0)
|
||||
- name: node-version
|
||||
type: string
|
||||
description: Node.js version to use
|
||||
default: "18"
|
||||
workspaces:
|
||||
- name: source
|
||||
description: Git-cloned source code
|
||||
results:
|
||||
- name: version
|
||||
description: Extracted project version (e.g. 0.2.0)
|
||||
steps:
|
||||
- name: verify-tag-version
|
||||
image: node:$(params.node-version)
|
||||
workingDir: /workspace/source
|
||||
script: |
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
if [ -n "$(params.subdirectory)" ]; then
|
||||
cd $(params.subdirectory)
|
||||
fi
|
||||
|
||||
echo "🔍 Extracting tag from Git ref..."
|
||||
FULL_REF="$(params.ref)"
|
||||
TAG_FROM_REF=$(basename "$FULL_REF") # → v0.2.0
|
||||
|
||||
echo "📄 Reading version from package.json..."
|
||||
VERSION=$(node -p "require('./package.json').version")
|
||||
TAG_FROM_PROJECT="v${VERSION}"
|
||||
|
||||
echo "🔁 Comparing Git tag and project version:"
|
||||
echo " - Git ref tag: $TAG_FROM_REF"
|
||||
echo " - Project version: $TAG_FROM_PROJECT"
|
||||
|
||||
if [ "$TAG_FROM_REF" != "$TAG_FROM_PROJECT" ]; then
|
||||
echo "❌ Mismatch! Git tag and project version are not the same."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Tag and version match: $VERSION"
|
||||
echo -n "$VERSION" > /tekton/results/version
|
Loading…
x
Reference in New Issue
Block a user