Skip to content

Commit

Permalink
Setup GitHub worflows (#97)
Browse files Browse the repository at this point in the history
* Add pyproject.toml

* Remove setup files

* Remove unnecessary tables in the pyproject.toml

* Move tox config to pyproject.toml

* Add build workflow

* Add Pipfile

* Update aidbox launch config

* Skip aiohttp.request mocking tests

Fix once #93 is done

* Remove pytest-mock

* Add mised import to test

* Update build workflow config

* Remove python required version in Pipfile

* Add docker services to build workflow

* Pass env vars for Aidbox container

* Fix typo in the build config

* Fix typoes

* Disable aidbox healthcheck service

* Remove services description

* Move test command to the shell script

* Remove setup python step
  • Loading branch information
dmitryashutov authored Jan 9, 2023
1 parent 682db6b commit 1b7c062
Show file tree
Hide file tree
Showing 18 changed files with 851 additions and 202 deletions.
1 change: 1 addition & 0 deletions .env.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AIDBOX_LICENSE=
34 changes: 34 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: fhirpy

on:
- push
- pull_request

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- python-version: 3.8
- python-version: 3.9
- python-version: "3.10"
- python-version: "3.11"
env:
PYTHON: ${{ matrix.python-version }}
AIDBOX_LICENSE: ${{ secrets.AIDBOX_LICENSE}}
steps:
- uses: actions/checkout@v3
- name: Run tests
run: ./run_test.sh
shell: bash
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v3
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# env_vars: PYTHON
# fail_ci_if_error: true
# files: ./coverage.xml
# flags: unittests
# name: codecov-umbrella
# verbose: true
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ARG PYTHON_VERSION
FROM python:$PYTHON_VERSION
RUN pip install pipenv

RUN mkdir /app
WORKDIR /app

COPY Pipfile Pipfile.lock ./
RUN pipenv install --dev

# SQLAlchemy vulnerability - https://pyup.io/v/51668/742
# Remove ignore option once fix is released or upgrade to version 2
# RUN pipenv check -i 51668
COPY . .

EXPOSE 8081
17 changes: 17 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]

[dev-packages]
requests = "==2.25.1"
pytest = ">=6.2.4"
pytest-cov = "==2.12.0"
aiohttp = "==3.7.4"
pytest-asyncio = "==0.15.1"
responses = "==0.13.3"
pytz = "==2021.1"
black = "==22.10.0"
pre-commit = "==2.20.0"
594 changes: 594 additions & 0 deletions Pipfile.lock

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions devbox/docker-compose.tests.m1.yaml

This file was deleted.

28 changes: 0 additions & 28 deletions devbox/docker-compose.tests.yaml

This file was deleted.

13 changes: 5 additions & 8 deletions devbox/run_devbox.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
#!/bin/sh

if [ -z "${AIDBOX_LICENSE_KEY_TESTS}" ]; then
echo "AIDBOX_LICENSE_KEY_TESTS is required to run tests"
exit 1
if [ -f ".env" ]; then
export `cat .env`
fi

if [ -z "${AIDBOX_LICENSE_ID_TESTS}" ]; then
echo "AIDBOX_LICENSE_ID_TESTS is required to run tests"
if [ -z "${AIDBOX_LICENSE}" ]; then
echo "AIDBOX_LICENSE is required to run tests"
exit 1
fi

docker-compose -f docker-compose.tests.yaml pull
docker-compose -f docker-compose.tests.yaml run dockerize
docker compose -f docker-compose.tests.yaml up --exit-code-from devbox devbox
exit $?
47 changes: 47 additions & 0 deletions docker-compose.tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
services:
devbox:
image: "healthsamurai/aidboxone:edge"
depends_on:
- devbox-db
ports:
- 8080:8080
links:
- "devbox-db:database"
env_file:
- env_tests
environment:
AIDBOX_LICENSE: ${AIDBOX_LICENSE}
devbox-db:
image: healthsamurai/aidboxdb:14.5
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: devbox
devbox-healthcheck:
image: curlimages/curl
entrypoint: /bin/sleep 10000
links:
- devbox
depends_on:
- devbox
healthcheck:
test: curl --fail http://devbox:8080/__healthcheck || exit 1
interval: 1s
timeout: 20s
retries: 100
app:
build:
context: .
args:
PYTHON_VERSION: ${PYTHON:-3.11}
command: ["pipenv", "run", "pytest"]
depends_on:
devbox-healthcheck:
condition:
service_healthy
links:
- devbox
ports:
- "8081:8081"
volumes:
- .:/app
File renamed without changes.
99 changes: 99 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"

[project]
name = "fhirpy"
description = "FHIR client for python"
readme = "README.md"
license = { file = "LICENSE.md" }
keywords = ["fhir"]
dynamic = ["version"]
authors = [{ name = "beda.software", email = "[email protected]" }]
dependencies = ["requests>=2.25.1", "aiohttp>=3.6.3", "pytz"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Software Development :: Libraries :: Python Modules",
]
requires-python = ">=3.8"

[project.optional-dependencies]
test = ["pytest>=6.2.4", "pytest-asyncio>=0.15.1", "responses>=0.13.3"]

[project.urls]
Homepage = "https://github.com/beda-software/fhir-py"
Documentation = "https://github.com/beda-software/fhir-py#readme"
Source = "https://github.com/beda-software/fhir-py.git"

[tool.tox]
legacy_tox_ini = """
[pytest]
addopts=--tb=short
[tox]
envlist =
py38
py39
py310
py311
skip_missing_interpreters = true
requires =
virtualenv>=16.7.8
pip>=19.3.1
[gh-actions]
python =
3.8: py38
3.9: py39
3.10: py310
3.11: py311
[testenv]
passenv =
TOXENV
CI
CODECOV_*
commands =
pytest --doctest-modules --cov=./fhirpy tests
setenv =
PYTHONDONTWRITEBYTECODE=1
PYTHONWARNINGS=once
deps =
-r requirements.txt
"""

[tool.black]
line-length = 100
target-version = ['py311']
exclude = '''
(
/(
| \.git
| \.pytest_cache
| pyproject.toml
| dist
)/
)
'''

[tool.isort]
profile = "black"
line_length = 100
skip = [".gitignore"]

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-ra -q --color=yes"
testpaths = ["tests"]
log_cli = true
log_cli_level = "INFO"
9 changes: 0 additions & 9 deletions requirements.txt

This file was deleted.

3 changes: 3 additions & 0 deletions run_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker compose -f docker-compose.tests.yaml up --quiet-pull --exit-code-from app app
3 changes: 0 additions & 3 deletions setup.cfg

This file was deleted.

55 changes: 0 additions & 55 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion tests/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from aiohttp import BasicAuth


FHIR_SERVER_URL = os.environ.get("FHIR_SERVER_URL", "http://localhost:8080/fhir")
FHIR_SERVER_URL = os.environ.get("FHIR_SERVER_URL", "http://devbox:8080/fhir")
FHIR_SERVER_AUTHORIZATION = os.environ.get(
"FHIR_SERVER_AUTHORIZATION", BasicAuth("root", "secret").encode()
)
Loading

0 comments on commit 1b7c062

Please sign in to comment.