-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (69 loc) · 2.14 KB
/
ci_cd_pipeline.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
name: ETL CI/CD Pipeline
on:
push:
branches:
- main
paths-ignore:
- 'README.md'
pull_request:
branches:
- main
paths:
- 'src/**'
- 'tests/**'
- 'docker-compose.yml'
- '**/*.py'
- '**/*.sql'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Create virtual environment
run: |
python -m venv venv
source venv/bin/activate
- name: Install dependencies
run: |
source venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install Docker and Docker Compose
run: |
# Remove any existing containerd or docker packages
sudo apt-get remove -y containerd containerd.io
# Update the apt package index
sudo apt-get update
# Install Docker
sudo apt-get install -y docker.io
# Install Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
- name: Build and start Docker containers with docker-compose
run: |
docker-compose -f docker-compose.yml up -d
sleep 10 # Wait for the DB to start properly (adjust if needed)
- name: Run database setup
run: |
source venv/bin/activate
python sql/sqlite_db/setup_db.py
- name: Set execute permission for load_data.py
run: |
chmod +x tests/load_data.py
- name: Load data into database
run: |
source venv/bin/activate
python tests/load_data.py
- name: Run tests
run: |
source venv/bin/activate
pytest tests/test_etl.py
continue-on-error: true
- name: Clean up Docker containers
run: |
docker-compose -f docker-compose.yml down