Repository navigation
Add license check workflow - #1680
Conversation
📝 WalkthroughWalkthroughAdds a GitHub Actions workflow and a Bash license-audit script that run on PRs touching Go modules, weekly, or manually; they install go-licenses, run checks, generate a CSV report, and upload it as a 30-day artifact. Changes
Sequence Diagram(s)sequenceDiagram
participant Trigger as PR / Schedule / Manual
participant GHA as GitHub Actions
participant Runner as Ubuntu Runner
participant Script as scripts/check-licenses.sh
participant GoLic as go-licenses
participant Artifact as Artifact Storage
Trigger->>GHA: start "License Check"
GHA->>Runner: run license-audit job (10m)
Runner->>Runner: checkout repo, setup Go 1.24 (cache)
Runner->>GoLic: install go-licenses (go install)
Runner->>Script: execute check-licenses.sh
Script->>GoLic: run audit (disallowed_types=forbidden)
GoLic-->>Script: output / exit code
Script->>Script: parse output, detect GPL/AGPL, handle known issues
Script->>Script: generate CSV distribution
Script-->>Runner: exit status
Runner->>Artifact: upload license-report.csv (30d)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Important Cloud Posse Engineering Team Review RequiredThis pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes. To expedite this process, reach out to us on Slack in the |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1680 +/- ##
==========================================
+ Coverage 66.36% 66.38% +0.01%
==========================================
Files 356 356
Lines 41025 41025
==========================================
+ Hits 27227 27234 +7
+ Misses 11762 11755 -7
Partials 2036 2036
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
.github/workflows/license-check.yml (1)
34-35: Redundant go-licenses installation.The workflow installs go-licenses here, but the script (line 15 in check-licenses.sh) also installs it conditionally. Consider removing this step and rely on the script's defensive installation, or remove the installation from the script and keep it in the workflow. The current setup is harmless but adds a small layer of redundancy.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
licenses-full-report.csvis excluded by!**/*.csv
📒 Files selected for processing (2)
.github/workflows/license-check.yml(1 hunks)scripts/check-licenses.sh(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*
📄 CodeRabbit inference engine (CLAUDE.md)
Target minimum 80% coverage on new/changed lines; exclude mock files from coverage: **/mock_.go, mock_.go, **/mock/*.go.
Files:
scripts/check-licenses.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Build (linux)
- GitHub Check: Build (windows)
- GitHub Check: Build (macos)
- GitHub Check: Check dependency licenses
- GitHub Check: Analyze (go)
- GitHub Check: Summary
🔇 Additional comments (3)
scripts/check-licenses.sh (1)
60-65: License summary generation is clear.Extracting, counting, and sorting license types via awk/sort/uniq is straightforward and readable. The guard clause
if [ -n "$license" ]handles empty lines safely..github/workflows/license-check.yml (2)
15-16: Verify Go 1.24 compatibility with the project.The workflow pins GO_VERSION to 1.24 (very recent). Confirm this version is compatible with the atmos codebase and any downstream tooling/CI that consumes builds from this workflow.
45-51: Artifact upload configuration is sound, contingent on report generation.The artifact step is well-configured with appropriate retention. However, its success depends on the prior report generation step producing licenses-report.csv. If that step silently fails (due to
|| true), the upload will fail. Address the robustness issue in the prior step to ensure consistent behavior.
- Ensure licenses-report.csv is always created - Add empty CSV with header if go-licenses fails - Log success/failure status for debugging - Prevents artifact upload step from failing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
This file should not be tracked in git. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
.github/workflows/license-check.yml (1)
35-35: Consider pinning go-licenses version.Installing
@latestmeans the workflow always pulls the newest version of go-licenses, which could introduce breaking changes if the tool evolves. For CI reliability, consider pinning to a specific release (e.g.,@v1.x.y) to make updates intentional.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
.github/workflows/license-check.yml(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Build (macos)
- GitHub Check: Build (windows)
- GitHub Check: Analyze (go)
- GitHub Check: Summary
🔇 Additional comments (2)
.github/workflows/license-check.yml (2)
16-16: Verify Go version compatibility.Go 1.24 is quite recent. Confirm this aligns with the project's minimum and maximum supported Go versions (check go.mod or contributing docs).
40-48: CSV generation robustness looks solid now.The fallback approach (creating a header-only CSV on failure) ensures the artifact upload doesn't break, which addresses the prior reviewer's concern. The
if: always()guards on both this step and the upload ensure the job pipeline completes even if go-licenses has issues.One small note: filtering out lines starting with
WandEremoves warnings and errors from the report. If the intent is to keep the report "clean", this is fine—but if you want to surface warnings, consider keeping them and let users filter in post-processing.
The previous implementation tested the exit code of `tee` instead of `go-licenses`, causing the else branch to be unreachable. This meant failed license checks would incorrectly pass. Now capture the go-licenses exit code before piping to tee, ensuring proper error detection. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (1)
scripts/check-licenses.sh (1)
33-34: Exit code capture from pipeline is still broken; the$?capturestee, notgo-licenses.The past review comment flagged this exact issue, but the fix does not appear to be applied. In bash,
$?after a pipeline captures the exit code of the last command (tee), which will almost always succeed even ifgo-licensesfails. This means failing license checks will incorrectly pass.Use
${PIPESTATUS[0]}to capture the exit code of the first command, or addset -o pipefailto make the pipeline fail if any command fails.Option 1: Use
${PIPESTATUS[0]}(recommended)go-licenses check . --disallowed_types=forbidden 2>&1 | tee /tmp/license-check.log - LICENSE_CHECK_EXIT=$? + LICENSE_CHECK_EXIT=${PIPESTATUS[0]}Option 2: Add
set -o pipefailat the top of the scriptset -e + set -o pipefailEither approach works; Option 1 is more explicit about intent.
🧹 Nitpick comments (3)
scripts/check-licenses.sh (3)
5-5: Consider addingset -o pipefailfor defensive pipeline handling.While the immediate exit code issue should be fixed with
${PIPESTATUS[0]}, addingset -o pipefailprovides an additional safety layer to ensure pipeline failures propagate correctly.set -e + set -o pipefail
33-33: Use a temporary directory viamktempinstead of hard-coded/tmp/license-check.log.Hard-coded
/tmppaths can cause permission issues or collisions in containerized CI environments, and the temp file is never cleaned up. Usingmktempis more robust and portable.+ # Create a temporary file for license check output + LICENSE_LOG=$(mktemp) + trap "rm -f '$LICENSE_LOG'" EXIT + go-licenses check . --disallowed_types=forbidden 2>&1 | tee "$LICENSE_LOG" - LICENSE_CHECK_EXIT=${PIPESTATUS[0]} + LICENSE_CHECK_EXIT=${PIPESTATUS[0]} - if grep -qi "GPL-[23]\.0\|AGPL" /tmp/license-check.log 2>/dev/null; then + if grep -qi "GPL-[23]\.0\|AGPL" "$LICENSE_LOG" 2>/dev/null; thenThen update line 48 similarly:
- if grep -E "(xi2/xz|bearsh/hid)" /tmp/license-check.log >/dev/null 2>&1; then + if grep -E "(xi2/xz|bearsh/hid)" "$LICENSE_LOG" >/dev/null 2>&1; then
64-68: The awk field assumption is fragile and undocumented.The
awk -F',' '{print $3}'assumes the CSV output fromgo-licenses reportalways has the license in field 3. If the tool's output format changes, this silently breaks. Consider being more explicit about which field is the license or add validation.This is a nice-to-have improvement rather than a blocker; document the expected format as a comment if keeping it as-is:
+ # Extract license (field 3) from go-licenses CSV output, filtering warnings/errors go-licenses report . 2>&1 | grep -v "^W" | grep -v "^E" | awk -F',' '{print $3}' | sort | uniq -c | sort -rn | while read count license; do
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
scripts/check-licenses.sh(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Build (windows)
- GitHub Check: Lint (golangci)
- GitHub Check: Analyze (go)
- GitHub Check: Run pre-commit hooks
- GitHub Check: Check dependency licenses
- GitHub Check: Summary
|
These changes were released in v1.196.0-rc.0. |
what
.github/workflows/license-check.yml) to automatically audit Go project dependencies for license compliance.go.mod,go.sum, or the workflow file itself.scripts/check-licenses.sh) was introduced to perform the actual license check usinggo-licenses.go-licenses reportis now uploaded as a GitHub Actions artifact.why
references
Summary by CodeRabbit