| 1 |
name: Run tests and upload coverage |
| 2 |
|
| 3 |
on: |
| 4 |
workflow_call: |
| 5 |
pull_request: |
| 6 |
branches: [main] |
| 7 |
paths: |
| 8 |
- shoutrrr/** |
| 9 |
- pkg/** |
| 10 |
- internal/** |
| 11 |
- shoutrrr.go |
| 12 |
- go.mod |
| 13 |
- go.sum |
| 14 |
|
| 15 |
permissions: |
| 16 |
contents: read # Set default read-only permissions |
| 17 |
|
| 18 |
jobs: |
| 19 |
test: |
| 20 |
name: Run Tests and Upload Coverage Report |
| 21 |
runs-on: ${{ matrix.platform }} |
| 22 |
strategy: |
| 23 |
fail-fast: false |
| 24 |
matrix: |
| 25 |
platform: |
| 26 |
- macos-latest |
| 27 |
- windows-2025 |
| 28 |
- ubuntu-latest |
| 29 |
steps: |
| 30 |
- name: Harden the Runner (Step Security) |
| 31 |
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4 |
| 32 |
with: |
| 33 |
egress-policy: audit |
| 34 |
|
| 35 |
- name: Checkout Repo |
| 36 |
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 |
| 37 |
with: |
| 38 |
fetch-depth: 0 |
| 39 |
persist-credentials: false |
| 40 |
|
| 41 |
- name: Setup Go |
| 42 |
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 |
| 43 |
with: |
| 44 |
cache: true |
| 45 |
cache-dependency-path: "**/go.sum" |
| 46 |
go-version-file: go.mod |
| 47 |
|
| 48 |
- name: Install Dependencies |
| 49 |
run: go mod download |
| 50 |
|
| 51 |
- name: Run Tests |
| 52 |
shell: bash |
| 53 |
run: | |
| 54 |
go list ./... | grep -vE '/testing/e2e(/|$)' | xargs go test -v -coverprofile coverage.out -covermode atomic |
| 55 |
|
| 56 |
- name: Upload Coverage Report to Codecov |
| 57 |
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0 |
| 58 |
with: |
| 59 |
token: ${{ secrets.CODECOV_TOKEN }} |