Skip to content

Commit f25c6ca

Browse files
Modernize (#349)
Co-authored-by: Jameson Nash <[email protected]>
1 parent a3c6a66 commit f25c6ca

24 files changed

+2354
-94
lines changed

.github/workflows/CI.yml

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
version:
18-
- '1.0'
19-
- '1.6'
18+
- 'lts'
2019
- '1'
20+
- 'pre'
2121
- 'nightly'
2222
os:
2323
- ubuntu-latest
@@ -35,6 +35,9 @@ jobs:
3535
arch: x64
3636
- version: '1'
3737
os: macos-latest
38+
arch: aarch64
39+
- version: '1'
40+
os: macos-13
3841
arch: x64
3942
steps:
4043
- uses: actions/checkout@v4
@@ -44,21 +47,15 @@ jobs:
4447
arch: ${{ matrix.arch }}
4548
- uses: julia-actions/julia-buildpkg@v1
4649
- uses: julia-actions/julia-runtest@v1
50+
with:
51+
coverage: true
52+
# Upload coverage using the modernized Coverage.jl
53+
- name: Upload coverage
4754
env:
48-
JULIA_COVERAGE_BLACK_HOLE_SERVER_URL_PUT: https://httpbingo.julialang.org/put
49-
# submit coverage data to a black hole server, and collect new coverage data on that
50-
- run: julia --color=yes --project=. --code-coverage=user etc/travis-coverage.jl
51-
working-directory: ${{ github.workspace }}
52-
env:
53-
JULIA_COVERAGE_IS_BLACK_HOLE_SERVER: true
54-
COVERALLS_TOKEN: token
55-
COVERALLS_URL: https://httpbingo.julialang.org/post
56-
CODECOV_URL: https://httpbingo.julialang.org
57-
CODECOV_URL_PATH: /post
58-
## submit coverage data *again*, this time without code coverage
59-
- run: julia --color=yes --project=. etc/travis-coverage.jl
60-
working-directory: ${{ github.workspace }}
61-
env:
62-
# COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
63-
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6455
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
56+
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
57+
run: |
58+
julia --color=yes --project=. -e '
59+
using Coverage
60+
process_and_upload(service=:both, folder="src")
61+
'

.github/workflows/CompatHelper.yml

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,49 @@
11
name: CompatHelper
2-
32
on:
43
schedule:
5-
- cron: '00 00 * * *'
6-
4+
- cron: 0 0 * * *
5+
workflow_dispatch:
6+
permissions:
7+
contents: write
8+
pull-requests: write
79
jobs:
810
CompatHelper:
911
runs-on: ubuntu-latest
1012
steps:
11-
- name: Pkg.add("CompatHelper")
12-
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
13-
- name: CompatHelper.main()
13+
- name: Check if Julia is already available in the PATH
14+
id: julia_in_path
15+
run: which julia
16+
continue-on-error: true
17+
- name: Install Julia, but only if it is not already available in the PATH
18+
uses: julia-actions/setup-julia@v2
19+
with:
20+
version: '1'
21+
arch: ${{ runner.arch }}
22+
if: steps.julia_in_path.outcome != 'success'
23+
- name: "Add the General registry via Git"
24+
run: |
25+
import Pkg
26+
ENV["JULIA_PKG_SERVER"] = ""
27+
Pkg.Registry.add("General")
28+
shell: julia --color=yes {0}
29+
- name: "Install CompatHelper"
30+
run: |
31+
import Pkg
32+
name = "CompatHelper"
33+
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
34+
version = "3"
35+
Pkg.add(; name, uuid, version)
36+
shell: julia --color=yes {0}
37+
- name: "Run CompatHelper"
38+
run: |
39+
import CompatHelper
40+
CompatHelper.main()
41+
shell: julia --color=yes {0}
1442
env:
1543
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16-
run: julia -e 'using CompatHelper; CompatHelper.main()'
44+
# If we don't have a documenter key set up, we should configure a dedicated ssh deploy key `COMPATHELPER_PRIV` following https://juliaregistries.github.io/CompatHelper.jl/dev/#Creating-SSH-Key.
45+
# Either way, we need an SSH key if we want the PRs that CompatHelper creates to be able to trigger CI workflows themselves.
46+
# That is because GITHUB_TOKEN's can't trigger other workflows (see https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow).
47+
# Check if you have a deploy key setup using these docs: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/reviewing-your-deploy-keys.
48+
# COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
49+
COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }}

