Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
PORT=3000
NODE_ENV=development
LOG_LEVEL=debug

POSTGRES_USER=
POSTGRES_PASSWORD=
POSTGRES_DB=
DATABASE_URL=
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
PORT=3000
NODE_ENV=development
LOG_LEVEL=info
POSTGRES_USER=your_username
POSTGRES_PASSWORD=your_password
POSTGRES_DB=your_database
DATABASE_URL=postgresql://your_username:your_password@localhost:5432/your_database
3 changes: 3 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
PORT=80
NODE_ENV=production
LOG_LEVEL=info
POSTGRES_USER=prod_username
POSTGRES_PASSWORD=prod_password
POSTGRES_DB=prod_database
4 changes: 4 additions & 0 deletions .env.staging
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
PORT=3002
NODE_ENV=staging
LOG_LEVEL=info
POSTGRES_USER=staging_username
POSTGRES_PASSWORD=staging_password
POSTGRES_DB=staging_database
DATABASE_URL=postgresql://staging_username:staging_password@localhost:5432/staging_database
3 changes: 3 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
PORT=3001
NODE_ENV=test
LOG_LEVEL=warn
POSTGRES_USER=test_user
POSTGRES_PASSWORD=test_password
POSTGRES_DB=test_database
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
jest: true,
es2020: true,
},
plugins: ['@typescript-eslint'],
plugins: ['@typescript-eslint', 'prettier'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
Expand Down
219 changes: 140 additions & 79 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,99 +1,160 @@
name: chainremit
name: CI/CD Pipeline

on:
push:
branches: [main, develop]
branches: [ main, develop ]
pull_request:
branches: [main, develop]
branches: [ main, develop ]
workflow_dispatch:

env:
NODE_VERSION: '18'
# Database configuration - commented out as not currently used
# POSTGRES_USER: postgres
# POSTGRES_PASSWORD: password
# POSTGRES_DB: chainremit_db
# DATABASE_URL: postgresql://postgres:password@localhost:5432/chainremit_db

jobs:
build:
quality:
name: Code Quality
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: build
path: dist

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm ci
- run: npm run lint
- run: npm run format
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Check formatting
run: npm run format -- --check
- name: Security audit
run: npm audit fix

test:
name: Tests
needs: quality
runs-on: ubuntu-latest
# Database service - commented out as not currently used
# services:
# postgres:
# image: postgres:14
# env:
# POSTGRES_USER: ${{ env.POSTGRES_USER }}
# POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }}
# POSTGRES_DB: ${{ env.POSTGRES_DB }}
# ports:
# - 5432:5432
# options: >-
# --health-cmd pg_isready
# --health-interval 10s
# --health-timeout 5s
# --health-retries 5
steps:
- uses: actions/checkout@v3
- run: npm ci
- run: npm run test:coverage
- name: Upload coverage report
uses: actions/upload-artifact@v3
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
name: coverage
path: coverage

security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm ci
- run: npm audit --audit-level=high
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run unit tests
run: npm run test
# Database-dependent tests - commented out
# - name: Run e2e tests
# run: npm run test:e2e
# env:
# DATABASE_URL: ${{ env.DATABASE_URL }}
# - name: Upload coverage reports
# uses: codecov/codecov-action@v3
# with:
# token: ${{ secrets.CODECOV_TOKEN }}

deploy-staging:
if: github.ref == 'refs/heads/main'
needs: [build, lint, test, security]
build:
name: Build
needs: test
runs-on: ubuntu-latest
environment:
name: staging
steps:
- name: Deploy to Staging
run: echo "Deploying to Staging..."
# Add deployment script/command
- name: Notify Slack
if: always()
uses: 8398a7/action-slack@v3
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

deploy-production:
if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch'
needs: [deploy-staging]
runs-on: ubuntu-latest
environment:
name: production
steps:
- name: Deploy to Production
run: echo "Deploying to Production..."
# Add deployment script/command
- name: Notify Slack
if: always()
uses: 8398a7/action-slack@v3
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
name: dist
path: dist

dependabot:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Enable Dependabot
run: echo "Dependabot enabled for automated dependency updates."
# Deployment jobs remain commented out as they were
# deploy-staging:
# name: Deploy to Staging
# needs: build
# if: github.ref == 'refs/heads/develop'
# runs-on: ubuntu-latest
# environment:
# name: staging
# url: https://staging-api.chainremit.com
# steps:
# - uses: actions/checkout@v4
# - name: Download build artifacts
# uses: actions/download-artifact@v3
# with:
# name: dist
# path: dist
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: ${{ secrets.AWS_REGION }}
# - name: Deploy to AWS Elastic Beanstalk
# run: |
# aws elasticbeanstalk create-application-version \
# --application-name chainremit-backend \
# --version-label "staging-${{ github.sha }}" \
# --source-bundle S3Bucket="${{ secrets.EB_BUCKET }}",S3Key="staging-${{ github.sha }}.zip"
# aws elasticbeanstalk update-environment \
# --environment-name chainremit-staging \
# --version-label "staging-${{ github.sha }}"

# deploy-production:
# name: Deploy to Production
# needs: build
# if: github.ref == 'refs/heads/main'
# runs-on: ubuntu-latest
# environment:
# name: production
# url: https://api.chainremit.com
# steps:
# - uses: actions/checkout@v4
# - name: Download build artifacts
# uses: actions/download-artifact@v3
# with:
# name: dist
# path: dist
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: ${{ secrets.AWS_REGION }}
# - name: Deploy to AWS Elastic Beanstalk
# run: |
# aws elasticbeanstalk create-application-version \
# --application-name chainremit-backend \
# --version-label "prod-${{ github.sha }}" \
# --source-bundle S3Bucket="${{ secrets.EB_BUCKET }}",S3Key="prod-${{ github.sha }}.zip"
# aws elasticbeanstalk update-environment \
# --environment-name chainremit-production \
# --version-label "prod-${{ github.sha }}"
38 changes: 0 additions & 38 deletions .github/workflows/codeql.yml

This file was deleted.

Loading