From 0922602a0c08a07d0cdfd4287a257f9471b1cb06 Mon Sep 17 00:00:00 2001 From: Anirudh Ramchandran Date: Mon, 21 Oct 2024 14:33:47 -0400 Subject: [PATCH] test both workflow for automated commits --- .github/workflows/backend-license-checker.yml | 41 +++++++++++++++---- .../frontend-lint-license-checker.yml | 2 +- app/api/api/__init__.py | 3 -- app/frontend/src/api/modelsDeployedApis.ts | 3 +- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/.github/workflows/backend-license-checker.yml b/.github/workflows/backend-license-checker.yml index 8508de5e..0c9df3d3 100644 --- a/.github/workflows/backend-license-checker.yml +++ b/.github/workflows/backend-license-checker.yml @@ -1,6 +1,3 @@ - -# - name: Backend-Models SPDX Licenses Checker on: @@ -22,12 +19,17 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 + - uses: actions/setup-python@v5.0.0 with: cache: "pip" python-version: "3.8" + + # Install the copyright checking tool - name: Install copyright check tool run: pip install git+https://github.com/espressif/check-copyright.git@master + + # Check SPDX licenses - name: Check SPDX licenses id: check_spdx_licenses run: | @@ -40,10 +42,13 @@ jobs: echo "EOF" >> $GITHUB_ENV echo "EXIT_CODE=$exit_code" >> $GITHUB_ENV exit 0 + - name: Debug Extracted Files run: | echo "Extracted Files:" echo "$CLEAN_OUTPUT" + + # Extract files needing SPDX header addition - name: Extract Files id: extract_files run: | @@ -60,25 +65,46 @@ jobs: echo "EOF" >> $GITHUB_ENV echo "Extracted Files: $files" exit 0 + - name: Debug Extracted Files run: | echo "Extracted Files:" echo "$FILES" + + # Run the `add_spdx_header.py` script to fix missing SPDX headers + - name: Run SPDX Header Script + if: env.FILES != '' + run: | + set +e + python add_spdx_header.py # Run the script to add SPDX headers to the missing files + exit 0 + + # Commit the changes made by `add_spdx_header.py` + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_user_name: SPDX-Bot + commit_user_email: bot@example.com + commit_message: '🚨✨AUTOMATED COMMIT | Added missing SPDX license headers automatically' + branch: ${{ github.head_ref }} + + # Extract and clean file paths - name: Extract File Paths if: env.FILES != '' run: | - # Extract lines starting with './' but ignore any paths following "Modified files:" until a stop marker files_clean=$(echo "$FILES" | awk '/^Modified files:/ {ignore = 1} /^Above is a list of files/ {ignore = 0} !ignore && /^\.\// {print}' | sort | uniq) - # Save the cleaned files into a new environment variable 'FILES_CLEAN' echo "FILES_CLEAN<> $GITHUB_ENV echo "$files_clean" >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV - echo "Extracted Paths: $files_clean" + echo "Extracted Paths: $files_clean" + - name: Debug Extracted Paths run: | echo "Extracted Paths:" echo "$FILES_CLEAN" echo "---------------------------------" + + # Post a comment on the PR or Issue if there are SPDX issues - name: Comment on PR or Issue if: env.FILES_CLEAN != '' uses: actions/github-script@v7 @@ -89,7 +115,7 @@ jobs: const owner = context.repo.owner; const repo = context.repo.repo; if (formattedOutput) { - const commentBody = `Our automated SPDX license verification process has discovered that the following files are missing a license header:\n\`\`\`\n${formattedOutput}\n\`\`\`\nPlease ensure each indicated file includes a valid SPDX license identifier. This is essential for maintaining licensing compliance. Your attention and cooperation in updating these files are greatly appreciated. Thank you.`; + const commentBody = `Our automated SPDX license verification process has discovered that the following files are missing a license header:\n\`\`\`\n${formattedOutput}\n\`\`\`\nPlease ensure each indicated file includes a valid SPDX license identifier. This is essential for maintaining licensing compliance. Thank you.`; await github.rest.issues.createComment({ issue_number: issueNumber, owner: owner, @@ -99,4 +125,3 @@ jobs: core.setFailed("SPDX license issues found."); } else { console.log("No SPDX license issues found."); - } \ No newline at end of file diff --git a/.github/workflows/frontend-lint-license-checker.yml b/.github/workflows/frontend-lint-license-checker.yml index b4854e79..18f72ab9 100644 --- a/.github/workflows/frontend-lint-license-checker.yml +++ b/.github/workflows/frontend-lint-license-checker.yml @@ -65,7 +65,7 @@ jobs: with: commit_user_name: CleanBot commit_user_email: your-email@example.com - commit_message: '*** AUTOMATED COMMIT | Applied Code Formatting and Cleanup ✨***' + commit_message: '🚨✨ AUTOMATED COMMIT | Applied Code Formatting, Cleanup and added SPDX license headers' commit_options: ${{ env.GPG_KEY_EXISTS == 'true' && '-S' || '' }} branch: ${{ github.head_ref }} diff --git a/app/api/api/__init__.py b/app/api/api/__init__.py index 4da24a6e..8b137891 100644 --- a/app/api/api/__init__.py +++ b/app/api/api/__init__.py @@ -1,4 +1 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC diff --git a/app/frontend/src/api/modelsDeployedApis.ts b/app/frontend/src/api/modelsDeployedApis.ts index f37e436c..16b26845 100644 --- a/app/frontend/src/api/modelsDeployedApis.ts +++ b/app/frontend/src/api/modelsDeployedApis.ts @@ -1,5 +1,4 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC + import axios from "axios"; import { customToast } from "../components/CustomToaster"; import { NavigateFunction } from "react-router-dom";