Skip to content

Add license check workflow - #1680

Merged
Andriy Knysh (aknysh) merged 8 commits into
mainfrom
osterman/license-audit
Oct 21, 2025
Merged

Andriy Knysh (aknysh) merged 8 commits into
mainfrom
osterman/license-audit

Conversation

@osterman

@osterman Erik Osterman (Cloud Posse) (osterman) commented Oct 20, 2025 •

Copy link
Copy Markdown
Member

what

  • Added a GitHub Actions workflow (.github/workflows/license-check.yml) to automatically audit Go project dependencies for license compliance.
  • This workflow triggers on pull request events (opened, synchronize, reopened) that affect go.mod, go.sum, or the workflow file itself.
  • It also includes scheduled runs (weekly on Mondays) and manual dispatch for flexibility.
  • A new script (scripts/check-licenses.sh) was introduced to perform the actual license check using go-licenses.
  • The script checks for "forbidden" license types and generates a summary report.
  • The generated CSV report from go-licenses report is now uploaded as a GitHub Actions artifact.

why

  • To proactively identify and prevent the introduction of dependencies with problematic licenses (e.g., GPL, AGPL) into the project.
  • Automates the license auditing process, reducing manual effort and the risk of oversight.
  • Ensures compliance with licensing requirements, especially important for open-source and commercial projects.
  • The CI integration provides immediate feedback on PRs affecting dependencies.
  • Uploading the report as an artifact allows for easy review of detailed license information.

references

Summary by CodeRabbit

  • Chores
    • Added automated license compliance checks that run on pull requests, weekly, and on demand, producing a downloadable CSV license report retained for 30 days.
    • Added a license-audit workflow and scanning script that installs/checks the scanner as needed, handles known edge cases, summarizes license distribution, and emits clear pass/fail results.

@github-actions github-actions Bot added the size/l Large size PR label Oct 20, 2025
@coderabbitai

coderabbitai Bot commented Oct 20, 2025 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds 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

Cohort / File(s) Summary
Workflow
\.github/workflows/license-check.yml
New GitHub Actions workflow "License Check": triggers on PRs touching go.mod/go.sum or the workflow file, weekly cron, and manual dispatch; sets GO_VERSION=1.24, runs a license-audit job on ubuntu-latest (10m timeout), checks out code, sets up Go (with caching), installs go-licenses, runs scripts/check-licenses.sh, generates a filtered CSV, and uploads license-report artifact (30d retention).
License script
scripts/check-licenses.sh
New Bash script that ensures github.com/google/go-licenses is installed, runs a license audit with disallowed_types=forbidden, treats LGPL/MPL as acceptable for dynamic linking, recognizes/works around known package issues (xi2/xz, bearsh/hid, HashiCorp MPL-2.0 note), parses output to detect GPL/AGPL, emits a license distribution CSV, prints diagnostics, and exits with pass/fail code.

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)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Linked Issues Check ⚠️ Warning The PR is linked to issue #123, which requests configurable analytics settings (components_enabled, auto_crash_log_send_enabled, commands_enabled) in atmos.yaml to control telemetry behavior. However, the changes in this PR introduce a GitHub Actions workflow and bash script for license compliance auditing of Go dependencies. These changes do not implement any of the analytics configuration requirements specified in issue #123, nor do they address analytics-related objectives. The PR's license checking functionality is entirely unrelated to the analytics opt-in/opt-out feature requested in the linked issue. Verify that issue #123 is the correct linked issue for this PR. If license compliance checking is the intended goal, consider linking to or opening an appropriate issue for dependency license auditing. If issue #123 is correct, the PR changes should implement the analytics configuration requirements instead. Clarify with the PR author whether the linked issue reference is accurate.
Out of Scope Changes Check ⚠️ Warning The PR introduces changes for license compliance auditing via a GitHub Actions workflow and supporting bash script. The linked issue #123 specifies requirements for configurable analytics settings in atmos.yaml (such as components_enabled, auto_crash_log_send_enabled, and commands_enabled). The PR's additions for license checking are out of scope for the analytics requirements stated in issue #123, representing a different feature area entirely—CI/CD infrastructure for dependency compliance rather than user-configurable telemetry. Either update the PR to implement the analytics configuration requirements from issue #123, or unlink this PR from #123 and create or link it to a more appropriate issue focused on license compliance auditing. Confirm with the PR author which objectives should drive this changeset.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "Add license check workflow" is clear, concise, and directly describes the primary change in the changeset. The title accurately reflects the introduction of the new GitHub Actions workflow file and supporting bash script for license compliance auditing. It's specific enough that someone scanning the repository history would understand the core change without being overly detailed.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch osterman/license-audit

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mergify

mergify Bot commented Oct 20, 2025

Copy link
Copy Markdown
Contributor

Important

Cloud Posse Engineering Team Review Required

This 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 #pr-reviews channel.

@mergify mergify Bot added the needs-cloudposse Needs Cloud Posse assistance label Oct 20, 2025
@codecov

codecov Bot commented Oct 20, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.38%. Comparing base (d9d6de0) to head (5e018d5).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            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              
Flag Coverage Δ
unittests 66.38% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@osterman Erik Osterman (Cloud Posse) (osterman) added the no-release Do not create a new release (wait for additional code changes) label Oct 20, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between e73828e and 9f0a872.

⛔ Files ignored due to path filters (1)
  • licenses-full-report.csv is 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.

Comment thread .github/workflows/license-check.yml Resolved
Comment thread scripts/check-licenses.sh Resolved
- 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]>
@github-actions github-actions Bot added size/m Medium size PR and removed size/l Large size PR labels Oct 20, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
.github/workflows/license-check.yml (1)

35-35: Consider pinning go-licenses version.

Installing @latest means 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 9f0a872 and 5b0ec3f.

📒 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 W and E removes 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]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
scripts/check-licenses.sh (1)

33-34: Exit code capture from pipeline is still broken; the $? captures tee, not go-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 if go-licenses fails. This means failing license checks will incorrectly pass.

Use ${PIPESTATUS[0]} to capture the exit code of the first command, or add set -o pipefail to 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 pipefail at the top of the script

  set -e
+ set -o pipefail

Either approach works; Option 1 is more explicit about intent.

🧹 Nitpick comments (3)
scripts/check-licenses.sh (3)

5-5: Consider adding set -o pipefail for defensive pipeline handling.

While the immediate exit code issue should be fixed with ${PIPESTATUS[0]}, adding set -o pipefail provides an additional safety layer to ensure pipeline failures propagate correctly.

  set -e
+ set -o pipefail

33-33: Use a temporary directory via mktemp instead of hard-coded /tmp/license-check.log.

Hard-coded /tmp paths can cause permission issues or collisions in containerized CI environments, and the temp file is never cleaned up. Using mktemp is 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; then

Then 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 from go-licenses report always 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 5b0ec3f and d47e6a8.

📒 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

@aknysh
Andriy Knysh (aknysh) merged commit d80090d into main Oct 21, 2025
@aknysh
Andriy Knysh (aknysh) deleted the osterman/license-audit branch October 21, 2025 15:05
@mergify mergify Bot removed the needs-cloudposse Needs Cloud Posse assistance label Oct 21, 2025
@github-actions

Copy link
Copy Markdown

These changes were released in v1.196.0-rc.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-release Do not create a new release (wait for additional code changes) size/m Medium size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opt in or opt out analytics for how atmos is used

2 participants