Skip to content

Commit

Permalink
ci: migrate to GH Actions (#116)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Kanitz <alexander.kanitz@alumni.ethz.ch>
  • Loading branch information
kushagra189 and uniqueg committed Apr 6, 2022
1 parent 71433c2 commit f0905d0
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 120 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package

on:
push:
branches: [ dev ]
pull_request:
branches: [ dev ]

jobs:
Test:
name: Run linting and unit tests
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install requirements
run: |
pip install -e .
pip install -r requirements_dev.txt
- name: Lint with flake8
run: flake8
- name: Calculate unit test coverage
run: |
coverage run --source foca -m pytest
coverage xml
- name: Submit Report to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
fail_ci_if_error: true
verbose: true
- name: Run tests on petstore app
run: |
cd ./examples/petstore
docker-compose up --build -d
cd ../..
sleep 10
pytest ./tests/integration_tests.py
Docker:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version-tag: [["3.7", "3.7"], ["3.8", "3.8"], ["3.9", "3.9"], ["3.9", "latest"]]

steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Build & Publish image to DockerHub
env:
docker_username: ${{ secrets.DOCKER_USERNAME }}
docker_password: ${{ secrets.DOCKER_PASSWORD }}
docker_org: ${{ secrets.DOCKER_ORG }}
repo_name: ${{ github.event.repository.name }}
run: |
export branch_name=${GITHUB_HEAD_REF##*/}
if [[ "$branch_name" == "dev" ]]; then
export tag="$(date '+%Y%m%d')"
else
export tag=${branch_name}
fi
if [[ ${{ matrix.python-version-tag[1] }} == "latest" ]]; then
export tag=${{ matrix.python-version-tag[1] }}
else
export tag=${tag}-py${{ matrix.python-version-tag[1] }}
fi
docker build . -t ${docker_org}/${repo_name}:latest \
-f docker/Dockerfile_py${{ matrix.python-version-tag[0] }}
docker tag ${docker_org}/${repo_name} ${docker_org}/${repo_name}:${tag}
echo $docker_password | docker login -u $docker_username --password-stdin
if [[ "$tag" == "latest" ]]; then
if [[ "$branch_name" == "dev" ]]; then
docker push ${docker_org}/${repo_name}:${tag}
fi
else
docker push ${docker_org}/${repo_name}:${tag}
fi
rm ${HOME}/.docker/config.json
92 changes: 0 additions & 92 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -489,13 +489,13 @@ question etc.
![Logo_banner][img-logo-banner]

[badge-build-status]: <https://travis-ci.com/elixir-cloud-aai/foca.svg?branch=dev>
[badge-coverage]: <https://img.shields.io/coveralls/github/elixir-cloud-aai/foca>
[badge-coverage]: <https://codecov.io/gh/elixir-cloud-aai/foca/branch/dev/graph/badge.svg?branch=dev>
[badge-docs]: <https://readthedocs.org/projects/foca/badge/>
[badge-github-tag]: <https://img.shields.io/github/v/tag/elixir-cloud-aai/foca?color=C39BD3>
[badge-license]: <https://img.shields.io/badge/license-Apache%202.0-blue.svg>
[badge-pypi]: <https://img.shields.io/pypi/v/foca.svg?style=flat&color=C39BD3>
[badge-url-build-status]: <https://travis-ci.com/elixir-cloud-aai/foca>
[badge-url-coverage]: <https://coveralls.io/github/elixir-cloud-aai/foca>
[badge-url-coverage]: <https://codecov.io/gh/elixir-cloud-aai/foca?branch=dev>
[badge-url-docs]: <https://foca.readthedocs.io/en/latest/>
[badge-url-github-tag]: <https://github.com/elixir-cloud-aai/foca/releases>
[badge-url-license]: <http://www.apache.org/licenses/LICENSE-2.0>
Expand Down
2 changes: 1 addition & 1 deletion foca/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""FOCA root package."""

__version__ = '0.7.0'
__version__ = '0.8.0'
22 changes: 11 additions & 11 deletions foca/foca.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,26 @@ def foca(config: Optional[str] = None) -> App:

# Parse config parameters and format logging
conf = ConfigParser(config, format_logs=True).config
logger.info(f"Log formatting configured.")
logger.info("Log formatting configured.")
if config:
logger.info(f"Configuration file '{config}' parsed.")
else:
logger.info(f"Default app configuration used.")
logger.info("Default app configuration used.")

# Create Connexion app
cnx_app = create_connexion_app(conf)
logger.info(f"Connexion app created.")
logger.info("Connexion app created.")

# Register error handlers
cnx_app = register_exception_handler(cnx_app)
logger.info(f"Error handler registered.")
logger.info("Error handler registered.")

# Enable cross-origin resource sharing
if(conf.security.cors.enabled is True):
enable_cors(cnx_app.app)
logger.info(f"CORS enabled.")
logger.info("CORS enabled.")
else:
logger.info(f"CORS not enabled.")
logger.info("CORS not enabled.")

# Register OpenAPI specs
if conf.api.specs:
Expand All @@ -58,23 +58,23 @@ def foca(config: Optional[str] = None) -> App:
specs=conf.api.specs,
)
else:
logger.info(f"No OpenAPI specifications provided.")
logger.info("No OpenAPI specifications provided.")

# Register MongoDB
if conf.db:
cnx_app.app.config['FOCA'].db = register_mongodb(
app=cnx_app.app,
conf=conf.db,
)
logger.info(f"Database registered.")
logger.info("Database registered.")
else:
logger.info(f"No database support configured.")
logger.info("No database support configured.")

# Create Celery app
if conf.jobs:
create_celery_app(cnx_app.app)
logger.info(f"Support for background tasks set up.")
logger.info("Support for background tasks set up.")
else:
logger.info(f"No support for background tasks configured.")
logger.info("No support for background tasks configured.")

return cnx_app
10 changes: 5 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
addict==2.2.1
celery==5.2.2
connexion==2.7.0
Flask==1.1.2
connexion==2.11.2
cryptography==36.0.2
Flask==2.0.3
Flask-Cors==3.0.9
Flask-PyMongo==2.3.0
mongomock==3.19.0
pydantic==1.8.2
PyJWT==1.7.1
pymongo==3.10.1
PyYAML==5.4
requests==2.23.0
requests==2.27.1
swagger-ui-bundle==0.0.6
toml==0.10.0
typing==3.7.4.1
Werkzeug==1.0.1
Werkzeug==2.0.3
13 changes: 6 additions & 7 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
coverage==5.1
coveralls==2.0.0
flake8==3.7.9
mongomock==3.19.0
pylint==2.5.3
pytest==5.4.3
python-semantic-release==7.15.0
coverage==6.3.2
flake8==4.0.1
mongomock==4.0.0
pylint==2.13.2
pytest==7.1.1
python-semantic-release==7.27.0
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[flake8]
exclude = .git,venv,env
exclude = .git,.eggs,build,venv,env
max-line-length = 79

[semantic_release]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@
include_package_data=True,
setup_requires=[
"setuptools_git==1.2",
"twine==3.1.1"
"twine==3.8.0"
],
)

0 comments on commit f0905d0

Please sign in to comment.