-
Notifications
You must be signed in to change notification settings - Fork 37
134 lines (116 loc) · 3.42 KB
/
run-tests.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Tests
on:
pull_request:
push:
branches:
- master
tags:
- "**"
env:
DOCKER_REGISTRY: ghcr.io
DOCKER_IMAGE: ${{ github.repository }}
jobs:
check-formatting:
name: Check formatting
runs-on: ubuntu-latest
container: debian:bullseye
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
apt-get update
apt-get install -y \
$(xargs < dependencies.apt.txt) \
python3-setuptools
python3 -m pip install \
black
- name: Run black
run: |
python3 -m black --check --diff .
check-typing:
name: Static type check
runs-on: ubuntu-latest
container: debian:bullseye
steps:
- uses: actions/checkout@v4
- name: Prime pip cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: |
pip-${{ runner.os }}-${{ hashFiles('requirements.txt') }}
restore-keys: |
pip-${{ runner.os }}-
- name: Install dependencies
run: |
apt-get update
apt-get install -y \
$(xargs < dependencies.apt.txt) \
python3-setuptools
python3 -m pip install \
mypy \
lxml-stubs
- name: Prime mypy cache
uses: actions/cache@v3
with:
path: .mypy_cache
key: |
mypy-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
mypy-${{ runner.os }}-
- name: Run mypy check
run: |
python3 -m mypy \
--install-types \
--non-interactive \
src
build-and-test-container:
name: Build and test container
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build container
id: docker_build
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
tags: ${{ env.DOCKER_IMAGE }}:build
push: false
load: true
cache-from: type=registry,ref=${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }}:latest
cache-to: type=inline
- name: Run tests in container
run: |
docker run -v $PWD:$PWD -w $PWD --entrypoint bash ${{ env.DOCKER_IMAGE }}:build -c \
"apt-get install python3-coverage && python3 -m coverage run -m unittest discover --verbose --buffer"
- name: Submit code coverage to Coveralls.io
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: |
sudo apt-get install -y \
python3-setuptools
sudo python3 -m pip install \
coveralls
python3 -m coveralls
continue-on-error: true
- name: Login to registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push image to registry
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
tags: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }}:latest
push: true