Skip to content
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
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[run]
branch = True
relative_files = True
omit =
simplecpreprocessor/__init__.py
simplecpreprocessor/__main__.py
simplecpreprocessor/tests/*.py

[xml]
output = coverage.xml
21 changes: 8 additions & 13 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,18 @@ jobs:
flake8 simplecpreprocessor

test:
name: Test with coverage
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.7

- uses: ./.github/actions/prepare-build

- run: |
py.test -v --cov=simplecpreprocessor --cov-config .coveragerc --cov-report=xml --cov-report=term-missing

- name: Upload coverage artifact
uses: actions/upload-artifact@v4.3.3
with:
name: coverage
path: coverage.xml
py.test -v

upload-coverage:
name: Publish coverage report
needs: test
name: Test with coverage and publish report
# Disabled for fork PR's as we can't use OIDC there
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
Expand All @@ -63,9 +56,11 @@ jobs:
steps:
- uses: actions/checkout@v4.1.7

- uses: actions/download-artifact@v4.1.8
with:
name: coverage
- uses: ./.github/actions/prepare-build

- name: Run tests with coverage
run: |
py.test -v --cov=simplecpreprocessor --cov-config .coveragerc --cov-report=xml --cov-report=term-missing

- name: Upload to Codecov via OIDC
uses: codecov/codecov-action@v5.5.0
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.pyc
.coverage
coverage.xml
dist
htmlcov
.venv
Expand Down
6 changes: 4 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ All contributions must pass linting with no errors.
Run tests with coverage (matches CI):

```bash
py.test -v --cov=simplecpreprocessor --cov-config .coveragerc --cov-report=term-missing
py.test -v --cov=simplecpreprocessor --cov-config .coveragerc --cov-report=xml --cov-report=term-missing
```

Coverage must remain at or above the current threshold. Coverage reports are generated automatically in CI.
This generates both a terminal report and an XML report (`coverage.xml`) that codecov uses.

Coverage must remain at or above the current threshold. Coverage reports are generated automatically in CI and uploaded to codecov.

## Pull requests

Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,18 @@ behaviour.
Gotchas
---------

Supported macros: ifdef, ifndef, define, undef, include, else,
Supported macros: ifdef, ifndef, if, elif, define, undef, include, else,
pragma (only "once")

The #if and #elif directives support constant expression evaluation including:
* Integer constants
* Arithmetic operators: +, -, *, /, %
* Comparison operators: ==, !=, <, >, <=, >=
* Logical operators: &&, ||, !
* Bitwise operators: &, |, ^
* The defined() operator (with or without parentheses)
* Parentheses for grouping

If using for FFI, you may want to ignore some system headers eg for types

Limitations:
Expand Down
28 changes: 28 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
codecov:
require_ci_to_pass: true

coverage:
precision: 2
round: down
range: "90...100"

status:
project:
default:
target: auto
threshold: 0.5%
patch:
default:
target: auto
threshold: 0.5%

ignore:
- "simplecpreprocessor/__init__.py"
- "simplecpreprocessor/__main__.py"
- "simplecpreprocessor/tests"
- "simplecpreprocessor/tests/*.py"

comment:
layout: "reach,diff,flags,tree"
behavior: default
require_changes: false
Loading