AlphaGit / jekyll-seo-ai-action

Generate SEO actions through the use of AI for Jekyll blogs/pages
MIT License
0 stars 1 forks source link

Sweep: avoid commits if there are no changed files #13

Closed AlphaGit closed 1 year ago

AlphaGit commented 1 year ago

Modify the index.js file so that if the list of changed files is empty or null, the call to createCommit is not done.

Checklist - [X] `index.js` ✅ Commit [`657fca4`](https://github.com/AlphaGit/jekyll-seo-ai-action/commit/657fca482d70e386efb9eec7350ce49b243d8eb6)
• Add a conditional check before the `createCommit` function call to verify if the list of changed files is empty or null. • If the list of changed files is empty or null, skip the `createCommit` function call.
Sandbox Execution Logs
npm install 1/3 ✓
added 317 packages, and audited 318 packages in 5s
32 packages are looking for funding
  run `npm fund` for details
1 moderate severity vulnerability
To address all issues, run:
  npm audit fix
Run `npm audit` for details.
npm notice 
npm notice New major version of npm available! 9.6.7 -> 10.1.0
npm notice Changelog: 
npm notice Run `npm install -g npm@10.1.0` to update!
npm notice 
npm test 2/3 ✓
> jekyl-seo-action@1.0.0 test
> cross-env NODE_OPTIONS=--experimental-vm-modules jest
(node:119) ExperimentalWarning: VM Modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
PASS test/generator.test.js
  ● Console
    console.error
      Error generating description for non-existent-file.md: Error: File not found
      50 |             return await generateDescription(page)
      51 |         } catch (error) {
    > 52 |             console.error(`Error generating description for ${page}: ${error}`);
         |                     ^
      53 |             return null;
      54 |         }
      55 |     });
      at src/generator.js:52:21
          at async Promise.allSettled (index 0)
      at generateDescriptions (src/generator.js:56:32)
      at Object. (test/generator.test.js:23:24)
    console.error
      Error generating description for test/fixtures/empty.md: Error: File not found
      50 |             return await generateDescription(page)
      51 |         } catch (error) {
    > 52 |             console.error(`Error generating description for ${page}: ${error}`);
         |                     ^
      53 |             return null;
      54 |         }
      55 |     });
      at src/generator.js:52:21
          at async Promise.allSettled (index 0)
      at generateDescriptions (src/generator.js:56:32)
      at Object. (test/generator.test.js:28:24)
    console.error
      Error generating description for test/fixtures/with-description.md: Error: File not found
      50 |             return await generateDescription(page)
      51 |         } catch (error) {
    > 52 |             console.error(`Error generating description for ${page}: ${error}`);
         |                     ^
      53 |             return null;
      54 |         }
      55 |     });
      at src/generator.js:52:21
          at async Promise.allSettled (index 0)
      at generateDescriptions (src/generator.js:56:32)
      at Object. (test/generator.test.js:33:24)
    console.warn
      No front matter found for test/fixtures/without-front-matter.md -- is it really a blog post?
      19 |     const regexMatch = pageContents.match(FRONT_MATTER_REGEX);
      20 |     if (!regexMatch || regexMatch.length < 2) {
    > 21 |         console.warn(`No front matter found for ${page} -- is it really a blog post?`);
         |                 ^
      22 |         return null;
      23 |     }
      24 |     const rawFrontMatter = regexMatch[1];
      at generateDescription (src/generator.js:21:17)
      at src/generator.js:50:20
          at async Promise.allSettled (index 0)
      at generateDescriptions (src/generator.js:56:32)
      at Object. (test/generator.test.js:39:24)
    console.warn
      No front matter found for test/fixtures/without-date.md -- is it really a blog post?
      26 |
      27 |     if (!fronMatter) {
    > 28 |         console.warn(`No front matter found for ${page} -- is it really a blog post?`);
         |                 ^
      29 |         return null;
      30 |     }
      31 |     if (fronMatter && fronMatter.description) {
      at generateDescription (src/generator.js:28:17)
      at src/generator.js:50:20
          at async Promise.allSettled (index 0)
      at generateDescriptions (src/generator.js:56:32)
      at Object. (test/generator.test.js:45:24)
    console.info
      Front matter already contains a description for test/fixtures/with-description.md -- skipping
      at generateDescription (src/generator.js:32:17)
          at async Promise.allSettled (index 0)
(node:120) ExperimentalWarning: VM Modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
PASS test/openai-client.test.js
------------------|---------|----------|---------|---------|-------------------
File              | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
------------------|---------|----------|---------|---------|-------------------
All files         |   80.18 |     91.3 |     100 |   80.18 |                   
 generator.js     |     100 |      100 |     100 |     100 |                   
 openai-client.js |      45 |       60 |     100 |      45 | 16-31,34-39       
 settings.js      |     100 |      100 |     100 |     100 |                   
------------------|---------|----------|---------|---------|-------------------
Test Suites: 2 passed, 2 total
Tests:       10 passed, 10 total
Snapshots:   0 total
Time:        1.391 s
Ran all test suites.
npm run build 3/3 ✓
> jekyl-seo-action@1.0.0 build
> esbuild index.js --bundle --platform=node --outfile=dist/index.js --target=es2020
  dist/index.js  1.1mb ⚠️
⚡ Done in 94ms
sweep-ai[bot] commented 1 year ago

Here's the PR! https://github.com/AlphaGit/jekyll-seo-ai-action/pull/14.

⚡ Sweep Free Trial: I'm creating this ticket using GPT-3.5. You have 0 GPT-4 tickets left for the month and 0 for the day. For more GPT-4 tickets, visit [our payment portal.](https://buy.stripe.com/6oE5npbGVbhC97afZ4)

Actions (click)


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/AlphaGit/jekyll-seo-ai-action/blob/72cac02f2bbf7676b0ea1a7006af0831d7726d40/index.js#L1-L21 https://github.com/AlphaGit/jekyll-seo-ai-action/blob/72cac02f2bbf7676b0ea1a7006af0831d7726d40/src/github.js#L1-L90

Step 2: ⌨️ Coding

npm install 1/3 ✓
added 317 packages, and audited 318 packages in 5s
32 packages are looking for funding
  run `npm fund` for details
1 moderate severity vulnerability
To address all issues, run:
  npm audit fix
Run `npm audit` for details.
npm notice 
npm notice New major version of npm available! 9.6.7 -> 10.1.0
npm notice Changelog: 
npm notice Run `npm install -g npm@10.1.0` to update!
npm notice 
npm test 2/3 ✓
> jekyl-seo-action@1.0.0 test
> cross-env NODE_OPTIONS=--experimental-vm-modules jest
(node:119) ExperimentalWarning: VM Modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
PASS test/generator.test.js
  ● Console
    console.error
      Error generating description for non-existent-file.md: Error: File not found
      50 |             return await generateDescription(page)
      51 |         } catch (error) {
    > 52 |             console.error(`Error generating description for ${page}: ${error}`);
         |                     ^
      53 |             return null;
      54 |         }
      55 |     });
      at src/generator.js:52:21
          at async Promise.allSettled (index 0)
      at generateDescriptions (src/generator.js:56:32)
      at Object. (test/generator.test.js:23:24)
    console.error
      Error generating description for test/fixtures/empty.md: Error: File not found
      50 |             return await generateDescription(page)
      51 |         } catch (error) {
    > 52 |             console.error(`Error generating description for ${page}: ${error}`);
         |                     ^
      53 |             return null;
      54 |         }
      55 |     });
      at src/generator.js:52:21
          at async Promise.allSettled (index 0)
      at generateDescriptions (src/generator.js:56:32)
      at Object. (test/generator.test.js:28:24)
    console.error
      Error generating description for test/fixtures/with-description.md: Error: File not found
      50 |             return await generateDescription(page)
      51 |         } catch (error) {
    > 52 |             console.error(`Error generating description for ${page}: ${error}`);
         |                     ^
      53 |             return null;
      54 |         }
      55 |     });
      at src/generator.js:52:21
          at async Promise.allSettled (index 0)
      at generateDescriptions (src/generator.js:56:32)
      at Object. (test/generator.test.js:33:24)
    console.warn
      No front matter found for test/fixtures/without-front-matter.md -- is it really a blog post?
      19 |     const regexMatch = pageContents.match(FRONT_MATTER_REGEX);
      20 |     if (!regexMatch || regexMatch.length < 2) {
    > 21 |         console.warn(`No front matter found for ${page} -- is it really a blog post?`);
         |                 ^
      22 |         return null;
      23 |     }
      24 |     const rawFrontMatter = regexMatch[1];
      at generateDescription (src/generator.js:21:17)
      at src/generator.js:50:20
          at async Promise.allSettled (index 0)
      at generateDescriptions (src/generator.js:56:32)
      at Object. (test/generator.test.js:39:24)
    console.warn
      No front matter found for test/fixtures/without-date.md -- is it really a blog post?
      26 |
      27 |     if (!fronMatter) {
    > 28 |         console.warn(`No front matter found for ${page} -- is it really a blog post?`);
         |                 ^
      29 |         return null;
      30 |     }
      31 |     if (fronMatter && fronMatter.description) {
      at generateDescription (src/generator.js:28:17)
      at src/generator.js:50:20
          at async Promise.allSettled (index 0)
      at generateDescriptions (src/generator.js:56:32)
      at Object. (test/generator.test.js:45:24)
    console.info
      Front matter already contains a description for test/fixtures/with-description.md -- skipping
      at generateDescription (src/generator.js:32:17)
          at async Promise.allSettled (index 0)
(node:120) ExperimentalWarning: VM Modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
PASS test/openai-client.test.js
------------------|---------|----------|---------|---------|-------------------
File              | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
------------------|---------|----------|---------|---------|-------------------
All files         |   80.18 |     91.3 |     100 |   80.18 |                   
 generator.js     |     100 |      100 |     100 |     100 |                   
 openai-client.js |      45 |       60 |     100 |      45 | 16-31,34-39       
 settings.js      |     100 |      100 |     100 |     100 |                   
------------------|---------|----------|---------|---------|-------------------
Test Suites: 2 passed, 2 total
Tests:       10 passed, 10 total
Snapshots:   0 total
Time:        1.391 s
Ran all test suites.
npm run build 3/3 ✓
> jekyl-seo-action@1.0.0 build
> esbuild index.js --bundle --platform=node --outfile=dist/index.js --target=es2020
  dist/index.js  1.1mb ⚠️
⚡ Done in 94ms


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/avoid-commits-if-no-changed-files.

.


🎉 Latest improvements to Sweep:


💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request. Join Our Discord