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

chore: exclude files with empty strings checker #88

Merged
merged 5 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
19 changes: 18 additions & 1 deletion .github/empty-string-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,24 @@ const token = process.env.GITHUB_TOKEN;
const [owner, repo] = process.env.GITHUB_REPOSITORY?.split("/") || [];
const pullNumber = process.env.GITHUB_PR_NUMBER || process.env.PULL_REQUEST_NUMBER || "0";
const baseRef = process.env.GITHUB_BASE_REF;
const excludeEnv = process.env.EXCLUDED_FILES;
const excludedFiles: string[] = [];

if (!token || !owner || !repo || pullNumber === "0" || !baseRef) {
if (!token || !owner || !repo || pullNumber === "0" || !baseRef || excludeEnv === undefined) {
core.setFailed("Missing required environment variables.");
process.exit(1);
}

// Only process excludeEnv if it has content
if (excludeEnv.length > 0) {
excludedFiles.push(
...excludeEnv
.split("\n")
.map((file) => file.trim())
.filter(Boolean)
);
}

const octokit = new Octokit({ auth: token });
const git = simpleGit();

Expand Down Expand Up @@ -96,6 +108,11 @@ function parseDiffForEmptyStrings(diff: string) {
return;
}

// Skip files in excludedFiles
if (excludedFiles.includes(currentFile)) {
return;
}

// Only process TypeScript files
if (!currentFile?.endsWith(".ts")) {
return;
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/no-empty-strings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ jobs:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_BASE_REF: ${{ github.base_ref }}
EXCLUDED_FILES:
obeys marked this conversation as resolved.
Show resolved Hide resolved
Loading