docs: Merge previous README with new security and test information #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
- name: Install backend dependencies | |
working-directory: ./backend | |
run: npm ci | |
- name: Run backend tests | |
working-directory: ./backend | |
run: npm test -- --json --outputFile=test-results.json | |
- name: Generate backend coverage badges | |
working-directory: ./backend | |
run: | | |
npm install -g jest-coverage-badges | |
jest-coverage-badges | |
- name: Install frontend dependencies | |
working-directory: ./frontend | |
run: npm ci | |
- name: Run frontend tests | |
working-directory: ./frontend | |
run: npm test -- --watchAll=false --json --outputFile=test-results.json | |
- name: Generate frontend coverage badges | |
working-directory: ./frontend | |
run: | | |
npm install -g jest-coverage-badges | |
jest-coverage-badges | |
- name: Upload test results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-results | |
path: | | |
backend/test-results.json | |
frontend/test-results.json | |
- name: Upload coverage reports | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage-reports | |
path: | | |
backend/coverage | |
frontend/coverage | |
- name: Publish Test Results | |
uses: EnricoMi/publish-unit-test-result-action@v2 | |
if: always() | |
with: | |
files: | | |
**/test-results.json | |
security: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Run npm audit | |
run: | | |
cd backend && npm audit --json > ../backend-audit.json || true | |
cd ../frontend && npm audit --json > ../frontend-audit.json || true | |
- name: Upload npm audit results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: security-audit-results | |
path: | | |
backend-audit.json | |
frontend-audit.json | |
docker: | |
needs: [test, security] | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Build Docker images | |
run: docker-compose build | |
- name: Test Docker Compose | |
run: | | |
docker-compose up -d | |
sleep 10 | |
curl http://localhost:3001/health | |
docker-compose down |