Skip to content

Commit

Permalink
ci: uploading coverage to Codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
snuffkin committed Dec 23, 2024
1 parent 7a2cf41 commit b90a653
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 113 deletions.
121 changes: 81 additions & 40 deletions .github/workflows/python-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Python CI
on:
push:
paths:
- 'backend/**/*.py'
- 'backend/**/*.py'

jobs:
lint-format:
Expand All @@ -12,25 +12,25 @@ jobs:
matrix:
target: [common, user, provider]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: .python-version
- name: Install dependencies
run: |
python -m pip install --upgrade pip==24.0
python -m pip install poetry
poetry install
- name: Check version
run: |
poetry --version
- name: Lint and Format ${{ matrix.target }}
run: |
make lint-${{ matrix.target }}
make fmt-${{ matrix.target }}
working-directory: ./backend
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: .python-version
- name: Install dependencies
run: |
python -m pip install --upgrade pip==24.0
python -m pip install poetry
poetry install
- name: Check version
run: |
poetry --version
- name: Lint and Format ${{ matrix.target }}
run: |
make lint-${{ matrix.target }}
make fmt-${{ matrix.target }}
working-directory: ./backend

test:
runs-on: ubuntu-latest
Expand All @@ -40,23 +40,64 @@ jobs:
target: [common, user, provider]

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: .python-version
- name: Install dependencies
run: |
python -m pip install --upgrade pip==24.0
python -m pip install poetry
poetry install
- name: Check version
run: |
poetry --version
- name: Test ${{ matrix.target }}
run: |
make test-${{ matrix.target }}
working-directory: ./backend
env:
TZ: Asia/Tokyo
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: .python-version
- name: Install dependencies
run: |
python -m pip install --upgrade pip==24.0
python -m pip install poetry
poetry install
- name: Check version
run: |
poetry --version
- name: Test ${{ matrix.target }}
run: |
make test-${{ matrix.target }}
working-directory: ./backend
env:
TZ: Asia/Tokyo
- name: Upload .coverage-${{ matrix.target }} file
uses: actions/upload-artifact@v4
with:
name: .coverage-${{ matrix.target }}
path: .coverage-${{ matrix.target }}

coverage:
runs-on: ubuntu-latest
needs: test

steps:
- name: Download .coverage-common artifacts
uses: actions/download-artifact@v4
with:
name: .coverage-common
path: ./
- name: Download .coverage-user artifacts
uses: actions/download-artifact@v4
with:
name: .coverage-user
path: ./
- name: Download .coverage-provider artifacts
uses: actions/download-artifact@v4
with:
name: .coverage-provider
path: ./
- name: Install dependencies
run: |
python -m pip install --upgrade pip==24.0
python -m pip install poetry
poetry install
- name: Combine coverage files
run: |
poetry run coverage combine .coverage-common .coverage-user .coverage-provider
poetry run coverage xml
- name: Upload combined coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
slug: oqtopus-team/oqtopus-cloud
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@ pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
htmlcov*/
.tox/
.nox/
.coverage
.coverage.*
.coverage*
.cache
nosetests.xml
coverage.xml
coverage*.xml
*.cover
*.py,cover
.hypothesis/
Expand Down
11 changes: 7 additions & 4 deletions backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,25 @@ lint-all: lint-common lint-user lint-provider ## Run all linters
test-common: fmt-common lint-common ## Run common tests
@export POWERTOOLS_METRICS_NAMESPACE=common && \
export POWERTOOLS_SERVICE_NAME=common && \
poetry run pytest tests/oqtopus_cloud/common/ -vv --cov=oqtopus_cloud/common --cov-report=xml:../coverage.xml --cov-report=html:../htmlcov
poetry run pytest tests/oqtopus_cloud/common/ -vv --cov=oqtopus_cloud/common --cov-report=xml:coverage-common.xml --cov-report=html:htmlcov-common
@mv .coverage .coverage-common

test-user: fmt-user lint-user ## Run User API tests
@export POWERTOOLS_METRICS_NAMESPACE=user-api && \
export POWERTOOLS_SERVICE_NAME=user-api && \
poetry run pytest tests/oqtopus_cloud/user/ -vv --cov=oqtopus_cloud/user --cov-report=xml:../coverage.xml --cov-report=html:../htmlcov
poetry run pytest tests/oqtopus_cloud/user/ -vv --cov=oqtopus_cloud/user --cov-report=xml:coverage-user.xml --cov-report=html:htmlcov-user
@mv .coverage .coverage-user

test-provider: fmt-provider lint-provider ## Run Provider tests
@export POWERTOOLS_METRICS_NAMESPACE=provider-api && \
export POWERTOOLS_SERVICE_NAME=provider-api && \
poetry run pytest tests/oqtopus_cloud/provider/ -vv --cov=oqtopus_cloud/provider --cov-report=xml:../coverage.xml --cov-report=html:../htmlcov
poetry run pytest tests/oqtopus_cloud/provider/ -vv --cov=oqtopus_cloud/provider --cov-report=xml:coverage-provider.xml --cov-report=html:htmlcov-provider
@mv .coverage .coverage-provider

test-all: fmt-all lint-all ## Run All tests
@export POWERTOOLS_METRICS_NAMESPACE=all && \
export POWERTOOLS_SERVICE_NAME=all && \
poetry run pytest tests/oqtopus_cloud -vv --cov=oqtopus_cloud --cov-report=xml:../coverage.xml --cov-report=html:../htmlcov
poetry run pytest tests/oqtopus_cloud -vv --cov=oqtopus_cloud --cov-report=xml:coverage.xml --cov-report=html:htmlcov


help: ## Show this help message
Expand Down
Loading

0 comments on commit b90a653

Please sign in to comment.