72 lines
2.0 KiB
YAML
72 lines
2.0 KiB
YAML
---
|
|
kind: pipeline
|
|
type: docker
|
|
name: default
|
|
|
|
steps:
|
|
# Step 1: Install dependencies and run server tests
|
|
- name: server_test
|
|
image: node:18-alpine
|
|
commands:
|
|
- echo "Running server tests..."
|
|
- cd services/server || echo "services/server directory not found!"
|
|
- if [ -f package.json ]; then
|
|
yarn install --frozen-lockfile;
|
|
yarn test;
|
|
else
|
|
echo "package.json not found! Skipping server tests.";
|
|
fi
|
|
|
|
# Step 2: Install dependencies and run client tests
|
|
- name: client_test
|
|
image: node:18-alpine
|
|
commands:
|
|
- echo "Running tests for React client..."
|
|
- cd services/client || echo "services/client directory not found!"
|
|
- if [ -f package.json ]; then
|
|
yarn install --frozen-lockfile;
|
|
yarn add --dev @babel/plugin-proposal-private-property-in-object @testing-library/jest-dom;
|
|
yarn test --coverage --detectOpenHandles;
|
|
else
|
|
echo "package.json not found! Skipping client tests.";
|
|
fi
|
|
|
|
# Step 3: Lint and static analysis (optional)
|
|
- name: lint
|
|
image: node:18-alpine
|
|
commands:
|
|
- echo "Running linter..."
|
|
- cd services/client || echo "services/client directory not found!"
|
|
- yarn lint || echo "Linting failed! Please fix lint errors."
|
|
|
|
# Step 4: Build the React client
|
|
- name: client_build
|
|
image: node:18-alpine
|
|
commands:
|
|
- echo "Building React client..."
|
|
- cd services/client || echo "services/client directory not found!"
|
|
- if [ -f package.json ]; then
|
|
yarn install --frozen-lockfile;
|
|
yarn build;
|
|
else
|
|
echo "package.json not found! Skipping build.";
|
|
fi
|
|
|
|
# Step 5: Deploy (example step)
|
|
- name: deploy
|
|
image: alpine:latest
|
|
environment:
|
|
DEPLOY_KEY:
|
|
from_secret: deploy_key
|
|
commands:
|
|
- echo "Deploying application..."
|
|
- # Add deployment commands here (e.g., SSH, Rsync, Kubernetes, etc.)
|
|
|
|
# Specify trigger conditions
|
|
trigger:
|
|
branch:
|
|
- main
|
|
event:
|
|
- push
|
|
- pull_request
|