Skip to content

Commit 5c9882e

Browse files
committed
Add workflow boilerplate.
0 parents  commit 5c9882e

File tree

5 files changed

+86
-0
lines changed

5 files changed

+86
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.10"]
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Cache dependencies
26+
uses: actions/cache@v3
27+
with:
28+
path: ~/.cache/pip
29+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }}
30+
restore-keys: |
31+
${{ runner.os }}-pip-${{ matrix.python-version }}-
32+
${{ runner.os }}-pip-
33+
34+
- name: Install dependencies
35+
run: |
36+
python -m pip install --upgrade pip
37+
pip install -r requirements.txt
38+
39+
- name: Run linting
40+
run: |
41+
pip install flake8
42+
flake8 .
43+
44+
- name: Run tests
45+
run: PYTHONPATH=src pytest
46+
47+
deploy:
48+
runs-on: ubuntu-latest
49+
needs: test # Ensures tests pass before deploying
50+
if: github.ref == 'refs/heads/main' # Only deploys from main branch
51+
52+
steps:
53+
- name: Checkout repository
54+
uses: actions/checkout@v4
55+
56+
- name: Set up Python
57+
uses: actions/setup-python@v4
58+
with:
59+
python-version: "3.10"
60+
61+
- name: Install dependencies
62+
run: |
63+
python -m pip install --upgrade pip
64+
pip install -r requirements.txt
65+
66+
- name: Deploy Application
67+
run: |
68+
echo "Deploying application..."
69+
# Add actual deployment commands here, e.g.:
70+
# scp -r . user@server:/path/to/app
71+
# ssh user@server "systemctl restart my-app"
72+
73+
- name: Notify Deployment Success
74+
run: echo "Deployment successful!"

README.md

Whitespace-only changes.

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pytest

src/hello.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def say_hello():
2+
return "Hello, World!"
3+
4+
5+
if __name__ == "__main__":
6+
print(say_hello())

tests/test_hello.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from src.hello import say_hello
2+
3+
4+
def test_say_hello():
5+
assert say_hello() == "Hello, World!"

0 commit comments

Comments
 (0)