Skip to content

Commit 2523a98

Browse files
author
Andrew Brookins
committed
WIP on CI action
1 parent 49654ee commit 2523a98

File tree

5 files changed

+266
-5
lines changed

5 files changed

+266
-5
lines changed

.github/dependabot.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: 2
2+
updates:
3+
4+
# Maintain dependencies for GitHub Actions
5+
- package-ecosystem: "github-actions"
6+
directory: "/"
7+
labels:
8+
- dependencies
9+
schedule:
10+
interval: "daily"
11+
12+
# Maintain dependencies for Python
13+
- package-ecosystem: "pip"
14+
directory: "/"
15+
labels:
16+
- dependencies
17+
schedule:
18+
interval: "daily"
19+
open-pull-requests-limit: 10

.github/workflows/ci.yml

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- '[0-9].[0-9]+' # matches to backport branches, e.g. 3.6
8+
tags: [ 'v*' ]
9+
pull_request:
10+
branches:
11+
- master
12+
- '[0-9].[0-9]+'
13+
- 'update/pre-commit-autoupdate'
14+
schedule:
15+
- cron: '0 6 * * *' # Daily 6AM UTC build
16+
17+
18+
jobs:
19+
20+
lint:
21+
name: Linter
22+
runs-on: ubuntu-latest
23+
timeout-minutes: 5
24+
steps:
25+
- name: Checkout
26+
uses: actions/[email protected]
27+
- name: Setup Python 3.9
28+
uses: actions/setup-python@v2
29+
with:
30+
python-version: 3.9
31+
#----------------------------------------------
32+
# ----- install & configure poetry -----
33+
#----------------------------------------------
34+
- name: Install Poetry
35+
uses: snok/install-poetry@v1
36+
with:
37+
virtualenvs-create: true
38+
virtualenvs-in-project: true
39+
installer-parallel: true
40+
#----------------------------------------------
41+
# load cached venv if cache exists
42+
#----------------------------------------------
43+
- name: Load cached venv
44+
id: cached-poetry-dependencies
45+
uses: actions/cache@v2
46+
with:
47+
path: .venv
48+
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
49+
#----------------------------------------------
50+
# install dependencies if cache does not exist
51+
#----------------------------------------------
52+
- name: Install dependencies
53+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
54+
run: poetry install --no-interaction --no-root
55+
#----------------------------------------------
56+
# install your root project, if required
57+
#----------------------------------------------
58+
- name: Install library
59+
run: poetry install --no-interaction
60+
#----------------------------------------------
61+
# run test suite
62+
#----------------------------------------------
63+
- name: Run linter
64+
run: |
65+
make lint
66+
# - name: Prepare twine checker
67+
# run: |
68+
# pip install -U twine wheel
69+
# python setup.py sdist bdist_wheel
70+
# - name: Run twine checker
71+
# run: |
72+
# twine check dist/*
73+
74+
test-unix:
75+
name: Test Unix
76+
needs: lint
77+
strategy:
78+
matrix:
79+
os: [ubuntu-latest]
80+
pyver: [3.6, 3.7, 3.8, 3.9, pypy3]
81+
redismod: ["edge", "preview", "latest"]
82+
fail-fast: false
83+
services:
84+
redis:
85+
image: redislabs/redismod:{{ matrix.redismod }}
86+
ports:
87+
# Maps port 6379 on service container to the host
88+
- 6379:6379
89+
# Set health checks to wait until redis has started
90+
options: >-
91+
--health-cmd "redis-cli ping"
92+
--health-interval 10s
93+
--health-timeout 5s
94+
--health-retries 5
95+
--load-module "/usr/lib/redis/modules/redisearch.so"
96+
--load-module "/usr/lib/redis/modules/rejson.so"
97+
runs-on: ${{ matrix.os }}
98+
timeout-minutes: 15
99+
env:
100+
OS: ${{ matrix.os }}
101+
INSTALL_DIR: ${{ github.workspace }}/redis
102+
steps:
103+
- name: Checkout
104+
uses: actions/[email protected]
105+
- name: Setup Python ${{ matrix.pyver }}
106+
uses: actions/setup-python@v2
107+
with:
108+
python-version: ${{ matrix.pyver }}
109+
#----------------------------------------------
110+
# ----- install & configure poetry -----
111+
#----------------------------------------------
112+
- name: Install Poetry
113+
uses: snok/install-poetry@v1
114+
with:
115+
virtualenvs-create: true
116+
virtualenvs-in-project: true
117+
installer-parallel: true
118+
#----------------------------------------------
119+
# load cached venv if cache exists
120+
#----------------------------------------------
121+
- name: Load cached venv
122+
id: cached-poetry-dependencies
123+
uses: actions/cache@v2
124+
with:
125+
path: .venv
126+
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
127+
#----------------------------------------------
128+
# install dependencies if cache does not exist
129+
#----------------------------------------------
130+
- name: Install dependencies
131+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
132+
run: poetry install --no-interaction --no-root
133+
#----------------------------------------------
134+
# install your root project, if required
135+
#----------------------------------------------
136+
- name: Install library
137+
run: poetry install --no-interaction
138+
- name: Run unittests (redismod:${{ matrix.redismod }}, ${{ matrix.os }})
139+
run: |
140+
make test
141+
poetry run coverage xml
142+
- name: Upload coverage
143+
uses: codecov/[email protected]
144+
with:
145+
file: ./coverage.xml
146+
flags: unit
147+
env_vars: OS
148+
fail_ci_if_error: false
149+
150+
deploy:
151+
name: Deploy
152+
runs-on: ubuntu-latest
153+
needs: test-unix
154+
# Run only on pushing a tag
155+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
156+
steps:
157+
- name: Checkout
158+
uses: actions/[email protected]
159+
- name: Setup Python 3.9
160+
uses: actions/setup-python@v2
161+
with:
162+
python-version: 3.9
163+
- name: Install dependencies
164+
run:
165+
python -m pip install -U pip wheel twine
166+
- name: Make dists
167+
run:
168+
python setup.py sdist bdist_wheel
169+
- name: PyPI upload
170+
env:
171+
TWINE_USERNAME: __token__
172+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
173+
run: |
174+
twine upload dist/*

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ format: $(INSTALL_STAMP)
4444

4545
.PHONY: test
4646
test: $(INSTALL_STAMP)
47-
#$(POETRY) run pytest ./tests/ --cov-report term-missing --cov-fail-under 100 --cov $(NAME)
48-
$(POETRY) run pytest -s -vv ./tests/
47+
$(POETRY) run pytest -s -vv ./tests/ --cov-report term-missing --cov $(NAME)
4948

5049
.PHONY: shell
5150
shell: $(INSTALL_STAMP)
@@ -55,6 +54,5 @@ shell: $(INSTALL_STAMP)
5554
redis:
5655
docker-compose up -d
5756

58-
5957
.PHONY: all
60-
all: redis $(INSTALL_STAMP) lint test
58+
all: redis $(INSTALL_STAMP) lint test

poetry.lock

Lines changed: 69 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ black = "^21.9b0"
2727
isort = "^5.9.3"
2828
flake8 = "^4.0.1"
2929
bandit = "^1.7.0"
30+
coverage = "^6.0.2"
31+
pytest-cov = "^3.0.0"
3032

3133

3234
[tool.poetry.scripts]

0 commit comments

Comments
 (0)