Skip to content

Commit b9aefa6

Browse files
codecov added
1 parent c770874 commit b9aefa6

7 files changed

Lines changed: 74 additions & 142 deletions

File tree

.github/scripts/check-coverage-delta.py

Lines changed: 0 additions & 67 deletions
This file was deleted.

.github/scripts/extract-coverage.py

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ name: Main
22

33
# Runs only on push to main (i.e. when a PR is merged or someone pushes
44
# directly). This is where the full forward-compat JDK matrix runs and
5-
# where we record the coverage baseline that PR runs compare against.
5+
# where we publish the canonical coverage snapshot that Codecov uses as
6+
# the base for PR diffs.
67
on:
78
push:
89
branches: ['main']
@@ -60,30 +61,16 @@ jobs:
6061
build/test-results/
6162
retention-days: 14
6263

63-
# The JDK 17 entry of the matrix is the canonical run for coverage
64-
# baseline purposes — its JaCoCo XML is what PR runs compare against.
65-
- name: Extract coverage baseline (JDK 17 only)
64+
# The JDK 17 entry of the matrix is the canonical run for coverage:
65+
# its JaCoCo XML is uploaded to Codecov and becomes the base that
66+
# subsequent PR runs compare against (see codecov.yml).
67+
- name: Upload coverage to Codecov (JDK 17 only)
6668
if: success() && matrix.java == '17'
67-
run: |
68-
python3 .github/scripts/extract-coverage.py > coverage-baseline.txt
69-
echo "Baseline coverage: $(cat coverage-baseline.txt)"
70-
71-
- name: Save coverage baseline to cache (JDK 17 only)
72-
if: success() && matrix.java == '17'
73-
uses: actions/cache/save@v4
69+
uses: codecov/codecov-action@v5
7470
with:
75-
path: coverage-baseline.txt
76-
# Unique per commit so each main run produces a fresh entry;
77-
# PR workflow restores via prefix-match on `coverage-baseline-main-`.
78-
key: coverage-baseline-main-${{ github.sha }}
79-
80-
- name: Upload coverage report (JDK 17 only)
81-
if: success() && matrix.java == '17'
82-
uses: actions/upload-artifact@v4
83-
with:
84-
name: jacoco-report
85-
path: build/reports/jacoco/test/
86-
retention-days: 14
71+
token: ${{ secrets.CODECOV_TOKEN }}
72+
files: build/reports/jacoco/test/jacocoTestReport.xml
73+
fail_ci_if_error: true
8774

8875
# Integration-tests job is intentionally not wired up yet:
8976
# SDK requirements §13 says they run on PRs and release pipelines, but

.github/workflows/pull-request.yml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,12 @@ jobs:
5454
build/test-results/
5555
retention-days: 14
5656

57-
# Coverage ratchet: PR's line coverage cannot drop more than 5 pp
58-
# below main's last recorded value. The baseline is restored from
59-
# the cache populated by main.yml; if no baseline is available
60-
# (first ever main run hasn't completed, or cache expired), the
61-
# check passes with a warning instead of blocking the PR.
62-
- name: Restore coverage baseline from main
63-
uses: actions/cache/restore@v4
57+
# Coverage ratchet lives in Codecov: codecov.yml at the repo root
58+
# configures `threshold: 5%` so a PR fails the Codecov status check
59+
# if line coverage drops more than 5 pp vs the base branch.
60+
- name: Upload coverage to Codecov
61+
uses: codecov/codecov-action@v5
6462
with:
65-
path: coverage-baseline.txt
66-
# Unique key that won't match — forces fall-through to restore-keys.
67-
key: coverage-baseline-pr-${{ github.run_id }}
68-
restore-keys: |
69-
coverage-baseline-main-
70-
71-
- name: Check coverage delta vs main
72-
run: python3 .github/scripts/check-coverage-delta.py
63+
token: ${{ secrets.CODECOV_TOKEN }}
64+
files: build/reports/jacoco/test/jacocoTestReport.xml
65+
fail_ci_if_error: true

CLAUDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ The Java SDK must also satisfy the canonical, cross-language [SDK Requirements](
6969
- §15 packaging: SemVer, MIT `LICENSE`, `CHANGELOG.md` in Keep a Changelog format, version auto-detected via JAR manifest (`Implementation-Version`).
7070
- §16 security: tokens never logged verbatim (use `Tokens.redact`); TLS validated by default (`HttpClient` does not expose a skip-verify option).
7171
- ADR-002 CI: split into two workflows.
72-
- `.github/workflows/pull-request.yml` — runs on PR `opened`/`synchronize`/`reopened` (no pre-PR push trigger by design). JDK 17 only. Runs `./gradlew build` + a coverage-delta check that compares the PR's line coverage against main's last recorded value, failing if it drops more than 5 pp. Baseline is restored via `actions/cache/restore@v4` with `restore-keys: coverage-baseline-main-` (prefix match against the latest main run's cache); if no baseline exists, the check passes with a `::warning::` rather than blocking the PR.
73-
- `.github/workflows/main.yml` — runs only on `push` to `main`. Full forward-compat matrix `{17, 21, 25}` via `-PtestJdk=N` (wired into `tasks.test.javaLauncher` in `build.gradle.kts`). The JDK 17 matrix entry also extracts the coverage baseline and saves it to cache key `coverage-baseline-main-${sha}` for the next PR run.
74-
- Helper scripts live in `.github/scripts/` (`extract-coverage.py`, `check-coverage-delta.py`). Both parse `build/reports/jacoco/test/jacocoTestReport.xml` directly. Tolerance constant lives in the script (`TOLERANCE_PP = 0.05`).
72+
- `.github/workflows/pull-request.yml` — runs on PR `opened`/`synchronize`/`reopened` (no pre-PR push trigger by design). JDK 17 only. Runs `./gradlew build` and uploads `build/reports/jacoco/test/jacocoTestReport.xml` to Codecov.
73+
- `.github/workflows/main.yml` — runs only on `push` to `main`. Full forward-compat matrix `{17, 21, 25}` via `-PtestJdk=N` (wired into `tasks.test.javaLauncher` in `build.gradle.kts`). The JDK 17 matrix entry also uploads coverage to Codecov, establishing the base coverage that PRs compare against.
74+
- Coverage ratchet lives in `codecov.yml`: project status with `target: auto, threshold: 5%` (cannot drop >5 pp vs base branch) plus a patch-coverage requirement of 70 % on new code. Requires a `CODECOV_TOKEN` repo secret — without it the upload step fails because workflows pass `fail_ci_if_error: true`.
7575

7676
**Deliberately deferred (require the request/endpoint layer to land first):**
7777
- §1.2 resource groupings (`client.stocks`, `client.options`, `client.funds`, `client.markets`, `client.utilities`).

PR.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# feat: initial Market Data Java SDK scaffold + CI
2+
3+
> Branch `00_base_setup``main` · 2 commits · 39 files
4+
5+
Initial scaffold for the Java SDK. **No endpoints are implemented in this PR** — it lays the foundation that endpoints will land on. Subsequent PRs will add endpoints one by one, each shipping with its corresponding integration tests against the live API (gated by `MARKETDATA_RUN_INTEGRATION_TESTS=true`).
6+
7+
## What's included
8+
9+
- **Build**: Gradle 8.12 (Kotlin DSL), JDK 17 toolchain (`--release 17`), Spotless (Google Java Format), JaCoCo, Vanniktech Maven Publish, separate source set for integration tests.
10+
- **Public API**: `MarketDataClient` with builder, shared HTTP/2 `HttpClient`, 50-permit concurrency semaphore, rate-limit accessor. `RateLimits` record. JSpecify `@NullMarked` across the entire public surface.
11+
- **Exceptions**: sealed `MarketDataException` hierarchy with the 7 canonical subtypes (`AuthenticationError`, `BadRequestError`, `NotFoundError`, `RateLimitError`, `ServerError`, `NetworkError`, `ParseError`), each carrying support context (`requestId`, `requestUrl`, `statusCode`, `timestamp`) and a `getSupportInfo()` helper.
12+
- **Configuration**: cascade `explicit → MARKETDATA_* env var → .env → default`. Defaults: `https://api.marketdata.app`, `v1`. Tokens are never logged verbatim (`Tokens.redact`).
13+
- **CI** (two workflows):
14+
- `pull-request.yml`: PRs run on JDK 17 + coverage ratchet (cannot drop more than 5 pp below main).
15+
- `main.yml`: full matrix `{17, 21, 25}` and saves the coverage baseline that PRs compare against.
16+
- **Docs**: `README.md`, `CLAUDE.md`, `CHANGELOG.md`, `LICENSE` (MIT).
17+
18+
## Tests & coverage
19+
20+
16 tests, all passing. Coverage: **83.1 % lines**, **98 % methods**, 100 % on the `exception` package.
21+
22+
## Architectural decisions
23+
24+
Follows ADRs 001–006 (already on `main`) and the foundational rules in the [cross-language SDK Requirements doc](https://www.marketdata.app/docs/sdk/sdk-requirements/) (§1, §4–§7, §10, §12, §15–§16). Request-flow specifics (retry, rate-limit header parsing, wire-format decoding, endpoints, integration tests) are intentionally deferred and listed explicitly in `CLAUDE.md`. They will land in the follow-up PRs alongside each endpoint.

codecov.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Codecov configuration.
2+
# Docs: https://docs.codecov.com/docs/codecov-yaml
3+
4+
coverage:
5+
status:
6+
project:
7+
default:
8+
# Compare against the base branch's coverage automatically.
9+
target: auto
10+
# Allow up to 5 percentage points of drop before failing the
11+
# status check. Mirrors the project's "no >5pp regression vs main"
12+
# rule that previously lived in .github/scripts/check-coverage-delta.py.
13+
threshold: 5%
14+
# Don't run on draft commits / forks of forks.
15+
if_ci_failed: error
16+
patch:
17+
default:
18+
# Patch coverage = coverage of the lines this PR added/changed.
19+
# Require at least 70% coverage on new code to nudge contributors
20+
# toward writing tests for new logic, while leaving room for
21+
# mechanical / boilerplate diffs.
22+
target: 70%
23+
threshold: 5%
24+
25+
# Pull request comment from the Codecov bot.
26+
comment:
27+
layout: "header, diff, files, footer"
28+
behavior: default
29+
require_changes: false

0 commit comments

Comments
 (0)