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

fix(createGHA): git remote connection errors #705

Merged
merged 6 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions __tests__/helpers/get-git-mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export default function getGitRemoteMock(
}
// second call (used to grab default branch)
if (arr.length === 2 && arr[0] === 'show' && arr[1] === remote) {
if (remote === 'bad-remote') {
return Promise.reject(
new Error(`fatal: unable to access '${remoteUrl}': Could not resolve host: ${remoteUrl}`)
) as unknown as Response<string>;
}
if (!defaultBranch) return Promise.reject(new Error('Bad mock uh oh')) as unknown as Response<string>;
return Promise.resolve(`* remote origin
Fetch URL: ${remoteUrl}
Expand Down
96 changes: 48 additions & 48 deletions __tests__/lib/__snapshots__/createGHA.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`#createGHA command inputs changelogs should run GHA creation workflow and generate valid workflow file 1`] = `
exports[`#createGHA command inputs changelogs (single) should run GHA creation workflow and generate valid workflow file 1`] = `
Copy link
Member Author

Choose a reason for hiding this comment

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

These are just the resulting snapshot changes from splitting up the describe blocks above. No actual content changes here.

"
Your GitHub Actions workflow file has been created! ✨

Expand All @@ -14,7 +14,7 @@ Almost done! Just a couple more steps:
"
`;

exports[`#createGHA command inputs changelogs should run GHA creation workflow and generate valid workflow file 2`] = `
exports[`#createGHA command inputs changelogs (single) should run GHA creation workflow and generate valid workflow file 2`] = `
"# This GitHub Actions workflow was auto-generated by the \`rdme\` cli on 2022-01-01T00:00:00.000Z
# You can view our full documentation here: https://docs.readme.com/docs/rdme
name: ReadMe GitHub Action 🦉
Expand All @@ -37,16 +37,16 @@ jobs:
- name: Run \`changelogs\` command 🚀
uses: readmeio/rdme@v7
with:
rdme: changelogs ./changelogs --key=\${{ secrets.README_API_KEY }}
rdme: changelogs ./changelogs/rdme.md --key=\${{ secrets.README_API_KEY }}
kanadgupta marked this conversation as resolved.
Show resolved Hide resolved
"
`;

exports[`#createGHA command inputs changelogs should run GHA creation workflow and generate valid workflow file 3`] = `
exports[`#createGHA command inputs changelogs (single) should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 1`] = `
"
Your GitHub Actions workflow file has been created! ✨

Almost done! Just a couple more steps:
1. Push your newly created file (.github/workflows/rdme-changelogs.yml) to GitHub 🚀
1. Push your newly created file (.github/workflows/rdme-changelogs-with-github-flag.yml) to GitHub 🚀
2. Create a GitHub secret called README_API_KEY and populate the value with your ReadMe API key (••••••••••••I_KEY) 🔑

🔐 Check out GitHub's docs for more info on creating encrypted secrets (https://docs.github.com/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository)
Expand All @@ -55,18 +55,18 @@ Almost done! Just a couple more steps:
"
`;

exports[`#createGHA command inputs changelogs should run GHA creation workflow and generate valid workflow file 4`] = `
exports[`#createGHA command inputs changelogs (single) should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 2`] = `
"# This GitHub Actions workflow was auto-generated by the \`rdme\` cli on 2022-01-01T00:00:00.000Z
# You can view our full documentation here: https://docs.readme.com/docs/rdme
name: ReadMe GitHub Action 🦉

on:
push:
branches:
# This workflow will run every time you push code to the following branch: \`some-branch\`
# This workflow will run every time you push code to the following branch: \`another-branch\`
# Check out GitHub's docs for more info on configuring this:
# https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
- some-branch
- another-branch

jobs:
rdme-changelogs:
Expand All @@ -82,12 +82,12 @@ jobs:
"
`;

exports[`#createGHA command inputs changelogs should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 1`] = `
exports[`#createGHA command inputs changelogs should run GHA creation workflow and generate valid workflow file 1`] = `
"
Your GitHub Actions workflow file has been created! ✨

Almost done! Just a couple more steps:
1. Push your newly created file (.github/workflows/rdme-changelogs-with-github-flag.yml) to GitHub 🚀
1. Push your newly created file (.github/workflows/rdme-changelogs.yml) to GitHub 🚀
2. Create a GitHub secret called README_API_KEY and populate the value with your ReadMe API key (••••••••••••I_KEY) 🔑

🔐 Check out GitHub's docs for more info on creating encrypted secrets (https://docs.github.com/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository)
Expand All @@ -96,18 +96,18 @@ Almost done! Just a couple more steps:
"
`;

exports[`#createGHA command inputs changelogs should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 2`] = `
exports[`#createGHA command inputs changelogs should run GHA creation workflow and generate valid workflow file 2`] = `
"# This GitHub Actions workflow was auto-generated by the \`rdme\` cli on 2022-01-01T00:00:00.000Z
# You can view our full documentation here: https://docs.readme.com/docs/rdme
name: ReadMe GitHub Action 🦉

on:
push:
branches:
# This workflow will run every time you push code to the following branch: \`another-branch\`
# This workflow will run every time you push code to the following branch: \`some-branch\`
# Check out GitHub's docs for more info on configuring this:
# https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
- another-branch
- some-branch

jobs:
rdme-changelogs:
Expand All @@ -123,7 +123,7 @@ jobs:
"
`;

exports[`#createGHA command inputs changelogs should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 3`] = `
exports[`#createGHA command inputs changelogs should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 1`] = `
"
Your GitHub Actions workflow file has been created! ✨

Expand All @@ -137,7 +137,7 @@ Almost done! Just a couple more steps:
"
`;

exports[`#createGHA command inputs changelogs should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 4`] = `
exports[`#createGHA command inputs changelogs should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 2`] = `
"# This GitHub Actions workflow was auto-generated by the \`rdme\` cli on 2022-01-01T00:00:00.000Z
# You can view our full documentation here: https://docs.readme.com/docs/rdme
name: ReadMe GitHub Action 🦉
Expand All @@ -160,11 +160,11 @@ jobs:
- name: Run \`changelogs\` command 🚀
uses: readmeio/rdme@v7
with:
rdme: changelogs ./changelogs/rdme.md --key=\${{ secrets.README_API_KEY }}
rdme: changelogs ./changelogs --key=\${{ secrets.README_API_KEY }}
"
`;

exports[`#createGHA command inputs custompages should run GHA creation workflow and generate valid workflow file 1`] = `
exports[`#createGHA command inputs custompages (single) should run GHA creation workflow and generate valid workflow file 1`] = `
"
Your GitHub Actions workflow file has been created! ✨

Expand All @@ -178,7 +178,7 @@ Almost done! Just a couple more steps:
"
`;

exports[`#createGHA command inputs custompages should run GHA creation workflow and generate valid workflow file 2`] = `
exports[`#createGHA command inputs custompages (single) should run GHA creation workflow and generate valid workflow file 2`] = `
"# This GitHub Actions workflow was auto-generated by the \`rdme\` cli on 2022-01-01T00:00:00.000Z
# You can view our full documentation here: https://docs.readme.com/docs/rdme
name: ReadMe GitHub Action 🦉
Expand All @@ -201,16 +201,16 @@ jobs:
- name: Run \`custompages\` command 🚀
uses: readmeio/rdme@v7
with:
rdme: custompages ./custompages --key=\${{ secrets.README_API_KEY }}
rdme: custompages ./custompages/rdme.md --key=\${{ secrets.README_API_KEY }}
"
`;

exports[`#createGHA command inputs custompages should run GHA creation workflow and generate valid workflow file 3`] = `
exports[`#createGHA command inputs custompages (single) should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 1`] = `
"
Your GitHub Actions workflow file has been created! ✨

Almost done! Just a couple more steps:
1. Push your newly created file (.github/workflows/rdme-custompages.yml) to GitHub 🚀
1. Push your newly created file (.github/workflows/rdme-custompages-with-github-flag.yml) to GitHub 🚀
2. Create a GitHub secret called README_API_KEY and populate the value with your ReadMe API key (••••••••••••I_KEY) 🔑

🔐 Check out GitHub's docs for more info on creating encrypted secrets (https://docs.github.com/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository)
Expand All @@ -219,18 +219,18 @@ Almost done! Just a couple more steps:
"
`;

exports[`#createGHA command inputs custompages should run GHA creation workflow and generate valid workflow file 4`] = `
exports[`#createGHA command inputs custompages (single) should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 2`] = `
"# This GitHub Actions workflow was auto-generated by the \`rdme\` cli on 2022-01-01T00:00:00.000Z
# You can view our full documentation here: https://docs.readme.com/docs/rdme
name: ReadMe GitHub Action 🦉

on:
push:
branches:
# This workflow will run every time you push code to the following branch: \`some-branch\`
# This workflow will run every time you push code to the following branch: \`another-branch\`
# Check out GitHub's docs for more info on configuring this:
# https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
- some-branch
- another-branch

jobs:
rdme-custompages:
Expand All @@ -246,12 +246,12 @@ jobs:
"
`;

exports[`#createGHA command inputs custompages should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 1`] = `
exports[`#createGHA command inputs custompages should run GHA creation workflow and generate valid workflow file 1`] = `
"
Your GitHub Actions workflow file has been created! ✨

Almost done! Just a couple more steps:
1. Push your newly created file (.github/workflows/rdme-custompages-with-github-flag.yml) to GitHub 🚀
1. Push your newly created file (.github/workflows/rdme-custompages.yml) to GitHub 🚀
2. Create a GitHub secret called README_API_KEY and populate the value with your ReadMe API key (••••••••••••I_KEY) 🔑

🔐 Check out GitHub's docs for more info on creating encrypted secrets (https://docs.github.com/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository)
Expand All @@ -260,18 +260,18 @@ Almost done! Just a couple more steps:
"
`;

exports[`#createGHA command inputs custompages should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 2`] = `
exports[`#createGHA command inputs custompages should run GHA creation workflow and generate valid workflow file 2`] = `
"# This GitHub Actions workflow was auto-generated by the \`rdme\` cli on 2022-01-01T00:00:00.000Z
# You can view our full documentation here: https://docs.readme.com/docs/rdme
name: ReadMe GitHub Action 🦉

on:
push:
branches:
# This workflow will run every time you push code to the following branch: \`another-branch\`
# This workflow will run every time you push code to the following branch: \`some-branch\`
# Check out GitHub's docs for more info on configuring this:
# https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
- another-branch
- some-branch

jobs:
rdme-custompages:
Expand All @@ -287,7 +287,7 @@ jobs:
"
`;

exports[`#createGHA command inputs custompages should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 3`] = `
exports[`#createGHA command inputs custompages should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 1`] = `
"
Your GitHub Actions workflow file has been created! ✨

Expand All @@ -301,7 +301,7 @@ Almost done! Just a couple more steps:
"
`;

exports[`#createGHA command inputs custompages should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 4`] = `
exports[`#createGHA command inputs custompages should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 2`] = `
"# This GitHub Actions workflow was auto-generated by the \`rdme\` cli on 2022-01-01T00:00:00.000Z
# You can view our full documentation here: https://docs.readme.com/docs/rdme
name: ReadMe GitHub Action 🦉
Expand All @@ -324,11 +324,11 @@ jobs:
- name: Run \`custompages\` command 🚀
uses: readmeio/rdme@v7
with:
rdme: custompages ./custompages/rdme.md --key=\${{ secrets.README_API_KEY }}
rdme: custompages ./custompages --key=\${{ secrets.README_API_KEY }}
"
`;

exports[`#createGHA command inputs docs should run GHA creation workflow and generate valid workflow file 1`] = `
exports[`#createGHA command inputs docs (single) should run GHA creation workflow and generate valid workflow file 1`] = `
"
Your GitHub Actions workflow file has been created! ✨

Expand All @@ -342,7 +342,7 @@ Almost done! Just a couple more steps:
"
`;

exports[`#createGHA command inputs docs should run GHA creation workflow and generate valid workflow file 2`] = `
exports[`#createGHA command inputs docs (single) should run GHA creation workflow and generate valid workflow file 2`] = `
"# This GitHub Actions workflow was auto-generated by the \`rdme\` cli on 2022-01-01T00:00:00.000Z
# You can view our full documentation here: https://docs.readme.com/docs/rdme
name: ReadMe GitHub Action 🦉
Expand All @@ -365,16 +365,16 @@ jobs:
- name: Run \`docs\` command 🚀
uses: readmeio/rdme@v7
with:
rdme: docs --key=\${{ secrets.README_API_KEY }} --version=1.0.0
rdme: docs ./docs/rdme.md --key=\${{ secrets.README_API_KEY }} --version=1.0.0
"
`;

exports[`#createGHA command inputs docs should run GHA creation workflow and generate valid workflow file 3`] = `
exports[`#createGHA command inputs docs (single) should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 1`] = `
"
Your GitHub Actions workflow file has been created! ✨

Almost done! Just a couple more steps:
1. Push your newly created file (.github/workflows/rdme-docs.yml) to GitHub 🚀
1. Push your newly created file (.github/workflows/rdme-docs-with-github-flag.yml) to GitHub 🚀
2. Create a GitHub secret called README_API_KEY and populate the value with your ReadMe API key (••••••••••••I_KEY) 🔑

🔐 Check out GitHub's docs for more info on creating encrypted secrets (https://docs.github.com/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository)
Expand All @@ -383,18 +383,18 @@ Almost done! Just a couple more steps:
"
`;

exports[`#createGHA command inputs docs should run GHA creation workflow and generate valid workflow file 4`] = `
exports[`#createGHA command inputs docs (single) should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 2`] = `
"# This GitHub Actions workflow was auto-generated by the \`rdme\` cli on 2022-01-01T00:00:00.000Z
# You can view our full documentation here: https://docs.readme.com/docs/rdme
name: ReadMe GitHub Action 🦉

on:
push:
branches:
# This workflow will run every time you push code to the following branch: \`some-branch\`
# This workflow will run every time you push code to the following branch: \`another-branch\`
# Check out GitHub's docs for more info on configuring this:
# https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
- some-branch
- another-branch

jobs:
rdme-docs:
Expand All @@ -410,12 +410,12 @@ jobs:
"
`;

exports[`#createGHA command inputs docs should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 1`] = `
exports[`#createGHA command inputs docs should run GHA creation workflow and generate valid workflow file 1`] = `
"
Your GitHub Actions workflow file has been created! ✨

Almost done! Just a couple more steps:
1. Push your newly created file (.github/workflows/rdme-docs-with-github-flag.yml) to GitHub 🚀
1. Push your newly created file (.github/workflows/rdme-docs.yml) to GitHub 🚀
2. Create a GitHub secret called README_API_KEY and populate the value with your ReadMe API key (••••••••••••I_KEY) 🔑

🔐 Check out GitHub's docs for more info on creating encrypted secrets (https://docs.github.com/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository)
Expand All @@ -424,18 +424,18 @@ Almost done! Just a couple more steps:
"
`;

exports[`#createGHA command inputs docs should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 2`] = `
exports[`#createGHA command inputs docs should run GHA creation workflow and generate valid workflow file 2`] = `
"# This GitHub Actions workflow was auto-generated by the \`rdme\` cli on 2022-01-01T00:00:00.000Z
# You can view our full documentation here: https://docs.readme.com/docs/rdme
name: ReadMe GitHub Action 🦉

on:
push:
branches:
# This workflow will run every time you push code to the following branch: \`another-branch\`
# This workflow will run every time you push code to the following branch: \`some-branch\`
# Check out GitHub's docs for more info on configuring this:
# https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
- another-branch
- some-branch

jobs:
rdme-docs:
Expand All @@ -451,7 +451,7 @@ jobs:
"
`;

exports[`#createGHA command inputs docs should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 3`] = `
exports[`#createGHA command inputs docs should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 1`] = `
"
Your GitHub Actions workflow file has been created! ✨

Expand All @@ -465,7 +465,7 @@ Almost done! Just a couple more steps:
"
`;

exports[`#createGHA command inputs docs should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 4`] = `
exports[`#createGHA command inputs docs should run GHA creation workflow with \`--github\` flag and messy file name and generate valid workflow file 2`] = `
"# This GitHub Actions workflow was auto-generated by the \`rdme\` cli on 2022-01-01T00:00:00.000Z
# You can view our full documentation here: https://docs.readme.com/docs/rdme
name: ReadMe GitHub Action 🦉
Expand All @@ -488,7 +488,7 @@ jobs:
- name: Run \`docs\` command 🚀
uses: readmeio/rdme@v7
with:
rdme: docs ./docs/rdme.md --key=\${{ secrets.README_API_KEY }} --version=1.0.0
rdme: docs --key=\${{ secrets.README_API_KEY }} --version=1.0.0
"
`;

Expand Down
Loading