Open-source IoT Platform - Device management, data collection, processing and visualization.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

112 lines
4.3 KiB

#
# SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
# SPDX-License-Identifier: BUSL-1.1
#
name: Check license headers
on:
push:
branches:
- master
- rc
- 'lts-[0-9]+.[0-9]+'
- 'hotfix-[0-9]+.[0-9]+'
pull_request:
branches:
- master
- rc
- 'lts-[0-9]+.[0-9]+'
- 'hotfix-[0-9]+.[0-9]+'
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
check:
name: Check license headers
runs-on: ubuntu-24.04
timeout-minutes: 30
defaults:
run:
shell: bash
steps:
- name: Checkout with full history
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
with:
distribution: corretto
java-version: 21
cache: maven
# Header-free CE contents from earlier runs. A pull request reads the cache of its base branch, then of master.
# What keeps a pull request from feeding the cache that other runs trust is GitHub's cache scoping, not the `if:`
# on the save step: a pull request runs its own copy of this workflow, and whatever it saved would be restorable
# only by that pull request. The `if:` keeps pull requests from spending the repository's cache storage.
- name: Restore normalized CE contents
id: restore-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: target/license-headers-cache
key: license-headers-ce-v1-${{ github.ref_name }}-${{ github.run_id }}
restore-keys: |
license-headers-ce-v1-${{ github.base_ref || github.ref_name }}-
license-headers-ce-v1-
# What the restore brought, to save the cache below only when this run changed it. A run that only reads the
# cache leaves its bytes as they were; the check needs no marker for this.
- name: Fingerprint restored CE contents
id: cache-fingerprint
if: github.event_name != 'pull_request'
run: echo "hash=${{ hashFiles('target/license-headers-cache/*.sqlite') }}" >> "$GITHUB_OUTPUT"
- name: Check license headers
env:
# Pull requests check only the files they change; pushes and manual runs check every file.
SINCE: ${{ github.event_name == 'pull_request' && format('origin/{0}', github.base_ref) || '' }}
run: |
mkdir -p target/license-provenance
# The runner does nothing else: use every CPU, not all but one as on a workstation.
LICENSE_HEADERS_JOBS="$(nproc)"
export LICENSE_HEADERS_JOBS
# A run uses the cache of one signature; older ones would only make every save and restore larger.
export LICENSE_HEADERS_CACHE_SIGNATURES=1
./check-license-headers.sh ${SINCE:+--since "$SINCE"} 2>&1 | tee target/license-provenance/console.log
# Saved even when the check finds problems, but only when the run changed the cache: it normalized something
# the cache lacked, or it pruned the databases of other signatures.
- name: Save normalized CE contents
if: >-
always() && github.event_name != 'pull_request'
&& hashFiles('target/license-headers-cache/*.sqlite') != steps.cache-fingerprint.outputs.hash
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: target/license-headers-cache
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
- name: Add findings to the job summary
if: failure() && hashFiles('target/license-provenance/console.log') != ''
run: |
{
echo '```'
cat target/license-provenance/console.log
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
- name: Upload report
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: license-provenance-report
path: target/license-provenance/
retention-days: 14
if-no-files-found: ignore