-
Notifications
You must be signed in to change notification settings - Fork 3
98 lines (79 loc) · 2.61 KB
/
main.yml
File metadata and controls
98 lines (79 loc) · 2.61 KB
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
name: Continuous Integration
on:
push:
branches: [master]
env:
IMAGE: ghcr.io/${{ github.repository }}/web-app
jobs:
build:
name: Build Docker Image
runs-on: ubuntu-18.04
steps:
- name: Checkout master
uses: actions/checkout@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Login to Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Build and Push to GhCR
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./fastapi-prophet
file: ./fastapi-prophet/Dockerfile.prod
push: true
tags: ${{ env.IMAGE }}:latest
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
test:
name: Test Docker Image
runs-on: ubuntu-18.04
needs: build
steps:
- name: Checkout master
uses: actions/checkout@v2
- name: Login to Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Pull images
run: docker pull ${{ env.IMAGE }}:latest || true
- name: Run container
run: |
docker run \
-d \
--name prophet \
-v "$(pwd)"/reports:/reports \
-e PORT=8765 \
-e ENVIRONMENT=dev \
-e DATABASE_TEST_URL=sqlite:///sqlite.db \
-e DATABASE_URL=sqlite:///sqlite_prod.db \
-p 5003:8765 \
${{ env.IMAGE }}:latest
- name: Install requirements
run: docker exec prophet pip install -r ./requirements-dev.in || true
- name: Print logs
run: docker logs prophet
- name: Run tests and generate coverage report
run: docker exec prophet pytest --cov-report=xml --cov=./ -p no:warnings -vv
- name: Place coverage report in shared volume
run: docker exec prophet bash -c "mv coverage.xml /reports/"
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_PAT }}
files: reports/coverage.xml
directory: reports
- name: Flake8
run: docker exec prophet python -m flake8 .
- name: Black
run: docker exec prophet python -m black . --check
- name: isort
run: docker exec prophet python -m isort . --check-only