-
Notifications
You must be signed in to change notification settings - Fork 52
92 lines (91 loc) · 3.16 KB
/
pytest-docker.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
name: 'Pytest Docker'
on:
push:
paths:
- '**.py'
- '**.js'
- '**.scss'
- '**.jinja2'
- '.flaskenv'
- '.testenv'
- 'requirements/base.txt'
- 'requirements/test.txt'
- '.github/workflows/pytest-docker.yml'
- 'Dockerfile'
- 'Makefile'
- 'pyproject.toml'
- 'docker-compose.ci.yml'
- 'docker/entrypoints/ci.sh'
- 'docker/initdb.sh'
- 'package.json'
- 'package-lock.json'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build funnel-ci image
id: build-funnel-ci
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
target: ci
tags: funnel-ci
load: true
push: false
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Set permissions for coverage
run: docker compose -f docker-compose.ci.yml run --rm -u root --entrypoint "" --no-deps --quiet-pull main chown -R 1000:1000 coverage
- name: Test with pytest
run: docker compose -f docker-compose.ci.yml up --quiet-pull --no-attach db --no-attach redis --no-log-prefix --exit-code-from main
- name: Upload coverage report to Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
path-to-lcov: coverage/funnel.lcov
flag-name: docker-3.11
- name: Set short git commit SHA
if: ${{ github.ref_name == 'main' || github.ref_name == 'docker' }}
id: sha
run: |
short_sha=$(git rev-parse --short ${{ github.sha }})
echo "short=$short_sha" >> "$GITHUB_OUTPUT"
- name: Login to Docker Hub
if: ${{ github.ref_name == 'main' || github.ref_name == 'docker' }}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: ${{ github.ref_name == 'main' || github.ref_name == 'docker' }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_WRITE_TOKEN }}
- name: Build & push funnel image
if: ${{ github.ref_name == 'main' || github.ref_name == 'docker' }}
id: build-funnel
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
target: app
tags: |
hasgeek/funnel:${{ github.ref_name }}
hasgeek/funnel:sha-${{ steps.sha.outputs.short }}
ghcr.io/hasgeek/funnel:${{ github.ref_name }}
ghcr.io/hasgeek/funnel:sha-${{ steps.sha.outputs.short }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max