Skip to content

Commit 44a4b6f

Browse files
Merge pull request #44 from dmitryashutov/master
Setup GitHub actions
2 parents d846f34 + f670722 commit 44a4b6f

16 files changed

+109
-41
lines changed

.env.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PYTHON=3.11
2+
AIDBOX_LICENSE=

.github/workflows/build.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Aidbox Python SDK
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
include:
13+
- python-version: 3.8
14+
- python-version: 3.9
15+
- python-version: "3.10"
16+
- python-version: "3.11"
17+
18+
env:
19+
PYTHON: ${{ matrix.python-version }}
20+
AIDBOX_LICENSE: ${{ secrets.AIDBOX_LICENSE}}
21+
steps:
22+
- uses: actions/checkout@v3
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
- name: Upgrade pip
28+
run: |
29+
python -m pip install --upgrade pip
30+
- name: Run tests
31+
run: ./run_test.sh
32+
shell: bash
33+
# - name: Upload coverage to Codecov
34+
# uses: codecov/codecov-action@v3
35+
# with:
36+
# token: ${{ secrets.CODECOV_TOKEN }}
37+
# env_vars: PYTHON
38+
# fail_ci_if_error: true
39+
# files: ./coverage.xml
40+
# flags: unittests
41+
# name: codecov-umbrella
42+
# verbose: true

.github/workflows/publish.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Publish to https://pypi.org/
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
packages: write
12+
contents: read
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Set up Python 3.11
16+
uses: actions/setup-python@v3
17+
with:
18+
python-version: "3.11"
19+
- name: Install wheel and build
20+
run: pip install wheel build
21+
- name: Build a binary wheel and a source tarball
22+
run: python -m build
23+
- name: Publish package
24+
uses: pypa/gh-action-pypi-publish@release/v1
25+
with:
26+
user: __token__
27+
password: ${{ secrets.PYPI_API_TOKEN }}

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM python:3.11
1+
ARG PYTHON_VERSION
2+
FROM python:$PYTHON_VERSION
23
RUN pip install pipenv
34

45
RUN mkdir /app

Pipfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,3 @@ isort = "~=5.11.2"
2020
autohooks = "~=22.11.2"
2121
autohooks-plugin-isort = "~=22.8.0"
2222
autohooks-plugin-black = "~=22.11.0"
23-
24-
[requires]
25-
python_version = "3.11"

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# aidbox-python-sdk
22

3-
1. Create a python 3.6+ environment `python3 -m venv env`
3+
1. Create a python 3.8+ environment `pyenv `
44
2. Set env variables and activate virtual environment `source activate_settings.sh`
5-
2. Install the required packages with `pip install -r requirements/base.txt -r requirements/dev.txt`
5+
2. Install the required packages with `pipenv install --dev`
66
3. Make sure the app's settings are configured correctly (see `activate_settings.sh` and `aidbox_python_sdk/settings.py`). You can also
77
use environment variables to define sensitive settings, eg. DB connection variables (see example `.env-ptl`)
88
4. You can then run example with `python example.py`.
99

10-
Add `APP_FAST_START_MODE=TRUE` to .env for fast start mode.
10+
Add `APP_FAST_START_MODE=TRUE` to env_tests for fast start mode.
1111

1212
# Getting started
1313
## Minimal application
@@ -20,7 +20,7 @@ settings = Settings(**{})
2020
sdk = SDK(settings, resources=resources, seeds=seeds)
2121

2222
async def create_app():
23-
return await _create_app(settings, sdk, debug=True)
23+
return await _create_app(sdk)
2424

2525
```
2626

docker-compose.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ services:
1717
ports:
1818
- "8080:8080"
1919
env_file:
20-
- .env
20+
- env_tests
2121
environment:
2222
PGHOST: database
2323
PGDATABASE: devbox
2424
PGPORT: 5432
2525
PGUSER: postgres
2626
PGPASSWORD: postgres
2727
AIDBOX_CONFIG: /var/config/config.edn
28+
AIDBOX_LICENSE: ${AIDBOX_LICENSE}
2829
volumes:
2930
- ./config:/var/config
3031
devbox-healthcheck:
@@ -40,7 +41,10 @@ services:
4041
timeout: 20s
4142
retries: 100
4243
app:
43-
build: ./
44+
build:
45+
context: .
46+
args:
47+
PYTHON_VERSION: ${PYTHON:-3.11}
4448
command: ["pipenv", "run", "pytest"]
4549
depends_on:
4650
devbox-healthcheck:
@@ -49,7 +53,7 @@ services:
4953
links:
5054
- devbox
5155
env_file:
52-
- .env
56+
- env_tests
5357
ports:
5458
- "8081:8081"
5559
volumes:

.env-tpl renamed to env_tests

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# Visit https://aidbox.app/ui/portal to get a licence key
2-
AIDBOX_LICENSE=
3-
4-
# comment to get unsecured box
51
AIDBOX_CLIENT_ID=root
62
AIDBOX_CLIENT_SECRET=secret
73
AIDBOX_BASE_URL=http://devbox:8080
@@ -23,3 +19,5 @@ AIO_APP_PATH=.
2319

2420
OPENID_RSA=/var/config/jwtRS256.key
2521
OPENID_RSA_PUB=/var/config/jwtRS256.key.pub
22+
23+
AIDBOX_STDOUT_PRETTY=debug

example/.env.tpl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
APP_FAST_START_MODE=True
2-
AIDBOX_LICENSE_ID=
3-
AIDBOX_LICENSE_KEY=
2+
AIDBOX_LICENSE=
43

54
AIDBOX_CLIENT_ID=root
65
AIDBOX_CLIENT_SECRET=secret

example/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
## Black autoformater
44
```
5-
brew install pre-commit
5+
pip install autohooks autohooks-plugin-black autohooks-plugin-isort
66
pre-commit install
77
```
88

99
## Tests
10-
To run tests locally, copy `.env.tpl` to `.env` and specify `TESTS_AIDBOX_LICENSE_ID` and `TESTS_AIDBOX_LICENSE_KEY` [https://license-ui.aidbox.app/](https://license-ui.aidbox.app/).
10+
To run tests locally, copy `.env.tpl` to `.env` and specify `TESTS_AIDBOX_LICENSE`[https://license-ui.aidbox.app/](https://license-ui.aidbox.app/).
1111

1212

13-
Build images using `docker-compose -f docker-compose.tests.yaml build`.
13+
Build images using `docker compose -f docker-compose.tests.yaml build`.
1414

1515

1616
After that, just start `./run_test.sh` or `./run_test.sh tests/test_base.py` (if you want to run the particular file/test).

0 commit comments

Comments
 (0)