Skip to content

Commit

Permalink
Merge pull request #11 from BBMRI-cz/CI_pipeline
Browse files Browse the repository at this point in the history
Ci pipeline
  • Loading branch information
SimonKonar authored Oct 26, 2024
2 parents d68c7e7 + 57b2c99 commit 188db2d
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/scripts/wait-for-url.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash -e

URL=$1
START_EPOCH="$(date +"%s")"

eclipsed() {
EPOCH="$(date +"%s")"
echo $((EPOCH - START_EPOCH))
}

# wait at maximum 120 seconds
while [[ ($(eclipsed) -lt 120) && ("$(curl -s -o /dev/null -w '%{response_code}' "$URL")" != "200") ]]; do
sleep 2
done
76 changes: 76 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: CI test

on:
push:
branches: [ "master" ]
pull_request:


jobs:
py-lint:
name: Lint
continue-on-error: true
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'

- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run pylint
run: pylint --recursive=y .

unit-tests:
name: Unit tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'

- name: Run unit tests
run: make test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
flags: unit

integration-tests:
needs: unit-tests
name: Integration tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'

- name: Run integration tests
run: make integration

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
flags: integration
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
PYTHON_INTERPRETER = python3
PYTEST_COMMAND = $(PYTHON_INTERPRETER) -m pytest
PYTEST_ARGS = -v -p no:cacheprovider --cov-report=xml --cov=./

.PHONY: test setup clean validate
setup: requirements.txt ## Install required packages
pip install -r requirements.txt
test: setup ## Run unit test
$(PYTEST_COMMAND) $(PYTEST_ARGS) test/unit
integration: setup ## Run integration test
docker run --name blaze --rm -d -e JAVA_TOOL_OPTIONS=-Xmx2g -p 8080:8080 samply/blaze:latest
.github/scripts/wait-for-url.sh http://localhost:8080/health
$(PYTEST_COMMAND) $(PYTEST_ARGS) test/service
docker stop blaze
clean:
rm -rf __pycache__

0 comments on commit 188db2d

Please sign in to comment.