Skip to content

Commit 7e30af8

Browse files
committed
Add package.json for project setup with dependencies and scripts
0 parents  commit 7e30af8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+5709
-0
lines changed

.dockerignore

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# ==========================================
2+
# Node.js Dependencies and Build Files
3+
# ==========================================
4+
node_modules
5+
npm-debug.log
6+
.nyc_output
7+
coverage
8+
test-results.xml
9+
10+
# ==========================================
11+
# Git and Version Control
12+
# ==========================================
13+
.git
14+
.gitignore
15+
.cache
16+
17+
# ==========================================
18+
# GitHub and CI/CD Files
19+
# ==========================================
20+
.github/
21+
22+
# ==========================================
23+
# Terraform Infrastructure Files
24+
# ==========================================
25+
Terraform/
26+
backend/
27+
*.tf
28+
*.tfvars
29+
*.tfstate
30+
*.tfstate.*
31+
*.tfstate.backup
32+
.terraform/
33+
.terraform.lock.hcl
34+
35+
# ==========================================
36+
# Kubernetes Deployment Files
37+
# ==========================================
38+
kubernetes/
39+
*.yml
40+
*.yaml
41+
!docker-compose.yml
42+
43+
# ==========================================
44+
# Environment and Secrets
45+
# ==========================================
46+
.env
47+
.env.*
48+
.secrets
49+
.aws/
50+
*-credentials*
51+
*.pem
52+
*.key
53+
54+
# ==========================================
55+
# Documentation and README
56+
# ==========================================
57+
*.md
58+
!README*.md
59+
README-secret.md
60+
61+
# ==========================================
62+
# Development and IDE Files
63+
# ==========================================
64+
.vscode/
65+
.idea/
66+
*.swp
67+
*.swo
68+
*~
69+
70+
# ==========================================
71+
# Operating System Files
72+
# ==========================================
73+
.DS_Store
74+
Thumbs.db
75+
76+
# ==========================================
77+
# Project Specific
78+
# ==========================================
79+
solar-system.png
80+
.talismanrc
81+
82+
# ==========================================
83+
# Logs and Temporary Files
84+
# ==========================================
85+
*.log
86+
tmp/
87+
temp/

.github/workflows/ci.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: CI - Testing and Code Coverage
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_call:
6+
outputs:
7+
test-result:
8+
description: "Test execution result"
9+
value: ${{ jobs.code-coverage.outputs.result }}
10+
11+
env:
12+
MONGO_URI: ${{ secrets.MONGO_URI }}
13+
MONGO_USERNAME: ${{ secrets.MONGO_USERNAME }}
14+
MONGO_PASSWORD: ${{ secrets.MONGO_PASSWORD }}
15+
16+
jobs:
17+
unit-testing:
18+
name: Unit Testing
19+
strategy:
20+
matrix:
21+
node-version: [18, 19, 20]
22+
os: [ubuntu-latest, windows-latest, macos-latest]
23+
exclude:
24+
- os: windows-latest
25+
node-version: 18
26+
runs-on: ${{ matrix.os }}
27+
28+
steps:
29+
- name: Checkout Repository
30+
uses: actions/checkout@v5
31+
32+
- name: Setup NodeJS Version - ${{ matrix.node-version }}
33+
uses: actions/[email protected]
34+
with:
35+
node-version: ${{ matrix.node-version }}
36+
37+
- name: Install Dependencies
38+
run: npm install
39+
40+
- name: Unit Testing
41+
id: Nodejs-unit-testing-step
42+
run: npm test
43+
44+
- name: Archive Test Result
45+
if: always()
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: Mocha-Test-Result-${{ matrix.os }}-${{ matrix.node-version }}
49+
path: test-results.xml
50+
retention-days: 1
51+
52+
code-coverage:
53+
name: Code Coverage
54+
needs: unit-testing
55+
runs-on: ubuntu-latest
56+
outputs:
57+
result: ${{ steps.coverage.outcome }}
58+
steps:
59+
- name: Checkout Repository
60+
uses: actions/checkout@v5
61+
62+
- name: Setup NodeJS
63+
uses: actions/[email protected]
64+
with:
65+
node-version: 18
66+
67+
- name: Install Dependencies
68+
run: npm install
69+
70+
- name: Run Code Coverage
71+
id: coverage
72+
continue-on-error: true
73+
run: npm run coverage
74+
75+
- name: Archive Coverage Report
76+
if: always()
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: Coverage-Report
80+
path: coverage/
81+
retention-days: 1

