Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anirud/legal-suggestion #75

Merged
merged 15 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 21 additions & 64 deletions .github/workflows/backend-license-checker.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Backend-Models SPDX Licenses Checker
name: Check SPDX Licenses

on:
workflow_dispatch:
Expand All @@ -19,17 +19,12 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4

- uses: actions/[email protected]
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: |
Expand All @@ -42,13 +37,10 @@ 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: |
Expand All @@ -65,80 +57,45 @@ 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
if: env.FILES != ''
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_user_name: SPDX-Bot
commit_user_email: [email protected]
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<<EOF" >> $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
with:
script: |
const formattedOutput = process.env.FILES_CLEAN;
const issueNumber = context.payload.pull_request.number;
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. Thank you.`;
await github.rest.issues.createComment({
issue_number: issueNumber,
owner: owner,
repo: repo,
body: commentBody
});
} else {
console.log("No SPDX license issues found.");
}

- name: Run SPDX Header Script Again
run: |
set +e
echo "Running SPDX header script again on all files in the repository"
python ./add_spdx_header.py
exit 0

# Commit the changes made by the second run of `add_spdx_header.py`
- name: Commit changes from second run
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_user_name: SPDX-Bot
commit_user_email: [email protected]
commit_message: '🚨✨AUTOMATED COMMIT | Final SPDX license header additions'
branch: ${{ github.head_ref }}
script: |
const formattedOutput = process.env.FILES_CLEAN;
const issueNumber = context.issue.number || context.payload.pull_request.number;
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.`;
await github.rest.issues.createComment({
issue_number: issueNumber,
owner: owner,
repo: repo,
body: commentBody
});
core.setFailed("SPDX license issues found.");
} else {
console.log("No SPDX license issues found.");
}
36 changes: 4 additions & 32 deletions .github/workflows/frontend-lint-license-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,6 @@ jobs:
set +e
npm run lint || true # Run lint and allow the workflow to continue even if there are warnings/errors

# Check if GPG key exists
- name: Check if GPG key exists
run: |
if [ -n "${{ secrets.GPG_PRIVATE_KEY }}" ]; then
echo "GPG_KEY_EXISTS=true" >> $GITHUB_ENV
else
echo "GPG_KEY_EXISTS=false" >> $GITHUB_ENV
fi

# Import GPG key if it exists
- name: Import GPG key if it exists
if: env.GPG_KEY_EXISTS == 'true'
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true

# Auto-commit changes using stefanzweifel/git-auto-commit-action
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_user_name: CleanBot
commit_user_email: [email protected]
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 }}

# Run ESLint and Capture Output
- name: Run ESLint and Capture Output
working-directory: app/frontend
Expand Down Expand Up @@ -152,11 +123,11 @@ jobs:

if (process.env.MISSING_LC_HEADERS === 'true') {
const flaggedFiles = process.env.LC_FLAGGED_FILES.trim();
commentBody += `## 🚨 SPDX-License Header Errors\n\nThe following files are missing the required license headers:\n\n\`\`\`\n${flaggedFiles}\n\`\`\`\nPlease ensure each of these files includes a valid SPDX license identifier. This is essential for maintaining licensing compliance. Thank you!`;
commentBody += `## 🚨 SPDX-License Header Errors\n\nThe following files are missing the required license headers:\n\n\`\`\`\n${flaggedFiles}\n\`\`\`\nPlease ensure each of these files includes a valid SPDX license identifier to maintain licensing compliance.`;
}

if (lintErrors) {
commentBody += `## Frontend Project: ESLint Errors\n\`\`\`\n${lintErrors}\n\`\`\`\nPlease review and resolve the ESLint errors.`;
commentBody += `\n\n## Frontend Project: ESLint Errors\n\`\`\`\n${lintErrors}\n\`\`\`\nPlease review and resolve the ESLint errors.`;
}

if (commentBody.trim() && issueNumber) {
Expand All @@ -169,8 +140,9 @@ jobs:
} else {
console.log("No relevant errors to report.");
}

