|
4 | 4 |
|
5 | 5 | ## Guide |
6 | 6 |
|
7 | | -### Travis Setup |
| 7 | +### GitHub Actions Setup |
| 8 | +You should first get the repository upload token from [codecov](https://docs.codecov.com/docs/quick-start#step-2-get-the-repository-upload-token) |
8 | 9 |
|
9 | | -Add to your `.travis.yml` file. |
| 10 | +Add the following to your `.github/workflows/test.yml` file. |
10 | 11 | ```yml |
11 | | -language: scala |
12 | | -after_success: |
13 | | - - bash <(curl -s https://codecov.io/bash) |
| 12 | +name: Test workflow |
| 13 | + |
| 14 | +on: [push, pull_request] |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + name: Test scala |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + - uses: actions/setup-java@v4 |
| 23 | + with: |
| 24 | + distribution: 'adopt' |
| 25 | + java-version: '21' |
| 26 | + - name: Run tests |
| 27 | + run: sbt coverage test coverageReport |
| 28 | + - uses: codecov/codecov-action@v4 |
| 29 | + with: |
| 30 | + fail_ci_if_error: true |
| 31 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 32 | +``` |
| 33 | +
|
| 34 | +Here we frist checkout the code, then setup java, run the tests and generate the coverage report. Finally, we upload the report to codecov using the codecov-action. |
| 35 | +
|
| 36 | +When all finished, you could also add a badge on readme like following. |
| 37 | +
|
| 38 | +``` |
| 39 | +[](https://codecov.io/gh/YOUR_ACCOUNT/YOUR_REPO) |
14 | 40 | ``` |
15 | 41 |
|
16 | 42 | ### Produce Coverage Reports |
17 | 43 |
|
18 | 44 | 1. Add `scoverage` to plugin list |
19 | | - - `addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")` as [seen here](https://github.com/codecov/example-scala/blob/master/project/plugins.sbt#L1) |
| 45 | + - `addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.11")` as [seen here](https://github.com/codecov/example-scala/blob/master/project/plugins.sbt#L1) |
20 | 46 | 1. Add `coverage` and `coverageReport` to `sbt` |
21 | 47 | - `sbt clean coverage test coverageReport` as [seen here](https://github.com/codecov/example-scala/blob/master/.travis.yml#L7) |
22 | 48 |
|
23 | 49 | ## Caveats |
24 | 50 | ### Private Repo |
25 | | -Repository tokens are required for (a) all private repos, (b) public repos not using Travis-CI, CircleCI or AppVeyor. Find your repository token at Codecov and provide via appending `-t <your upload token>` to you where you upload reports. |
| 51 | +Repository tokens are required for |
| 52 | +- (a) all private repos, |
| 53 | +- (b) public repos not using Travis-CI, CircleCI or AppVeyor. |
| 54 | + |
| 55 | +Find your repository token at Codecov and provide via appending `-t <your upload token>` to you where you upload reports. |
26 | 56 |
|
27 | 57 | ## Links |
28 | 58 | - [Community Boards](https://community.codecov.io) |
|
0 commit comments