.github/workflows/deploy.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Kubernetes Deployment
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
image-tag:
7+
description: 'Docker image tag to deploy'
8+
required: false
9+
default: 'latest'
10+
type: string
11+
workflow_call:
12+
inputs:
13+
image-tag:
14+
description: 'Docker image tag to deploy'
15+
required: false
16+
default: 'latest'
17+
type: string
18+
19+
env:
20+
MONGO_URI: ${{ secrets.MONGO_URI }}
21+
MONGO_USERNAME: ${{ secrets.MONGO_USERNAME }}
22+
MONGO_PASSWORD: ${{ secrets.MONGO_PASSWORD }}
23+
24+
jobs:
25+
deploy:
26+
name: Deploy to Kubernetes
27+
runs-on: ubuntu-latest
28+
environment: production
29+
30+
steps:
31+
- name: Checkout Repository
32+
uses: actions/checkout@v5
33+
34+
- name: Login to AWS
35+
uses: aws-actions/[email protected]
36+
with:
37+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
38+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
39+
aws-region: us-east-1
40+
41+
- name: Update kubeconfig
42+
run: |
43+
aws eks update-kubeconfig --name otel-cluster --region us-east-1
44+
45+
- name: Configure kubectl
46+
uses: statsig-io/kubectl-via-eksctl@main
47+
env:
48+
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
49+
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
50+
region: us-east-1
51+
cluster: otel-cluster
52+
53+
54+
- name: Create Base64-encoded K8s Secret
55+
run: |
56+
kubectl apply -f - <<EOF
57+
apiVersion: v1
58+
kind: Secret
59+
metadata:
60+
name: mongo-secrets
61+
type: Opaque
62+
data:
63+
MONGO_URI: $(echo -n "${{ secrets.MONGO_URI }}" | base64)
64+
MONGO_USERNAME: $(echo -n "${{ secrets.MONGO_USERNAME }}" | base64)
65+
MONGO_PASSWORD: $(echo -n "${{ secrets.MONGO_PASSWORD }}" | base64)
66+
EOF
67+
68+
- name: Generate Deployment YAML with Docker image
69+
run: |
70+
IMAGE_TAG=${{ inputs.image-tag || github.sha }}
71+
envsubst < ./kubernetes/deployment.template.yml > ./kubernetes/deployment.yml
72+
env:
73+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
74+
IMAGE_TAG: ${{ inputs.image-tag || github.sha }}
75+
76+
- name: Deploy to EKS
77+
run: |
78+
kubectl apply -f deployment.yml
79+
kubectl apply -f service.yml
80+
working-directory: ./kubernetes
81+
82+
83+
84+
- name: Verify Deployment
85+
run: |
86+
kubectl get pods -l app=solar-system
87+
kubectl get services
88+
echo "Waiting for deployment to be ready..."
89+
kubectl wait --for=condition=available --timeout=300s deployment/solar-system
90+
echo "Waiting for container to be running..."
91+
kubectl wait --for=condition=Ready --timeout=180s pod -l app=solar-system
92+
93+
- name: Get Service URL
94+
run: |
95+
HOSTNAME=$(kubectl get svc solar-system-service -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
96+
echo "Service URL: http://$HOSTNAME:3000"
97+
working-directory: ./kubernetes

.github/workflows/destroy.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Terraform Destroy Workflow
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
terraform-destroy:
8+
name: Terraform Destroy
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout Repository
13+
uses: actions/checkout@v5
14+
15+
- name: Login to AWS
16+
uses: aws-actions/[email protected]
17+
with:
18+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
19+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
20+
aws-region: us-east-1
21+
22+
- name: Setup Terraform
23+
uses: hashicorp/[email protected]
24+
with:
25+
terraform_version: 1.5.7
26+
27+
- name: Delete LoadBalancer Services
28+
run: |
29+
aws eks update-kubeconfig --name otel-cluster --region us-east-1 || true
30+
kubectl delete services --all --ignore-not-found=true || true
31+
32+
- name: Terraform Init
33+
run: terraform init
34+
working-directory: ./Terraform
35+
36+
- name: Terraform Destroy
37+
run: terraform destroy -auto-approve
38+
working-directory: ./Terraform

.github/workflows/development.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Development - Feature Branch Testing
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches-ignore:
9+
- main
10+
- 'feature-branch-A'
11+
12+
jobs:
13+
quick-test:
14+
name: Quick CI Tests
15+
uses: ./.github/workflows/ci.yml
16+
secrets: inherit
17+
18+
docker-test:
19+
name: Docker Build Test (No Push)
20+
needs: [quick-test]
21+
uses: ./.github/workflows/docker.yml
22+
secrets: inherit
23+
with:
24+
push-image: false

0 commit comments

Comments
 (0)