|
| 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. |
0 commit comments