Skip to content

Commit

Permalink
feat(ci): added filename lint job (lucide-icons#1782)
Browse files Browse the repository at this point in the history
  • Loading branch information
jguddas authored Jan 7, 2024
1 parent 05f209c commit bc5efd7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,26 @@ on:
- fix-icon-preview

jobs:
lint-filenames:
if: github.repository == 'lucide-icons/lucide'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: refs/pull/${{ github.event.pull_request.number }}/merge
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v41
with:
files: icons/*
- name: Generate annotations
run: node ./scripts/lintFilenames.mjs
env:
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}

lint-contributors:
if: github.repository == 'lucide-icons/lucide'
runs-on: ubuntu-latest
Expand Down
24 changes: 24 additions & 0 deletions scripts/lintFilenames.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { spawn } from 'child_process';

const regex = /(?<file>[^:]+):(?<line>\d+):(?<column>\d+)\s-\s+(?<message>.+)/;
const fileList = (process.env.CHANGED_FILES || '').split(' ');

const cspell = spawn('npx', ['cspell', 'stdin'], { stdio: ['pipe', 'pipe', 'inherit'] });
cspell.stdin.write(fileList.join('\n'));
cspell.stdin.end();

cspell.stdout.on('data', (data) => {
console.log(data.toString());
data
.toString()
.split('\n')
.forEach((line) => {
const match = line.match(regex);
if (match) {
const { line, message } = match.groups;
console.log(`::error file=${fileList[line - 1]},line=1,column=1::${message}`);
}
});
});

cspell.on('exit', process.exit);

0 comments on commit bc5efd7

Please sign in to comment.