-
Notifications
You must be signed in to change notification settings - Fork 6
91 lines (83 loc) · 2.66 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
name: CI
on:
schedule:
- cron: '5 4 * * 1'
push:
branches: [ master ]
pull_request:
jobs:
test:
# Due to drop of out-of-the-box support in ubuntu-22.04 for MongoDB 5.0,
# we cannot use ubuntu-latest. have to consider this in the future. as ubuntu-20.04 will be OBSOLETE in 2025.
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ['3.10','3.12']
services:
mongodb:
image: mongo:5.0.14
env:
MONGO_INITDB_DATABASE: amivapi
options: >-
--health-cmd mongo
--health-start-period 20s
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 27017:27017
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions setuptools
- name: Create MongoDB User
run: mongo test_amivapi --eval 'db.createUser({user:"test_user",pwd:"test_pw",roles:["readWrite"]});'
- name: Test with tox
run: tox
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: unittests
fail_ci_if_error: true
verbose: true
build:
runs-on: ubuntu-latest
needs: test
env:
IMAGE_NAME: amiveth/amivapi
steps:
- uses: actions/checkout@v4
# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
# Login against a Docker registry except on PR
- name: Log into Docker Hub registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}
tags: type=raw,value=latest
# Build and push Docker image with Buildx (don't push on PR)
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
context: .
pull: true
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}