ci: add license compliance checks and LICENSE-3RD-PARTY.txt generation #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: License compliance | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| pull_request: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| env: | |
| CARGO_TERM_COLOR: always | |
| # Tool versions (adapt as needed; not required to match atlas-local-lib). | |
| CARGO_DENY_VERSION: "0.16.3" | |
| CARGO_ABOUT_VERSION: "0.9.1" | |
| # Allowed licenses for the Python layer. Must mirror deny.toml `licenses.allow` | |
| # and about.toml `accepted`. pip-licenses matches the license string reported | |
| # in package metadata, so several spellings of each SPDX id are listed. | |
| PY_ALLOWED_LICENSES: >- | |
| MIT License;MIT; | |
| Apache Software License;Apache License 2.0;Apache 2.0;Apache-2.0;Apache-2.0 WITH LLVM-exception; | |
| BSD Zero Clause License;0BSD; | |
| The Unlicense (Unlicense);Unlicense; | |
| Boost Software License 1.0 (BSL-1.0);BSL-1.0; | |
| Unicode-3.0 | |
| jobs: | |
| check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@4cda84d5c5c54efe2404f9d843567869ab1699d4 # stable | |
| with: | |
| toolchain: stable | |
| - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6 | |
| with: | |
| python-version: "3.x" | |
| - name: Cache cargo registry | |
| uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-license-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo-license- | |
| - name: Install cargo-binstall | |
| uses: cargo-bins/cargo-binstall@732870f031d2fb36309d0deaf36abcc704a7be65 # v1.20.1 | |
| - name: Install cargo-deny and cargo-about | |
| run: | | |
| cargo binstall --no-confirm --locked --version "${CARGO_DENY_VERSION}" cargo-deny | |
| cargo binstall --no-confirm --locked --version "${CARGO_ABOUT_VERSION}" cargo-about | |
| - name: Install package and Python tooling | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install . pip-licenses packaging | |
| # 1. Rust dependency license policy. | |
| - name: Check Rust dependency licenses | |
| run: cargo deny --all-features check licenses | |
| # 2. Python dependency license policy. | |
| - name: Check Python dependency licenses | |
| run: | | |
| set -euo pipefail | |
| deps="$(python scripts/py_runtime_deps.py | tr '\n' ' ')" | |
| if [ -z "${deps}" ]; then | |
| echo "No third-party Python runtime dependencies to check." | |
| exit 0 | |
| fi | |
| allowed="$(echo "${PY_ALLOWED_LICENSES}" | tr -d '\n' | tr -s ' ')" | |
| echo "Checking: ${deps}" | |
| pip-licenses --packages ${deps} --allow-only "${allowed}" | |
| # 3. Regenerate LICENSE-3RD-PARTY.txt and fail if the checked-in copy is stale. | |
| - name: Regenerate LICENSE-3RD-PARTY.txt | |
| run: PYTHON="$(which python)" ./scripts/generate-third-party.sh | |
| - name: Fail if checked-in LICENSE-3RD-PARTY.txt is stale | |
| run: | | |
| if ! git diff --exit-code -- LICENSE-3RD-PARTY.txt; then | |
| echo "::error::LICENSE-3RD-PARTY.txt is out of date. Run ./scripts/generate-third-party.sh and commit the result." | |
| exit 1 | |
| fi |