-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (99 loc) · 3.23 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Continuous Integration
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
CI: true
jobs:
backend-tests:
name: Backend Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install backend dependencies
run: |
python -m pip install --upgrade pip
pip install -r src/api/requirements.txt
- name: Run backend linting
run: |
pip install flake8
flake8 src/api
- name: Run backend unit tests
run: |
cd src/api
python manage.py test
- name: Run backend integration tests
run: |
cd src/api
python manage.py test --tag=integration
frontend-tests:
name: Frontend Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 14
- name: Install frontend dependencies
run: |
cd src/frontend
npm ci
- name: Run frontend linting
run: |
cd src/frontend
npm run lint
- name: Run frontend unit tests
run: |
cd src/frontend
npm test
- name: Run frontend integration tests
run: |
cd src/frontend
npm run test:integration
build-and-push:
name: Build and Push Docker Images
needs: [backend-tests, frontend-tests]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build backend Docker image
run: |
docker build -t podcast-marketing-backend:${{ github.sha }} -f src/api/Dockerfile src/api
- name: Build frontend Docker image
run: |
docker build -t podcast-marketing-frontend:${{ github.sha }} -f src/frontend/Dockerfile src/frontend
- name: Push images to ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY_BACKEND: podcast-marketing-backend
ECR_REPOSITORY_FRONTEND: podcast-marketing-frontend
run: |
docker tag podcast-marketing-backend:${{ github.sha }} $ECR_REGISTRY/$ECR_REPOSITORY_BACKEND:${{ github.sha }}
docker tag podcast-marketing-frontend:${{ github.sha }} $ECR_REGISTRY/$ECR_REPOSITORY_FRONTEND:${{ github.sha }}
docker push $ECR_REGISTRY/$ECR_REPOSITORY_BACKEND:${{ github.sha }}
docker push $ECR_REGISTRY/$ECR_REPOSITORY_FRONTEND:${{ github.sha }}
# Human tasks:
# - Set up AWS credentials as GitHub secrets (Critical)
# - Configure ECR repository details (Critical)
# - Review and adjust test coverage thresholds (Required)