Skip to content

ci: warn when SONAR_TOKEN is within 7 days of expiry - #354

Merged
AndreasIgel merged 2 commits into
java-helpers:mainfrom
igel-devin-ai:feature/sonar-token-expiry-warning
Oct 22, 2026
Merged

AndreasIgel merged 2 commits into
java-helpers:mainfrom
igel-devin-ai:feature/sonar-token-expiry-warning

Conversation

@igel-devin-ai

Copy link
Copy Markdown
Contributor

Adds a second, non-fatal step to the sonarcloud job of integrations-check.yml.

The existing authentication/validate check only reports {"valid": ...} and still hard-fails the run on an invalid/expired token — it cannot surface an upcoming expiry. The new Check SonarCloud token expiry step queries api/user_tokens/search, picks the user token whose name contains github (case-insensitive, anywhere in the name; soonest expirationDate if several match) and emits a ::warning:: annotation once the token is within 7 days of expiry (or already past it), so it can be rotated before CI/release jobs break.

No-op cases (informational log line, exit 0): no token name matches github, the matching token was created without an expirationDate, or the endpoint/response is unreachable or unparseable. Only the existing validate step can fail the job.

Verified locally against mocked user_tokens/search responses: no match, match without expiry, ≤7 days, already expired, >7 days, and malformed JSON all behave as specified.

authentication/validate only reports valid/invalid. Query
api/user_tokens/search for the 'github'-named user token's
expirationDate and emit a ::warning:: 7 days before expiry so it can
be rotated before CI/release jobs fail. Non-fatal: parse or
reachability issues are informational only.
@codecov

codecov Bot commented Oct 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Match the diagnostic conventions of the sibling checks: empty
SONAR_TOKEN, a non-200 or unparseable user_tokens/search response, a
malformed expirationDate, and no 'github'-named token are real
problems for a nightly token diagnostic (reachability/validity are
already proven by the validate step), so they now hard-fail instead
of silently passing. Only 'no expiration date' and '>7 days
remaining' stay informational.
@sonarqubecloud

Copy link
Copy Markdown

@AndreasIgel
AndreasIgel merged commit 1e6c1c4 into java-helpers:main Oct 22, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants