Skip to content

Commit 2fca463

Browse files
committed
ci: Enable code coverage
1 parent ce3b417 commit 2fca463

File tree

3 files changed

+25
-49
lines changed

3 files changed

+25
-49
lines changed

.codecov.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
# Do not pass if PR reduces coverage by more than 5%
6+
target: auto
7+
threshold: 5
8+
comment:
9+
layout: "header, diff, components, files, footer"

.github/workflows/python.yml

Lines changed: 8 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ concurrency:
1414
jobs:
1515
test:
1616
name: Tests and coverage
17-
runs-on: ubuntu-latest-16core
17+
runs-on: ubuntu-latest
1818
env:
1919
HATCH_ENV: "ci"
2020
# Workaround for read-only dependabot GITHUB_TOKEN in meow-coverage
@@ -27,24 +27,21 @@ jobs:
2727
python-version: [ "3.9", "3.10", "3.11" ]
2828
steps:
2929
- uses: actions/checkout@v4
30-
with:
31-
path: head
30+
3231
- name: Set up Python ${{ matrix.python-version }}
3332
uses: actions/setup-python@v4
3433
with:
3534
python-version: ${{ matrix.python-version }}
3635
cache: pip
3736

3837
- name: Install dependencies
39-
working-directory: head
4038
run: |
4139
python -m pip install --upgrade pip
4240
python -m pip install hatch
4341
4442
- name: Formatting
4543
uses: famedly/black@stable
4644
with:
47-
src: head
4845
options: "--check --verbose"
4946

5047
- name: Prepare lint
@@ -55,46 +52,12 @@ jobs:
5552
uses: chartboost/ruff-action@491342200cdd1cf4d5132a30ddc546b3b5bc531b
5653
with:
5754
args: check --target-version ${{ env.PYTHON_TARGET }}
58-
src: head
5955

6056
- name: Tests and coverage
61-
working-directory: head
62-
run: hatch run head-cov
63-
64-
- name: Load base coverage results from cache
65-
if: github.event_name == 'pull_request'
66-
id: cache-coverage
67-
uses: actions/cache@v3
68-
with:
69-
path: ./base.lcov
70-
key: coverage-${{ github.event.pull_request.base.sha }}
71-
72-
- name: Pull base
73-
uses: actions/checkout@v3
74-
if: github.event_name == 'pull_request' && steps.cache-coverage.outputs.cache-hit != 'true'
57+
run: hatch run cov
58+
59+
- name: Codecov - Upload coverage
60+
uses: codecov/codecov-action@v4
7561
with:
76-
ref: ${{ github.event.pull_request.base.ref }}
77-
repository: ${{ github.event.pull_request.base.full_name }}
78-
path: base
79-
80-
- name: Generate base coverage
81-
if: github.event_name == 'pull_request' && steps.cache-coverage.outputs.cache-hit != 'true'
82-
working-directory: base
83-
# Needed for initial run
84-
continue-on-error: true
85-
run: hatch run base-cov
86-
87-
- name: Meow Coverage
88-
id: coverage-report
89-
continue-on-error: true
90-
uses: famedly/meow-coverage@main
91-
if: github.event_name == 'pull_request'
92-
with:
93-
new-lcov-file: 'head.lcov'
94-
old-lcov-file: ${{ github.event_name == 'pull_request' && 'base.lcov' || '' }}
95-
source-prefix: 'synapse_invite_policies/'
96-
pr-number: ${{ github.event_name == 'pull_request' && github.event.pull_request.number || '' }}
97-
repo-name: ${{ github.repository }}
98-
commit-id: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.event.after }}
99-
github-token: ${{ secrets.GITHUB_TOKEN }}
100-
62+
token: ${{secrets.CODECOV_TOKEN}}
63+
files: "lcov.info"

pyproject.toml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ classifiers = [
2323
"Programming Language :: Python :: Implementation :: CPython",
2424
"Programming Language :: Python :: Implementation :: PyPy",
2525
]
26-
dependencies = ["jwcrypto", "twisted"]
26+
dependencies = [
27+
"jwcrypto",
28+
"twisted",
29+
# We need to pin this because of https://github.com/element-hq/synapse/issues/17882
30+
# TODO: Remove this dependency when we can
31+
"Twisted==24.7.0"
32+
]
2733
version = "0.6.0"
2834

2935
[project.urls]
@@ -46,9 +52,7 @@ format = "black ."
4652
lint = "ruff check ."
4753

4854
[tool.hatch.envs.ci.scripts]
49-
format = "black --check ."
50-
head-cov = "pytest --cov-report=lcov:../head.lcov --cov-config=pyproject.toml --cov=synapse_token_authenticator --cov=tests"
51-
base-cov = "pytest --cov-report=lcov:../base.lcov --cov-config=pyproject.toml --cov=synapse_token_authenticator --cov=tests"
55+
cov = "pytest --cov-report=lcov:lcov.info --cov-config=pyproject.toml --cov=synapse_token_authenticator --cov=tests"
5256

5357
[tool.coverage.run]
5458
branch = true

0 commit comments

Comments
 (0)