Skip to content

Commit

Permalink
Merge pull request #1 from robertbetts/develop
Browse files Browse the repository at this point in the history
Setup develop branch
  • Loading branch information
robertbetts authored Sep 4, 2023
2 parents 7b1a257 + 4739dea commit 9232756
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 2 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/poetry-pytest-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# This workflow will install Python & Poetry dependencies, run tests with a single version of Python 3.11
# Upload code coverage results to codecov.io

name: NuroPb Testing and Code Coverage

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

permissions:
contents: read

jobs:
test:

runs-on: ubuntu-latest

services:
rabbitmq:
image: rabbitmq:3.8
env:
RABBITMQ_DEFAULT_USER: guest
RABBITMQ_DEFAULT_PASS: guest
ports:
- 5672
- 15672

steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
id: setup-python
with:
python-version: '3.11'
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: Install library
run: poetry install --no-interaction
#----------------------------------------------
# run test suite and output coverage file
#----------------------------------------------
- name: Test with coverage and pytest
RMQ_AMQP_PORT: ${{ job.services.rabbitmq.ports['5672'] }}
RMQ_API_PORT: ${{ job.services.rabbitmq.ports['15672'] }}
run: poetry run coverage run -m pytest && poetry run coverage xml
#----------------------------------------------
# Upload coverage file to codeconv.io
#----------------------------------------------
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ pip install nuropb
```



13 changes: 11 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import datetime
import secrets
from uuid import uuid4
import os

import pytest

Expand All @@ -21,10 +22,18 @@
@pytest.fixture(scope="session")
def test_settings():
start_time = datetime.datetime.utcnow()

"""
RMQ_AMQP_PORT: ${{ job.services.rabbitmq.ports['5672'] }}
RMQ_API_PORT: ${{ job.services.rabbitmq.ports['15672'] }}
"""
api_port = os.environ.get("RMQ_API_PORT", 15672)
amqp_port = os.environ.get("RMQ_AMQP_PORT", 5672)

yield {
"api_scheme": "http",
"api_port": 15672,
"port": 5672,
"api_port": api_port,
"port": amqp_port,
"host": "127.0.0.1",
"username": "guest",
"password": "guest",
Expand Down

0 comments on commit 9232756

Please sign in to comment.