Skip to content

ci: add GitHub Actions workflow for validate-filepaths#20616

Open
okwn wants to merge 2 commits into
github:masterfrom
okwn:contrib/dmca/ci-validate-filepaths
Open

ci: add GitHub Actions workflow for validate-filepaths#20616
okwn wants to merge 2 commits into
github:masterfrom
okwn:contrib/dmca/ci-validate-filepaths

Conversation

@okwn
Copy link
Copy Markdown

@okwn okwn commented May 21, 2026

Adds a GitHub Actions workflow that runs Jest tests for the validate-filepaths script on Node 20.

Copilot AI review requested due to automatic review settings May 21, 2026 01:19
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds CI coverage for the .github/script/validate-filepaths Node/Jest test suite by introducing a dedicated GitHub Actions workflow, along with a new Jest test file intended to validate filepath/date rules.

Changes:

  • Added a new GitHub Actions workflow to run npm test for validate-filepaths on Node 20.
  • Added a new Jest test file under .github/script/validate-filepaths/__tests__.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
.github/workflows/validate-filepaths.yml Runs the validate-filepaths Jest tests in CI on pushes/PRs targeting master.
.github/script/validate-filepaths/tests/validate.test.js Adds additional unit tests around year-folder detection and filename date pattern checks.
Comments suppressed due to low confidence (2)

.github/script/validate-filepaths/tests/validate.test.js:67

  • The file defines isFileInsideAYearFolder / isFilepathDateValid a second time in a later describe. Duplicating helper implementations increases the chance tests diverge over time; reuse a single helper/import across the file (or import the real functions) to keep tests consistent.
describe("filepath structure validation", () => {
  // Tests for the overall filepath structure (year folder, optional month folder, filename)

  function isFileInsideAYearFolder(filepath) {
    return filepath.match(/^\d{4}/) !== null;
  }

  function isFilepathDateValid(filepath) {
    const filename = filepath.split("/").pop();
    const dateStringInFilename = filename.match(/\d{4}-\d{2}-\d{2}/);
    return dateStringInFilename !== null;
  }

.github/script/validate-filepaths/tests/validate.test.js:91

  • This test is labeled as an “incorrect structure with non-matching date in filename”, but it asserts isFilepathDateValid(...) is true. If the intended rule is that folder year/month must match the date in the filename (as isFileInCorrectFolder enforces), update the assertions to reflect the expected failure condition and/or call the actual folder-validation function here.
  test("incorrect structure with non-matching date in filename", () => {
    const invalidPath = "2024/06/2023-06-15-brand.markdown";
    expect(isFileInsideAYearFolder(invalidPath)).toBe(true);
    expect(isFilepathDateValid(invalidPath)).toBe(true);
  });

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +22 to +24

- name: Install dependencies
run: npm install
Comment on lines +6 to +10
// This function is defined in index.js - we test the logic it's testing

function isFileInsideAYearFolder(filepath) {
return filepath.match(/^\d{4}/) !== null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants