-
Notifications
You must be signed in to change notification settings - Fork 1
150 lines (129 loc) · 4.84 KB
/
ci.yaml
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: ci
on:
push:
branches: [main]
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -e {0}
strategy:
fail-fast: false
matrix:
python: ['3.12']
os: [ubuntu-latest]
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python }}
MODULE: omnipath_server
PG_USER: omnipath
PG_PASSWORD: omnipath
PG_DB: omnipath
PG_HOST: localhost
PG_PORT: 5432
services:
postgres:
image: postgres:17
ports:
- 5432:5432
env:
POSTGRES_USER: ${{ env.PG_USER }}
POSTGRES_PASSWORD: ${{ env.PG_PASSWORD }}
POSTGRES_DB: ${{ env.PG_DB }}
steps:
- name: Check out main
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: System dependencies Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
sudo apt-get update
sudo apt-get install -y libcurl4-openssl-dev
- name: System dependencies OSX
if: ${{ matrix.os == 'macos-latest' }}
run: |
brew install openssl
export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@3/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig"
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: ${{ steps.cached-poetry-dependencies.outputs.cache-hit != 'true' }}
run: poetry install --no-interaction --no-root
- name: Install library
run: poetry install --no-interaction
- name: Wait for Postgres to be ready
run: |
echo 'Waiting for Postgres'
for i in {1..30}; do
if pg_isready -h $PG_HOST -p $PG_PORT -U $PG_USER; then
echo 'Postgres is ready after $((i * 2)) seconds'
break
fi
sleep 2
done
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
poetry run flake8 $MODULE \
--count \
--select=E9,F63,F7,F82 \
--show-source \
--statistics
# exit-zero treats all errors as warnings
poetry run flake8 $MODULE \
--count \
--exit-zero \
--max-complexity=10 \
--max-line-length=127 \
--statistics
- name: Set up Postgres connection config
run: |
echo 'user: ${{ env.PG_USER }}' > 'db_config.yaml'
echo 'password: ${{ env.PG_PASSWORD }}' >> 'db_config.yaml'
echo 'database: ${{ env.PG_DB }}' >> 'db_config.yaml'
echo 'host: ${{ env.PG_HOST }}' >> 'db_config.yaml'
echo 'port: ${{ env.PG_PORT }}' >> 'db_config.yaml'
- name: Tests and test coverage
if: ${{ github.event_name == 'push' }}
run: |
poetry run pytest -v \
--cov \
--color=yes \
--durations=0 \
--disable-warnings \
--db-config=db_config.yaml
- name: Tests
if: ${{ github.event_name == 'pull_request' }}
run: |
poetry run pytest -v \
--color=yes \
--durations=0 \
--disable-warnings
--db-config=db_config.yaml
- name: Upload coverage reports to Codecov
if: ${{ github.event_name == 'push' }}
env:
CODECOV_NAME: ${{ matrix.python }}-${{ matrix.os }}
run: |
poetry run codecovcli \
--verbose upload-process \
-t ${{ secrets.CODECOV_TOKEN }} \
-n 'std'-${{ github.run_id }}