Skip to content

Commit 9603299

Browse files
committed
go coverage stuff added/updated
1 parent df9864b commit 9603299

File tree

5 files changed

+185
-74
lines changed

5 files changed

+185
-74
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# .github/workflows/coverage.yml
2+
#
3+
# Purpose:
4+
# - Run Go tests with coverage on every Pull Request (PR)
5+
# - Upload the coverage report to Coveralls
6+
# - Also run the same workflow once per month (useful as a periodic β€œcanary”)
7+
#
8+
# Notes:
9+
# - GitHub scheduled workflows run in UTC and only run from the default branch workflow file.
10+
# - If you add this file on a non-default branch, the schedule will not start until merged. :contentReference[oaicite:0]{index=0}
11+
12+
name: Go Coverage (PR + Monthly)
13+
14+
on:
15+
# Run for all PRs targeting any branch
16+
pull_request:
17+
18+
# Run once a month: at 03:00 UTC on the 1st day of every month
19+
# Adjust to your preference; cron is always interpreted in UTC. :contentReference[oaicite:1]{index=1}
20+
schedule:
21+
- cron: "0 3 1 * *"
22+
23+
# Optional: allow manual runs from the Actions tab (handy for testing changes)
24+
workflow_dispatch:
25+
26+
# Minimal permissions. Coveralls can post PR comments; that requires pull-requests: write.
27+
# contents: read is sufficient for checkout.
28+
permissions:
29+
contents: read
30+
pull-requests: write
31+
32+
# Concurrency prevents duplicated runs from stacking up when you push multiple commits quickly to a PR.
33+
concurrency:
34+
group: coverage-${{ github.event.pull_request.number || github.ref }}
35+
cancel-in-progress: true
36+
37+
jobs:
38+
coverage:
39+
runs-on: ubuntu-latest
40+
41+
steps:
42+
# 1) Check out repository code
43+
- name: Checkout
44+
uses: actions/checkout@v4
45+
46+
# 2) Install Go (recommended: read version from go.mod)
47+
# actions/setup-go exists in newer majors; using the major tag keeps you on supported updates. :contentReference[oaicite:2]{index=2}
48+
- name: Set up Go
49+
uses: actions/setup-go@v6
50+
with:
51+
go-version-file: go.mod
52+
cache: true
53+
54+
# 3) Run tests and generate a coverage profile (Go native format)
55+
# coverage.out is a common convention; it matches what you saw locally.
56+
- name: Run tests with coverage
57+
run: |
58+
set -euo pipefail
59+
go test ./... -covermode=atomic -coverprofile=coverage.out
60+
61+
# 4) Print a human-readable summary into the workflow logs
62+
# This uses Go’s built-in cover tool. :contentReference[oaicite:3]{index=3}
63+
- name: Coverage summary (log)
64+
run: |
65+
set -euo pipefail
66+
go tool cover -func=coverage.out
67+
68+
# 5) Upload coverage.out as an artifact for later inspection/download
69+
# Useful for debugging and auditing. Artifact v4 is the current major. :contentReference[oaicite:4]{index=4}
70+
- name: Upload coverage artifact
71+
uses: actions/upload-artifact@v4
72+
with:
73+
name: coverage-out
74+
path: coverage.out
75+
if-no-files-found: error
76+
77+
# 6) Send coverage to Coveralls
78+
#
79+
# coverallsapp/github-action supports multiple input styles; 'file' + 'format' is the modern pattern.
80+
# It can also add a PR comment on pull_request events. :contentReference[oaicite:5]{index=5}
81+
#
82+
# Authentication:
83+
# - For public repos with GitHub integration, GITHUB_TOKEN is often enough.
84+
# - If your Coveralls setup requires a repo token, set COVERALLS_REPO_TOKEN as a GitHub Actions secret
85+
# and pass it via env (see section B below).
86+
- name: Publish to Coveralls
87+
uses: coverallsapp/github-action@v2
88+
with:
89+
github-token: ${{ secrets.GITHUB_TOKEN }}
90+
file: coverage.out
91+
format: golang
92+
# If you need a repo token, uncomment the env block:
93+
env:
94+
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
95+
β€š

β€Ž.gitignoreβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
**/.mxproject
1313
**/.DS_Store
1414
internal/receiver/trices.raw
15-
15+
coverage.out

β€Ž.travis.ymlβ€Ž

Lines changed: 0 additions & 7 deletions
This file was deleted.

β€ŽREADME.mdβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
![GitHub commits since latest release](https://img.shields.io/github/commits-since/rokath/trice/latest)
1717
[![Go Report Card](https://goreportcard.com/badge/github.com/rokath/trice)](https://goreportcard.com/report/github.com/rokath/trice)
1818
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
19-
[![Coverage Status](https://coveralls.io/repos/github/rokath/trice/badge.svg?branch=master)](https://coveralls.io/github/rokath/trice?branch=master)
19+
[![Coverage Status](https://coveralls.io/repos/github/rokath/trice/badge.svg?branch=main)](https://coveralls.io/github/rokath/trice?branch=main)
2020

2121
<!-- [![Sponsor rokath](https://github.com/sponsors/rokath/button)](https://github.com/sponsors/rokath) -->
2222
<!-- [![test](https://github.com/shogo82148/actions-goveralls/workflows/_test/badge.svg?branch=main)](https://coveralls.io/github/rokath/trice) -->
@@ -187,6 +187,6 @@ git clone https://github.com/rokath/trice.git
187187
- [uLog (RD Poor)](https://github.com/rdpoor/ulog)
188188
- [Zepyr Dictionary Based Logging](https://docs.zephyrproject.org/3.1.0/services/logging/index.html#dictionary-based-logging)
189189

190-
[ChatGPT Trice Compare (2025-05-26)](https://htmlpreview.github.io/?https://github.com/rokath/trice/blob/master/docs/ChatGPTo4-mini-high_TriceCompare.html)
190+
[ChatGPT Trice Compare (2025-05-26)](https://htmlpreview.github.io/?https://github.com/rokath/trice/blob/main/docs/ChatGPTo4-mini-high_TriceCompare.html)
191191

192192
<p align="right">(<a href="#top">back to top</a>)</p>

0 commit comments

Comments
Β (0)