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

ci: uploading coverage to Codecov #62

Merged
merged 1 commit into from
Dec 24, 2024
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
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
Loading