Skip to content

Commit 3fc8c4e

Browse files
fix: craft config and docs (#19)
* fix: updates in config and docs * fix: renamed the file
1 parent 834c994 commit 3fc8c4e

File tree

5 files changed

+84
-28
lines changed

5 files changed

+84
-28
lines changed

.craft.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
minVersion: "2.21.2"
22
changelog:
33
policy: auto
4+
artifactProvider:
5+
name: github
6+
config:
7+
artifacts:
8+
Build & Test:
9+
- action-package
410
targets:
511
- name: github
Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: Build & Test
2+
13
on:
24
pull_request:
35
branches:
@@ -11,8 +13,8 @@ jobs:
1113
runs-on: ubuntu-latest
1214
permissions:
1315
contents: read
14-
pull-requests: write # Required for posting/updating PR comments
15-
statuses: write # Required for reporting commit statuses
16+
pull-requests: write # Required for posting/updating PR comments
17+
statuses: write # Required for reporting commit statuses
1618

1719
steps:
1820
- name: Checkout
@@ -22,13 +24,13 @@ jobs:
2224
uses: actions/setup-node@v4
2325
with:
2426
node-version: 20
25-
27+
2628
- name: Install pnpm
2729
run: npm install -g pnpm
28-
30+
2931
- name: Install dependencies
3032
run: pnpm install
31-
33+
3234
- name: Build Action
3335
run: pnpm run build
3436

@@ -43,4 +45,12 @@ jobs:
4345
post-pr-comment: true
4446
target-patch: 80
4547
threshold-project: 1
46-
fail-on-error: true
48+
fail-on-error: true
49+
50+
- run: npm pack
51+
52+
- name: Upload build artifacts
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: action-package
56+
path: "*.tgz"

README.md

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
| Input | Description | Required | Default |
4949
|-------|-------------|----------|---------|
5050
| `token` | GitHub token for API access and artifacts | **Yes** | — |
51-
| `base-branch` | Base branch to compare results against | No | `main` |
51+
| `base-branch` | Base branch to compare results against | No | Auto-detected |
5252
| `enable-tests` | Enable test results reporting | No | `true` |
5353
| `enable-coverage` | Enable coverage reporting | No | `true` |
5454
| `post-pr-comment` | Post results as a PR comment | No | `false` |
@@ -87,7 +87,7 @@ When thresholds are not configured, status checks report coverage metrics withou
8787
| Input | Description | Required | Default |
8888
|-------|-------------|----------|---------|
8989
| `flags` | Comma-separated flags to tag coverage (e.g., `unittests,frontend`) | No | — |
90-
| `name` | Custom name for this coverage upload | No | — |
90+
| `name` | Custom name for this coverage upload. Also used to differentiate artifacts in matrix builds | No | — |
9191

9292
### Test Results
9393

@@ -240,6 +240,35 @@ When thresholds are not configured, status checks report coverage metrics withou
240240
name: backend-coverage
241241
```
242242

243+
### Matrix Builds
244+
245+
When running coverage in a matrix strategy (e.g., multiple Python versions), use the `name` input to give each matrix entry a unique artifact name and avoid upload conflicts:
246+
247+
```yaml
248+
jobs:
249+
test:
250+
runs-on: ubuntu-latest
251+
strategy:
252+
matrix:
253+
python-version: ["3.10", "3.11", "3.12", "3.13"]
254+
steps:
255+
- uses: actions/checkout@v4
256+
257+
- uses: actions/setup-python@v5
258+
with:
259+
python-version: ${{ matrix.python-version }}
260+
261+
- name: Run tests
262+
run: pytest --cov=src --cov-report=xml
263+
264+
- name: Codecov Action
265+
uses: getsentry/codecov-action@v1
266+
with:
267+
token: ${{ secrets.GITHUB_TOKEN }}
268+
files: coverage.xml
269+
name: py${{ matrix.python-version }}
270+
```
271+
243272
### Coverage Thresholds with Status Checks
244273

245274
Use built-in threshold enforcement with GitHub status checks:
@@ -278,15 +307,18 @@ Multiple coverage files are parsed and aggregated:
278307
### 3. Artifact Storage
279308

280309
Results are stored as GitHub Artifacts:
281-
- `coverage-results-{branch}` — Aggregated coverage data
282-
- `test-results-{branch}` — Aggregated test results
310+
- `codecov-coverage-results-{branch}[-{name}][-{flags}]` — Aggregated coverage data
311+
- `codecov-test-results-{branch}` — Aggregated test results
312+
313+
When using the `name` input, it is appended to the artifact name to avoid conflicts in matrix builds.
283314

284315
### 4. Base Branch Comparison
285316

286317
On PRs or feature branches:
287-
1. Downloads latest results from base branch
288-
2. Compares current vs baseline
289-
3. Calculates deltas
318+
1. Auto-detects the repository's default branch (or uses the explicit `base-branch` input)
319+
2. Downloads latest results from base branch
320+
3. Compares current vs baseline
321+
4. Calculates deltas
290322

291323
### 5. Reporting
292324

@@ -469,6 +501,8 @@ permissions:
469501
statuses: write # Create commit status checks
470502
```
471503

504+
> **Note**: On pull requests from forks, `GITHUB_TOKEN` has restricted permissions regardless of the workflow's `permissions` block. PR comments and commit status checks will be skipped gracefully with a warning in this case. Coverage results and Job Summary are still generated.
505+
472506
## Migration from Codecov
473507

474508
If you're migrating from the official Codecov action:

action.yml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: Codecov Action
22
description: Test results and coverage reporting for GitHub Actions with multi-format support
3+
branding:
4+
icon: activity
5+
color: red
36

47
inputs:
58
# Authentication
@@ -14,34 +17,34 @@ inputs:
1417
directory:
1518
description: Folder to search for coverage files. Defaults to current working directory
1619
required: false
17-
default: '.'
20+
default: "."
1821
exclude:
1922
description: Comma-separated list of folders/patterns to exclude from search
2023
required: false
2124

2225
# Format handling
2326
coverage-format:
24-
description: 'Coverage format hint (auto, clover, cobertura, jacoco, lcov, istanbul, go). Auto-detects if not specified'
27+
description: "Coverage format hint (auto, clover, cobertura, jacoco, lcov, istanbul, go). Auto-detects if not specified"
2528
required: false
26-
default: 'auto'
29+
default: "auto"
2730
disable-search:
2831
description: Disable automatic search for coverage files. Use with "files" input
2932
required: false
30-
default: 'false'
33+
default: "false"
3134

3235
# Behavior flags (Codecov-style)
3336
fail-ci-if-error:
3437
description: Exit with non-zero code if coverage processing fails
3538
required: false
36-
default: 'false'
39+
default: "false"
3740
handle-no-reports-found:
3841
description: Do not fail if no coverage reports are found
3942
required: false
40-
default: 'false'
43+
default: "false"
4144
verbose:
4245
description: Enable verbose logging for debugging
4346
required: false
44-
default: 'false'
47+
default: "false"
4548

4649
# Grouping and identification (Codecov-style)
4750
flags:
@@ -60,25 +63,25 @@ inputs:
6063
junit-xml-pattern:
6164
description: Glob pattern for finding JUnit XML files
6265
required: false
63-
default: './**/*.junit.xml'
66+
default: "./**/*.junit.xml"
6467
enable-tests:
6568
description: Enable test results reporting
6669
required: false
67-
default: 'true'
70+
default: "true"
6871
enable-coverage:
6972
description: Enable coverage reporting
7073
required: false
71-
default: 'true'
74+
default: "true"
7275
post-pr-comment:
7376
description: Post results as a PR comment (in addition to Job Summary)
7477
required: false
75-
default: 'false'
78+
default: "false"
7679

7780
# Threshold enforcement
7881
fail-on-error:
7982
description: Fail the CI job if coverage thresholds are not met
8083
required: false
81-
default: 'false'
84+
default: "false"
8285
target-project:
8386
description: "Target project coverage % (or 'auto' to use base branch coverage)"
8487
required: false
@@ -91,7 +94,7 @@ inputs:
9194

9295
# Legacy input (deprecated, use 'files' or 'directory' instead)
9396
coverage-xml-pattern:
94-
description: '[Deprecated] Glob pattern for finding coverage XML files. Use files/directory instead.'
97+
description: "[Deprecated] Glob pattern for finding coverage XML files. Use files/directory instead."
9598
required: false
9699

97100
outputs:
@@ -112,7 +115,7 @@ outputs:
112115
description: Number of tests that changed from failing to passing
113116
tests-broken:
114117
description: Number of tests that changed from passing to failing
115-
118+
116119
# Coverage outputs
117120
line-coverage:
118121
description: Line coverage percentage

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{
22
"name": "codecov-action",
3-
"version": "1.0.0",
3+
"version": "0.0.0",
44
"type": "module",
5+
"files": [
6+
"dist"
7+
],
58
"scripts": {
69
"build": "rollup --config rollup.config.js",
710
"format": "biome format --write .",

0 commit comments

Comments
 (0)