Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ on:
description: 'Extra -D arguments for the Sonar scanner'
type: string
default: ''
secrets:
SONAR_TOKEN:
description: >-
Only needed with `sonar: true`. Declared so callers do not have to use `secrets: inherit`,
which SonarQube Cloud's own quality gate flags.
required: false

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
38 changes: 29 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ on:

jobs:
test:
uses: evolution-gaming/scala-github-actions/.github/workflows/ci.yml@v6
secrets: inherit
uses: evolution-gaming/scala-github-actions/.github/workflows/ci.yml@2a389d2a5f4b093e72f738464bd7472bd0c3b4b8 # v6
```

Nothing else is required if the project uses the defaults below. Coverage is uploaded to Coveralls,
so `secrets: inherit` is needed for `GITHUB_TOKEN`.
Nothing else is required if the project uses the defaults below.

Two things about that snippet are deliberate, both because SonarQube Cloud's quality gate rejects the
alternatives and drops the security rating to C:

* the workflow is pinned to a **full commit SHA**, with the tag in a trailing comment. Resolve the
current one with
`gh api repos/evolution-gaming/scala-github-actions/git/ref/tags/v6 --jq .object.sha`.
* there is **no `secrets: inherit`**. It is not needed — `GITHUB_TOKEN` is available to a called
workflow automatically, and that is what the Coveralls upload uses. Only the optional Sonar scan
needs a secret.

### Inputs

Expand All @@ -47,8 +55,7 @@ Example for a project without `sbt-version-policy` and on a different Scala set:
```yaml
jobs:
test:
uses: evolution-gaming/scala-github-actions/.github/workflows/ci.yml@v6
secrets: inherit
uses: evolution-gaming/scala-github-actions/.github/workflows/ci.yml@2a389d2a5f4b093e72f738464bd7472bd0c3b4b8 # v6
with:
scala_versions: '["2.13.18", "3.3.7"]'
version_policy_check: false
Expand Down Expand Up @@ -78,9 +85,14 @@ compatibility check passes without checking anything.

### SonarQube Cloud

Off by default. Enable with `sonar: true`, which scans once, on the first Scala version, importing
scoverage's per-module reports. Configuration is passed as scanner arguments, so no per-repo
`sonar-project.properties` is needed.
Most repositories should **not** use the `sonar` input. Analysis is done server-side by SonarQube
Cloud's Automatic Analysis, which needs no token, no CI step and no repository configuration — that is
how `kafka-journal` and the other analysed repositories work. The `sonar` input exists for the
CI-based scanner, which is the mutually exclusive alternative.

If you do enable it, it scans once, on the first Scala version, importing scoverage's per-module
reports. Configuration is passed as scanner arguments, so no per-repo `sonar-project.properties` is
needed.

Three prerequisites, all outside this repo:

Expand All @@ -91,6 +103,14 @@ Three prerequisites, all outside this repo:
3. **Automatic Analysis must be turned off** for that project. It and CI-based scanning are mutually
exclusive, and Automatic Analysis wins, so the scan will be rejected while it is on.

The scanner also needs the token passed through, which the caller must do explicitly now that
`secrets: inherit` is gone:

```yaml
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
```

Note that the SonarQube Cloud GitHub App creates a check suite on every commit even in repositories
it never analyses, which leaves a check permanently queued and reporting no result. Repositories not
being analysed should have the app removed rather than left in that state.
Expand Down