From 1c392823f0bdb01a649eb58b0f84cbcb68b15147 Mon Sep 17 00:00:00 2001 From: okwn Date: Thu, 21 May 2026 01:17:59 +0000 Subject: [PATCH 1/4] test: add Jest tests for validate-filepaths --- .../__tests__/validate.test.js | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 .github/script/validate-filepaths/__tests__/validate.test.js diff --git a/.github/script/validate-filepaths/__tests__/validate.test.js b/.github/script/validate-filepaths/__tests__/validate.test.js new file mode 100644 index 00000000000..7907f243270 --- /dev/null +++ b/.github/script/validate-filepaths/__tests__/validate.test.js @@ -0,0 +1,92 @@ +/** + * Tests for validate-filepaths main script logic + */ + +describe("isFileInsideAYearFolder", () => { + // This function is defined in index.js - we test the logic it's testing + + function isFileInsideAYearFolder(filepath) { + return filepath.match(/^\d{4}/) !== null; + } + + test("returns true for file in year folder", () => { + expect(isFileInsideAYearFolder("2024/2024-01-01-brand.markdown")).toBe(true); + }); + + test("returns true for file in year/month subfolder", () => { + expect(isFileInsideAYearFolder("2024/01/2024-01-01-brand.markdown")).toBe(true); + }); + + test("returns false for file not in year folder", () => { + expect(isFileInsideAYearFolder("README.md")).toBe(false); + }); + + test("returns false for file with non-year folder", () => { + expect(isFileInsideAYearFolder("foo/2024-01-01-brand.markdown")).toBe(false); + }); +}); + +describe("filepath date validation pattern", () => { + // Tests for the YYYY-MM-DD brand.markdown naming pattern + + function isFilepathDateValid(filepath) { + const filename = filepath.split("/").pop(); + const dateStringInFilename = filename.match(/\d{4}-\d{2}-\d{2}/); + return dateStringInFilename !== null; + } + + test("validates correct YYYY-MM-DD format in filename", () => { + expect(isFilepathDateValid("2024/01/2024-01-15-brand.markdown")).toBe(true); + expect(isFilepathDateValid("2023/12/2023-12-31-company.markdown")).toBe(true); + }); + + test("invalidates incorrect date formats", () => { + expect(isFilepathDateValid("2024/1-01-15-brand.markdown")).toBe(false); + expect(isFilepathDateValid("2024/01/24-01-15-brand.markdown")).toBe(false); + expect(isFilepathDateValid("2024/01/2024-1-15-brand.markdown")).toBe(false); + expect(isFilepathDateValid("2024/01/2024-01-5-brand.markdown")).toBe(false); + }); + + test("invalidates filenames without date", () => { + expect(isFilepathDateValid("README.md")).toBe(false); + expect(isFilepathDateValid("2024/01/brand.markdown")).toBe(false); + }); +}); + +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; + } + + test("correct structure with year-only folder", () => { + const validPath = "2024/2024-06-15-brand.markdown"; + expect(isFileInsideAYearFolder(validPath)).toBe(true); + expect(isFilepathDateValid(validPath)).toBe(true); + }); + + test("correct structure with year/month folders", () => { + const validPath = "2024/06/2024-06-15-brand.markdown"; + expect(isFileInsideAYearFolder(validPath)).toBe(true); + expect(isFilepathDateValid(validPath)).toBe(true); + }); + + test("incorrect structure with missing year folder", () => { + const invalidPath = "brand/2024-06-15-brand.markdown"; + expect(isFileInsideAYearFolder(invalidPath)).toBe(false); + expect(isFilepathDateValid(invalidPath)).toBe(true); + }); + + 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); + }); +}); \ No newline at end of file From 073fcf4d9655802cdb3f7374c9b9b2cc50ac5342 Mon Sep 17 00:00:00 2001 From: okwn Date: Thu, 21 May 2026 01:18:58 +0000 Subject: [PATCH 2/4] ci: add GitHub Actions workflow for validate-filepaths --- .github/workflows/validate-filepaths.yml | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/validate-filepaths.yml diff --git a/.github/workflows/validate-filepaths.yml b/.github/workflows/validate-filepaths.yml new file mode 100644 index 00000000000..6d000d506dc --- /dev/null +++ b/.github/workflows/validate-filepaths.yml @@ -0,0 +1,29 @@ +name: Validate Filepaths Tests + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + + - name: Install dependencies + run: npm install + working-directory: .github/script/validate-filepaths + + - name: Run tests + run: npm test + working-directory: .github/script/validate-filepaths \ No newline at end of file From c0ab7559b6508bd0c8bc6783a8fd3b36d66503f5 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Tue, 26 May 2026 19:31:09 +0000 Subject: [PATCH 3/4] chore: add LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..b77bf2ab726 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From d961e33e7e5323c7e0c2d52dcf966051dd1f7fd0 Mon Sep 17 00:00:00 2001 From: OKWN Date: Wed, 27 May 2026 15:46:48 +0300 Subject: [PATCH 4/4] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .github/workflows/validate-filepaths.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/validate-filepaths.yml b/.github/workflows/validate-filepaths.yml index 6d000d506dc..e09950bd96c 100644 --- a/.github/workflows/validate-filepaths.yml +++ b/.github/workflows/validate-filepaths.yml @@ -3,9 +3,11 @@ name: Validate Filepaths Tests on: push: branches: + - main - master pull_request: branches: + - main - master jobs: