Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
amcgready committed Oct 28, 2024
0 parents commit cbc4842
Show file tree
Hide file tree
Showing 106 changed files with 13,974 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// .github/dependabot.yml
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
versioning-strategy: increase
labels:
- "dependencies"
- "automerge"
commit-message:
prefix: "chore"
include: "scope"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
labels:
- "dependencies"
- "automerge"
commit-message:
prefix: "ci"
include: "scope"
37 changes: 37 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// .github/pull_request_template.md
## Description
<!-- Describe your changes in detail -->

## Related Issue
<!-- Please link to the issue here -->
Closes #

## Type of change
<!-- Please delete options that are not relevant -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update

## How Has This Been Tested?
<!-- Please describe the tests that you ran to verify your changes -->
- [ ] Unit Tests
- [ ] Integration Tests
- [ ] Manual Testing (please describe)

## Checklist
<!-- Please check off items as they are completed -->
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules

## Screenshots (if appropriate)
<!-- Add screenshots here -->

## Additional Notes
<!-- Add any additional notes here -->
36 changes: 36 additions & 0 deletions .github/workflows/environments.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# .github/workflows/environments.yml
name: Environment Configuration

on:
workflow_dispatch:
inputs:
environment:
description: 'Environment to configure'
required: true
type: choice
options:
- staging
- production

jobs:
configure-environment:
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}

steps:
- name: Configure Environment Secrets
uses: hashicorp/vault-action@v2
with:
url: ${{ secrets.VAULT_ADDR }}
token: ${{ secrets.VAULT_TOKEN }}
secrets: |
secret/data/votarr/${{ github.event.inputs.environment }}/aws AWS_ACCESS_KEY_ID ;
secret/data/votarr/${{ github.event.inputs.environment }}/aws AWS_SECRET_ACCESS_KEY ;
secret/data/votarr/${{ github.event.inputs.environment }}/aws AWS_REGION ;
secret/data/votarr/${{ github.event.inputs.environment }}/database DATABASE_URL ;
secret/data/votarr/${{ github.event.inputs.environment }}/plex PLEX_CLIENT_IDENTIFIER ;
secret/data/votarr/${{ github.event.inputs.environment }}/jwt JWT_SECRET ;
secret/data/votarr/${{ github.event.inputs.environment }}/monitoring SENTRY_DSN ;
secret/data/votarr/${{ github.event.inputs.environment }}/monitoring LOGTAIL_SOURCE_TOKEN ;
secret/data/votarr/${{ github.event.inputs.environment }}/aws AWS_S3_BUCKET ;
secret/data/votarr/${{ github.event.inputs.environment }}/aws AWS_CLOUDFRONT_ID ;
167 changes: 167 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
// .github/workflows/main.yml
name: Votarr CI/CD Pipeline

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
name: Test
runs-on: ubuntu-latest

services:
postgres:
image: postgres:14
env:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: votarr_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Generate Prisma Client
run: npx prisma generate

- name: Run database migrations
run: npx prisma migrate deploy
env:
DATABASE_URL: postgresql://test:test@localhost:5432/votarr_test

- name: Run tests
run: npm test
env:
DATABASE_URL: postgresql://test:test@localhost:5432/votarr_test
JWT_SECRET: test-secret
NODE_ENV: test

- name: Upload test coverage
uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage/

lint:
name: Lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run ESLint
run: npm run lint

- name: Run TypeScript compilation check
run: npm run type-check

build:
name: Build
needs: [test, lint]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Build application
run: npm run build

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: build
path: dist/

deploy-staging:
name: Deploy to Staging
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
environment: staging

steps:
- uses: actions/checkout@v3

- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build
path: dist/

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
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
run: |
aws s3 sync dist/ s3://${{ secrets.AWS_S3_BUCKET }} --delete
aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_ID }} --paths "/*"
deploy-production:
name: Deploy to Production
needs: deploy-staging
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
environment:
name: production
url: https://votarr.example.com

steps:
- uses: actions/checkout@v3

- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build
path: dist/

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
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
run: |
aws s3 sync dist/ s3://${{ secrets.AWS_S3_BUCKET }} --delete
aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_ID }} --paths "/*"
36 changes: 36 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// cypress.config.ts
import { defineConfig } from 'cypress';

export default defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
supportFile: 'cypress/support/e2e.ts',
specPattern: 'cypress/e2e/**/*.cy.{js,jsx,ts,tsx}',
setupNodeEvents(on, config) {
require('@cypress/code-coverage/task')(on, config);
return config;
},
env: {
codeCoverage: {
url: '/api/__coverage__'
}
}
},
component: {
devServer: {
framework: 'react',
bundler: 'vite',
},
supportFile: 'cypress/support/component.ts',
specPattern: 'cypress/component/**/*.cy.{js,jsx,ts,tsx}',
},
viewportWidth: 1280,
viewportHeight: 720,
video: false,
screenshotOnRunFailure: true,
chromeWebSecurity: false,
retries: {
runMode: 2,
openMode: 0
}
});
Loading

0 comments on commit cbc4842

Please sign in to comment.