Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👷 Run CI (lint, tests) on Github Workflows #23

Merged
merged 8 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 0 additions & 73 deletions .circleci/config.yml

This file was deleted.

61 changes: 61 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

name: ✅ CI

on:
pull_request:
types: [opened, reopened, edited, synchronize, closed]

concurrency:
group: ci-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-20.04
timeout-minutes: 10
steps:
- name: 👩‍💻 Checkout code
uses: actions/checkout@v3

- name: 🐍 Setup Python
uses: actions/setup-python@v3
with:
python-version: '3.8'

- name: 📦 Install deps
run: |
pip install black

- name: 🚨 Lint code
run: |
black --check --line-length 80 kf_update_dbgap_consent tests

test:
runs-on: ubuntu-20.04
timeout-minutes: 10
steps:
- name: 👩‍💻 Checkout code
uses: actions/checkout@v3

- name: 🐳 Start Dataservice docker-compose
run: |
./bin/setup_dataservice.sh

- name: 🐍 Setup Python
uses: actions/setup-python@v3
with:
python-version: '3.8'

- name: 📦 Install deps
run: |
pip install --upgrade virtualenv
virtualenv -p python3 venv
source venv/bin/activate
pip install -r dev-requirements.txt
pip install -e .

- name: ✅ Test
run: |
source venv/bin/activate
pytest tests

165 changes: 165 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

### Ingest stuff
cached_schema.json
*.tsv
*.csv
*.xls
*.xlsx
*.txt

# Ingest outputs
kf_ingest_packages/packages/**/output/*

# Exclude uid cache db
!kf_ingest_packages/packages/**/output/*.db

# Exclude count analysis report
!kf_ingest_packages/packages/**/counts*.log

# Exclude ingest logs
!kf_ingest_packages/packages/**/ingest*.log

# dot files and folders
.*

# Exclude github workflows
!/.github

# Exclude validation test results
!kf_ingest_packages/packages/**/validation_results/*

# Validation Report Site
## Build dir
web/site

# CI Artifacts
kf-api-dataservice
23 changes: 23 additions & 0 deletions bin/health-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# Dataservice Health Check

set -e

START_TIME=$SECONDS
DATASERVICE_ENDPOINT=${DATASERVICE_ENDPOINT:-http://localhost:5000}

echo "⛑️ Waiting for service to become healthy ..."
until $(curl --output /dev/null --head --silent --fail $DATASERVICE_ENDPOINT/status)
do
echo -n "."
sleep 2
done

ELAPSED=$((( SECONDS - START_TIME ) / 60 ))
FORMATTED_ELAPSED=$(printf "%.2f" $ELAPSED)
echo ""
echo "Elapsed time $FORMATTED_ELAPSED minutes"

echo "✅ --- Development environment setup complete! ---"

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

# Dataservice Setup

set -e

if [ -d "./kf-api-dataservice" ];
then
cd kf-api-dataservice
git pull
cd ..
else
git clone --depth 1 https://github.com/kids-first/kf-api-dataservice.git
fi
cp kf-api-dataservice/.env.sample kf-api-dataservice/.env
cp docker-compose.yml kf-api-dataservice/
docker-compose -f kf-api-dataservice/docker-compose.yml up -d --build
./bin/health-check.sh
36 changes: 36 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '3'

services:
dataservice_pg:
container_name: dataservice_pg
image: postgres:11.1
env_file:
- .env
environment:
POSTGRES_DB: "${DATASERVICE_DB}"
POSTGRES_USER: "${DATASERVICE_DB_USER}"
POSTGRES_PASSWORD: "${DATASERVICE_DB_PASSWORD}"
ports:
- "5432:5432"
dataservice:
container_name: dataservice
build:
context: .
target: test
command: /bin/ash -c "sleep 5; ./bin/run.sh"
volumes:
- .:/app
ports:
- "5000:80"
env_file:
- .env
environment:
FLASK_CONFIG: "${FLASK_CONFIG}"
FLASK_APP: "${FLASK_APP}"
PG_HOST: "${DATASERVICE_PG_HOST}"
PG_PORT: "${DATASERVICE_PG_PORT}"
PG_NAME: "${DATASERVICE_DB}"
PG_USER: "${DATASERVICE_DB_USER}"
PG_PASS: "${DATASERVICE_DB_PASSWORD}"
depends_on:
- dataservice_pg