- name: Fail the Workflow if LC Headers Are Missing
if: env.MISSING_LC_HEADERS == 'true'
run: |
echo "Failing the workflow because LC headers are missing."
exit 1
exit 1
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,5 @@ distributed as part of the software:

- Django [License available here](https://github.com/django/django/blob/main/LICENSE)
- Docker [License available here](https://github.com/docker/docs/blob/main/LICENSE)
- shadcn/ui [License available here](https://github.com/shadcn/ui/blob/main/LICENSE.md)
- Third Party Libraries used in Frontend Product [License available here](app/frontend/third-party-licenses.txt)
4 changes: 1 addition & 3 deletions app/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# SPDX-License-Identifier: Apache-2.0
#
# SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC


FROM python:3.12.5-slim-bookworm

Expand Down
3 changes: 2 additions & 1 deletion app/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"dev": "vite ",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0 --fix",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint-fix":"eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0 --fix",
"preview": "vite preview",
"generate-license": "npx generate-license-file --input package.json --output ./third-party-licenses.txt"
},
Expand Down
6 changes: 6 additions & 0 deletions app/frontend/src/components/ui/accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC
// SPDX-License-Identifier: Apache-2.0
// This file incorporates work covered by the following copyright and permission notice:
// SPDX-FileCopyrightText: Copyright (c) 2023 shadcn
// SPDX-License-Identifier: MIT

import * as React from "react";
import * as AccordionPrimitive from "@radix-ui/react-accordion";
import { ChevronDown } from "lucide-react";
Expand Down
7 changes: 7 additions & 0 deletions app/frontend/src/components/ui/alert-dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
// SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC
// SPDX-License-Identifier: Apache-2.0
// This file incorporates work covered by the following copyright and permission notice:
// SPDX-FileCopyrightText: Copyright (c) 2023 shadcn
// SPDX-License-Identifier: MIT


import * as React from "react"
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"

Expand Down
7 changes: 7 additions & 0 deletions app/frontend/src/components/ui/alert.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
// SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC
// SPDX-License-Identifier: Apache-2.0
// This file incorporates work covered by the following copyright and permission notice:
// SPDX-FileCopyrightText: Copyright (c) 2023 shadcn
// SPDX-License-Identifier: MIT


import * as React from "react";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "../../lib/utils";
Expand Down
7 changes: 7 additions & 0 deletions app/frontend/src/components/ui/aspect-ratio.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
// SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC
// SPDX-License-Identifier: Apache-2.0
// This file incorporates work covered by the following copyright and permission notice:
// SPDX-FileCopyrightText: Copyright (c) 2023 shadcn
// SPDX-License-Identifier: MIT


import * as AspectRatioPrimitive from "@radix-ui/react-aspect-ratio"

const AspectRatio = AspectRatioPrimitive.Root
Expand Down
7 changes: 7 additions & 0 deletions app/frontend/src/components/ui/badge.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
// SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC
// SPDX-License-Identifier: Apache-2.0
// This file incorporates work covered by the following copyright and permission notice:
// SPDX-FileCopyrightText: Copyright (c) 2023 shadcn
// SPDX-License-Identifier: MIT


/* this shadcnn badge component has been updated to be more specific to a status badge component and
should not be used for the other badges in the application
*/
Expand Down
7 changes: 7 additions & 0 deletions app/frontend/src/components/ui/breadcrumb.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/// SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC
// SPDX-License-Identifier: Apache-2.0
// This file incorporates work covered by the following copyright and permission notice:
// SPDX-FileCopyrightText: Copyright (c) 2023 shadcn
// SPDX-License-Identifier: MIT


import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { ChevronRight, MoreHorizontal } from "lucide-react";
Expand Down
6 changes: 6 additions & 0 deletions app/frontend/src/components/ui/button.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC
// SPDX-License-Identifier: Apache-2.0
// This file incorporates work covered by the following copyright and permission notice:
// SPDX-FileCopyrightText: Copyright (c) 2023 shadcn
// SPDX-License-Identifier: MIT

import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { cva, type VariantProps } from "class-variance-authority";
Expand Down
6 changes: 6 additions & 0 deletions app/frontend/src/components/ui/card.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC
// SPDX-License-Identifier: Apache-2.0
// This file incorporates work covered by the following copyright and permission notice:
// SPDX-FileCopyrightText: Copyright (c) 2023 shadcn
// SPDX-License-Identifier: MIT

import * as React from "react";

import { cn } from "../../lib/utils";
Expand Down
6 changes: 6 additions & 0 deletions app/frontend/src/components/ui/collapsible.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC
// SPDX-License-Identifier: Apache-2.0
// This file incorporates work covered by the following copyright and permission notice:
// SPDX-FileCopyrightText: Copyright (c) 2023 shadcn
// SPDX-License-Identifier: MIT

import * as CollapsiblePrimitive from "@radix-ui/react-collapsible"

const Collapsible = CollapsiblePrimitive.Root
Expand Down
6 changes: 6 additions & 0 deletions app/frontend/src/components/ui/command.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC
// SPDX-License-Identifier: Apache-2.0
// This file incorporates work covered by the following copyright and permission notice:
// SPDX-FileCopyrightText: Copyright (c) 2023 shadcn
// SPDX-License-Identifier: MIT

import * as React from "react";
import { type DialogProps } from "@radix-ui/react-dialog";
import { Command as CommandPrimitive } from "cmdk";
Expand Down
6 changes: 6 additions & 0 deletions app/frontend/src/components/ui/dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC
// SPDX-License-Identifier: Apache-2.0
// This file incorporates work covered by the following copyright and permission notice:
// SPDX-FileCopyrightText: Copyright (c) 2023 shadcn
// SPDX-License-Identifier: MIT

import * as React from "react";
import * as DialogPrimitive from "@radix-ui/react-dialog";
import { X } from "lucide-react";
Expand Down
6 changes: 6 additions & 0 deletions app/frontend/src/components/ui/drawer.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC
// SPDX-License-Identifier: Apache-2.0
// This file incorporates work covered by the following copyright and permission notice:
// SPDX-FileCopyrightText: Copyright (c) 2023 shadcn
// SPDX-License-Identifier: MIT

import * as React from "react";
import { Drawer as DrawerPrimitive } from "vaul";

Expand Down
6 changes: 6 additions & 0 deletions app/frontend/src/components/ui/dropdown-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC
// SPDX-License-Identifier: Apache-2.0
// This file incorporates work covered by the following copyright and permission notice:
// SPDX-FileCopyrightText: Copyright (c) 2023 shadcn
// SPDX-License-Identifier: MIT

import * as React from "react";
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
import { Check, ChevronRight, Circle } from "lucide-react";
Expand Down
6 changes: 6 additions & 0 deletions app/frontend/src/components/ui/form.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC
// SPDX-License-Identifier: Apache-2.0
// This file incorporates work covered by the following copyright and permission notice:
// SPDX-FileCopyrightText: Copyright (c) 2023 shadcn
// SPDX-License-Identifier: MIT

import * as React from "react";
import * as LabelPrimitive from "@radix-ui/react-label";
import { Slot } from "@radix-ui/react-slot";
Expand Down
6 changes: 6 additions & 0 deletions app/frontend/src/components/ui/input.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC
// SPDX-License-Identifier: Apache-2.0
// This file incorporates work covered by the following copyright and permission notice:
// SPDX-FileCopyrightText: Copyright (c) 2023 shadcn
// SPDX-License-Identifier: MIT

import * as React from "react";

import { cn } from "../../lib/utils";
Expand Down
6 changes: 6 additions & 0 deletions app/frontend/src/components/ui/label.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC
// SPDX-License-Identifier: Apache-2.0
// This file incorporates work covered by the following copyright and permission notice:
// SPDX-FileCopyrightText: Copyright (c) 2023 shadcn
// SPDX-License-Identifier: MIT

import * as React from "react";
import * as LabelPrimitive from "@radix-ui/react-label";
import { cva, type VariantProps } from "class-variance-authority";
Expand Down
Loading
Loading