feat: add footer visibility toggle with localStorage persistence #707
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: TT-Studio Backend SPDX License Checker | |
| on: | |
| workflow_dispatch: | |
| workflow_call: | |
| pull_request: | |
| branches: | |
| - "main" | |
| - "staging" | |
| - "dev" | |
| types: | |
| - opened | |
| - reopened | |
| - synchronize | |
| - assigned | |
| - review_requested | |
| jobs: | |
| check-spdx-licenses: | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| issues: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch full history to compare with base branch | |
| - uses: actions/setup-python@v5.0.0 | |
| with: | |
| cache: "pip" | |
| python-version: "3.8" | |
| - name: Install copyright check tool | |
| run: pip install git+https://github.com/espressif/check-copyright.git@master | |
| - name: Get changed files | |
| id: changed_files | |
| run: | | |
| # Get the list of changed files in this PR | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| # For PR, compare with the base branch | |
| base_sha="${{ github.event.pull_request.base.sha }}" | |
| head_sha="${{ github.event.pull_request.head.sha }}" | |
| changed_files=$(git diff --name-only --diff-filter=AM $base_sha...$head_sha) | |
| else | |
| # For workflow_dispatch, compare with HEAD~1 | |
| changed_files=$(git diff --name-only --diff-filter=AM HEAD~1) | |
| fi | |
| # Filter for files that should be checked (Python, shell, Dockerfile) | |
| filtered_files="" | |
| for file in $changed_files; do | |
| if [[ "$file" =~ \.(py|sh)$ ]] || [[ "$file" == *"Dockerfile"* ]]; then | |
| if [ -f "$file" ]; then # Only include files that still exist | |
| filtered_files="$filtered_files $file" | |
| fi | |
| fi | |
| done | |
| echo "CHANGED_FILES<<EOF" >> $GITHUB_ENV | |
| echo "$filtered_files" >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| echo "Changed files to check: $filtered_files" | |
| - name: Check SPDX licenses on changed files | |
| id: check_spdx_licenses | |
| if: env.CHANGED_FILES != '' | |
| run: | | |
| set +e | |
| # Create temporary file list for check-copyright | |
| echo "$CHANGED_FILES" | tr ' ' '\n' > /tmp/files_to_check.txt | |
| # Run copyright check only on changed files | |
| if [ -s /tmp/files_to_check.txt ]; then | |
| output=$(python -m check_copyright --verbose --dry-run --config ./check_copyright_config.yaml $(cat /tmp/files_to_check.txt) 2>&1) | |
| exit_code=$? | |
| else | |
| output="No files to check" | |
| exit_code=0 | |
| fi | |
| clean_output=$(echo "$output" | sed 's/\x1b\[[0-9;]*m//g') | |
| echo "CLEAN_OUTPUT<<EOF" >> $GITHUB_ENV | |
| echo "$clean_output" >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| echo "EXIT_CODE=$exit_code" >> $GITHUB_ENV | |
| exit 0 | |
| - name: Extract failed files | |
| id: extract_files | |
| if: env.CHANGED_FILES != '' | |
| run: | | |
| set +e | |
| # Extract files from the "Some files are without a copyright note" section | |
| files=$(echo "$CLEAN_OUTPUT" | awk ' | |
| /Some files are without a copyright note and a license header needs to be added:/ { | |
| flag = 1 | |
| next | |
| } | |
| flag && /^$/ { | |
| flag = 0 | |
| } | |
| flag && NF > 0 && !/Some files are without/ { | |
| print $0 | |
| } | |
| ') | |
| # Filter to only include files from CHANGED_FILES | |
| files_clean="" | |
| for file in $files; do | |
| if echo "$CHANGED_FILES" | grep -q "$file"; then | |
| files_clean="$files_clean$file"$'\n' | |
| fi | |
| done | |
| echo "FILES_CLEAN<<EOF" >> $GITHUB_ENV | |
| echo "$files_clean" >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| echo "Files with missing headers: $files_clean" | |
| - name: Show results | |
| if: env.CHANGED_FILES != '' | |
| run: | | |
| echo "==================================================" | |
| if [ -n "$FILES_CLEAN" ] && [ "$FILES_CLEAN" != "" ]; then | |
| echo "🚨 SPDX LICENSE HEADERS MISSING" | |
| echo "==================================================" | |
| echo "" | |
| echo "📊 Files in this PR missing headers:" | |
| echo "$FILES_CLEAN" | |
| echo "" | |
| echo "✅ HOW TO FIX:" | |
| echo "Add these 3 lines to the top of each file:" | |
| echo "" | |
| echo "# SPDX-License-Identifier: Apache-2.0" | |
| echo "#" | |
| echo "# SPDX-FileCopyrightText: © 2025 Tenstorrent AI ULC" | |
| else | |
| echo "✅ All changed files have proper SPDX headers" | |
| fi | |
| echo "==================================================" | |
| - name: Fail workflow if headers missing | |
| if: env.FILES_CLEAN != '' && env.CHANGED_FILES != '' | |
| run: | | |
| echo "❌ Workflow failed due to missing SPDX license headers." | |
| echo "Please add proper license headers to all flagged files before merging." | |
| exit 1 | |
| - name: Skip message for no changed files | |
| if: env.CHANGED_FILES == '' | |
| run: | | |
| echo "==================================================" | |
| echo "ℹ️ No Python, shell, or Dockerfile changes detected" | |
| echo "Skipping SPDX license check" | |
| echo "==================================================" |