MIGRATION.md

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# Migration Guide: Coverage.jl Modernization
2+
3+
This guide helps you migrate from the deprecated direct upload functionality to the new official uploader integration.
4+
5+
## What Changed?
6+
7+
Coverage.jl has been modernized to work with the official uploaders from Codecov and Coveralls, as both services have deprecated support for 3rd party uploaders.
8+
9+
### Before (Deprecated)
10+
```julia
11+
using Coverage
12+
fcs = process_folder("src")
13+
Codecov.submit(fcs) # Deprecated
14+
Coveralls.submit(fcs) # Deprecated
15+
```
16+
17+
### After (Modern)
18+
```julia
19+
using Coverage
20+
fcs = process_folder("src")
21+
22+
# Option 1: Use automated upload (recommended)
23+
process_and_upload(service=:both, folder="src")
24+
25+
# Option 2: Prepare data for manual upload
26+
codecov_file = prepare_for_codecov(fcs, format=:lcov)
27+
coveralls_file = prepare_for_coveralls(fcs, format=:lcov)
28+
```
29+
30+
## Migration Steps
31+
32+
### 1. For CI Environments (GitHub Actions, Travis, etc.)
33+
34+
**Option A: Use the automated helper (easiest)**
35+
36+
```julia
37+
using Coverage
38+
process_and_upload(service=:both, folder="src")
39+
```
40+
41+
**Option B: Use official uploaders directly**
42+
```yaml
43+
# GitHub Actions example
44+
- name: Process coverage to LCOV
45+
run: |
46+
julia -e '
47+
using Pkg; Pkg.add("Coverage")
48+
using Coverage, Coverage.LCOV
49+
coverage = process_folder("src")
50+
LCOV.writefile("coverage.info", coverage)
51+
'
52+
53+
- name: Upload to Codecov
54+
uses: codecov/codecov-action@v3
55+
with:
56+
files: ./coverage.info
57+
token: ${{ secrets.CODECOV_TOKEN }}
58+
59+
- name: Upload to Coveralls
60+
uses: coverallsapp/github-action@v2
61+
with:
62+
files: ./coverage.info
63+
```
64+
65+
### 2. For Local Development
66+
67+
```julia
68+
using Coverage
69+
70+
# Process and upload
71+
fcs = process_folder("src")
72+
upload_to_codecov(fcs; token="your_token", dry_run=true) # Test first
73+
upload_to_codecov(fcs; token="your_token") # Actual upload
74+
```
75+
76+
### 3. Using Helper Scripts
77+
78+
```bash
79+
# Upload to both services
80+
julia scripts/upload_coverage.jl --folder src
81+
82+
# Upload only to Codecov
83+
julia scripts/upload_coverage.jl --service codecov --flags julia
84+
85+
# Dry run to test
86+
julia scripts/upload_coverage.jl --dry-run
87+
```
88+
89+
## Available Functions
90+
91+
Coverage.jl now provides these functions directly:
92+
93+
### Coverage Processing and Upload
94+
- `process_and_upload()` - One-stop function for processing and uploading
95+
- `upload_to_codecov()` - Upload to Codecov using official uploader
96+
- `upload_to_coveralls()` - Upload to Coveralls using official reporter
97+
98+
### Data Export Functions
99+
- `prepare_for_codecov()` - Export coverage in Codecov-compatible formats
100+
- `prepare_for_coveralls()` - Export coverage in Coveralls-compatible formats
101+
- `export_codecov_json()` - Export to JSON format
102+
- `export_coveralls_json()` - Export to JSON format
103+
104+
### Utility Functions
105+
- `detect_platform()` - Detect current platform
106+
107+
## Environment Variables
108+
109+
The modern upload functions use these environment variables:
110+
111+
| Variable | Service | Description |
112+
|----------|---------|-------------|
113+
| `CODECOV_TOKEN` | Codecov | Repository token for Codecov |
114+
| `COVERALLS_REPO_TOKEN` | Coveralls | Repository token for Coveralls |
115+
116+
**Note**: Legacy environment variables `CODECOV_FLAGS` and `CODECOV_NAME` are only supported by the deprecated `Codecov.submit()` functions, not the modern `upload_to_codecov()` function. Use function parameters instead.
117+
118+
## Supported Formats
119+
120+
- **LCOV** (`.info`) - Recommended, supported by both services
121+
- **JSON** - Native format for each service
122+
123+
## Platform Support
124+
125+
The modernized Coverage.jl automatically downloads the appropriate uploader for your platform:
126+
- **Linux** (x64, ARM64)
127+
- **macOS** (x64, ARM64)
128+
- **Windows** (x64)
129+
130+
## Troubleshooting
131+
132+
### Deprecation Warnings
133+
If you see deprecation warnings, update your code:
134+
135+
```julia
136+
# Old
137+
Codecov.submit(fcs)
138+
139+
# New
140+
upload_to_codecov(fcs)
141+
```
142+
143+
### Missing Tokens
144+
Set environment variables or pass tokens explicitly:
145+
```bash
146+
export CODECOV_TOKEN="your_token"
147+
export COVERALLS_REPO_TOKEN="your_token"
148+
```
149+
150+
### CI Platform Not Detected
151+
The modern uploaders handle CI detection automatically. If needed, you can force CI parameters:
152+
```julia
153+
upload_to_codecov(fcs; token="manual_token")
154+
```
155+
156+
For more examples, see the `examples/ci/` directory.

Project.toml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
11
name = "Coverage"
22
uuid = "a2441757-f6aa-5fb2-8edb-039e3f45d037"
3+
version = "1.7.0"
34
authors = ["Iain Dunning <[email protected]>", "contributors"]
4-
version = "1.6.1"
55

66
[deps]
7+
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
8+
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
79
CoverageTools = "c36e975a-824b-4404-a568-ef97ca766997"
10+
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
811
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
912
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
1013
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
1114
MbedTLS = "739be429-bea8-5141-9913-cc70e7f3736d"
15+
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
16+
Scratch = "6c6a2e73-6563-6170-7368-637461726353"
1217

1318
[compat]
19+
ArgParse = "1"
20+
Artifacts = "1"
1421
CoverageTools = "1"
22+
Downloads = "1.6.0"
1523
HTTP = "0.8, 0.9, 1"
1624
JSON = "0.21"
1725
MbedTLS = "0.6, 0.7, 1"
26+
SHA = "0.7.0"
27+
Scratch = "1"
1828
julia = "1"
1929

2030
[extras]
21-
CoverageTools = "c36e975a-824b-4404-a568-ef97ca766997"
2231
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2332

2433
[targets]
25-
test = ["CoverageTools", "Test"]
34+
test = ["Test"]

0 commit comments

Comments
 (0)