Skip to content

Commit

Permalink
ci: replace Travis CI with GH Actions (#64)
Browse files Browse the repository at this point in the history
* replaced travis ci with github actions

Signed-off-by: Prati28 <[email protected]>

* made some changes according to reviews

Signed-off-by: Prati28 <[email protected]>

* did some changes based on sourcery reviews

Signed-off-by: Prati28 <[email protected]>

* did some changes based on sourcery reviews

Signed-off-by: Prati28 <[email protected]>

* added py version

Signed-off-by: Prati28 <[email protected]>

* made some changes based on review

Signed-off-by: Prati28 <[email protected]>

* fix linting issue and py version

Signed-off-by: Prati28 <[email protected]>

* fix installation of package issue

Signed-off-by: Prati28 <[email protected]>

* fix command

Signed-off-by: Prati28 <[email protected]>

* added flask to requirements

Signed-off-by: Prati28 <[email protected]>

* added command for installation of packages

Signed-off-by: Prati28 <[email protected]>

* added github token

Signed-off-by: Prati28 <[email protected]>

* made changes

Signed-off-by: Prati28 <[email protected]>

---------

Signed-off-by: Prati28 <[email protected]>
  • Loading branch information
psankhe28 authored Aug 1, 2024
1 parent f6058d8 commit 194ee78
Show file tree
Hide file tree
Showing 7 changed files with 413 additions and 4 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/docker-build-publish-drs-filer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: drs-filer

on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev

jobs:
publish_to_docker:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/dev'

name: Build and publish to Docker
steps:
- name: Checkout repository
uses: actions/[email protected]

- name: Set up Docker Buildx
uses: docker/[email protected]

- name: Login to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: elixircloud/drs-filer

- name: Build and push Docker images
uses: docker/[email protected]
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
45 changes: 45 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Lint workflow

on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev

jobs:
linting_and_tests:
runs-on: ubuntu-latest

name: Run linting and unit tests
steps:
- name: Checkout repository
uses: actions/[email protected]

- name: Set up Python
uses: actions/[email protected]
with:
python-version: 3.11

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest coverage coveralls
pip install -r requirements-test.txt
pip install -r requirements.txt
- name: Lint with flake8
run: flake8

- name: Run unit tests with coverage
run: |
coverage run --source drs_filer -m pytest
coverage report -m
- name: Send coverage data to Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: coveralls
45 changes: 45 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Test Drs-filer API Endpoints

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/[email protected]

- name: Build and run Docker Compose
run: docker-compose up --build -d

- name: Wait for the services to be ready
run: |
echo "Waiting for the services to be ready..."
for i in {1..10}; do
if curl -sSf http://localhost:8080/ga4gh/drs/v1 > /dev/null; then
echo "Service is up!"
break
fi
echo "Waiting for the service to be ready..."
sleep 3
done
- name: Set up Python
uses: actions/[email protected]
with:
python-version: 3.11

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest requests
- name: Test with pytest
run: |
pytest tests/test.py -v -p no:warnings
env:
DRS_FILER_URL: http://localhost:8080/ga4gh/drs/v1

- name: Stop and remove Docker Compose services
run: docker-compose down
9 changes: 5 additions & 4 deletions drs_filer/ga4gh/drs/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

logger = logging.getLogger(__name__)


@log_traffic
def ListDrsObjects() -> List[Dict]:
"""Get all DRS objects.
Expand All @@ -33,10 +34,10 @@ def ListDrsObjects() -> List[Dict]:
current_app.config.foca.db.dbs['drsStore'].
collections['objects'].client
)
cursor = db_collection.find({}, {'_id': 0})
objects = []
for obj in cursor:
objects.append(obj)
cursor = db_collection.find({}, {'_id': 0})
objects = []
for obj in cursor:
objects.append(obj)
return objects


Expand Down
1 change: 1 addition & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
flask
flake8
mongomock
pytest
Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ source =
drs_filer
omit =
drs_filer/app.py

[flake8]
max-line-length = 88
Loading

0 comments on commit 194ee78

Please sign in to comment.