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

Feat: add support for checking if source folder exists #463

Merged
merged 4 commits into from
Oct 15, 2020
Merged

Feat: add support for checking if source folder exists #463

merged 4 commits into from
Oct 15, 2020

Conversation

exuanbo
Copy link
Contributor

@exuanbo exuanbo commented Oct 12, 2020

Resolves #310

Description

Provide a description of what your changes do.

Refactor function init to generate paths and check if required parameters are provided.

Remove some tests.

@exuanbo exuanbo requested a review from JamesIves as a code owner October 12, 2020 09:27
}

export const checkParameters = (action: ActionInterface): void => {
if (!hasRequiredParameters(action, ['accessToken', 'gitHubToken', 'ssh'])) {
Copy link
Owner

Choose a reason for hiding this comment

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

Big fan of this refactor!

Copy link
Owner

@JamesIves JamesIves left a comment

Choose a reason for hiding this comment

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

This looks good! I just have the one concern about moving the default assignments out of run.

Also I left a previous comment about types and stuff being optional, you can totally disregard it as I was thinking of something totally different.

src/constants.ts Outdated
@@ -40,6 +41,7 @@ export interface ActionInterface {
repositoryPath?: string
/** The root directory where your project lives. */
root: string
Copy link
Owner

@JamesIves JamesIves Oct 12, 2020

Choose a reason for hiding this comment

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

Is root used anymore? We default it in the action interface but it doesn't seem to be used for anything after the more recent changes. It's also not a required parameter when using it as a node module either: https://github.com/JamesIves/github-pages-deploy-action#install-as-a-node-module-

Copy link
Contributor Author

Choose a reason for hiding this comment

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

} --exclude .ssh --exclude .git --exclude .github ${
folderPath === rootPath
? `--exclude ${temporaryDeploymentDirectory}`
: ''
}`,

It seems that this is the only place root is used. Maybe it should be replaced by action.workplace.

Copy link
Owner

@JamesIves JamesIves Oct 12, 2020

Choose a reason for hiding this comment

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

I think that makes sense, especially if rootPath and action.workspace are generating the same path anyway.

} ${
!fs.existsSync(`${folderPath}/.nojekyll`)
!fs.existsSync(`${action.folderPath}/.nojekyll`)
Copy link
Owner

@JamesIves JamesIves Oct 12, 2020

Choose a reason for hiding this comment

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

Will action.folderPath be defined here? I see it's assigned in the init function but I'm not sure it will be here because it's not available on action as these are not assigned to the settings object in run.

#463 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

action.folderPath will be defined here.

const settings = {
  ...action,
  ...configuration
}


await init(settings)
status = await deploy(settings)

Object settings is passed by reference in function init and then passed to deploy().

@@ -30,10 +29,6 @@ export default async function run(
...configuration
}

// Defines the repository paths and token types.
settings.repositoryPath = generateRepositoryPath(settings)
settings.tokenType = generateTokenType(settings)
Copy link
Owner

Choose a reason for hiding this comment

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

Is there a purpose for moving these over to the git init function instead of leaving it here? run is the initiator so I think they make more sense here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I get your point. So this way I'm not sure where checkParameters should be.

Copy link
Owner

Choose a reason for hiding this comment

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

I think here would make sense right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I need to refactor some tests too.

Refactor: rm `action.root`, `action.rootPath`

Refactor: `generateFolderPath`, `hasRequiredParameters`

Test: rm some tests for `init`, add tests for `checkParameters`
@codecov-io
Copy link

Codecov Report

Merging #463 into dev will decrease coverage by 3.51%.
The diff coverage is 95.23%.

Impacted file tree graph

@@             Coverage Diff             @@
##               dev     #463      +/-   ##
===========================================
- Coverage   100.00%   96.48%   -3.52%     
===========================================
  Files            5        5              
  Lines          201      199       -2     
  Branches        52       49       -3     
===========================================
- Hits           201      192       -9     
- Misses           0        6       +6     
- Partials         0        1       +1     
Impacted Files Coverage Δ
src/git.ts 93.75% <66.66%> (-6.25%) ⬇️
src/lib.ts 100.00% <100.00%> (ø)
src/util.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fbc5cb9...023d591. Read the comment docs.

@exuanbo
Copy link
Contributor Author

exuanbo commented Oct 14, 2020

I am thinking of a way to fix the code coverage.

@exuanbo exuanbo requested a review from JamesIves October 14, 2020 11:11
Copy link
Owner

@JamesIves JamesIves left a comment

Choose a reason for hiding this comment

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

PR looks good! I think creating a new test and mocking the execute function and having it return an error in an error would probably be what I'd do: https://stackoverflow.com/a/50656680/4933483

I'm happy to fix the test coverage if you'd like to call this done! Let me know.

@JamesIves JamesIves added the hacktoberfest-accepted Approved pull requests related to Hacktoberfest. label Oct 14, 2020
@exuanbo
Copy link
Contributor Author

exuanbo commented Oct 14, 2020

PR looks good! I think creating a new test and mocking the execute function and having it return an error in an error would probably be what I'd do: stackoverflow.com/a/50656680/4933483

I'm happy to fix the test coverage if you'd like to call this done! Let me know.

Ok I think I've done my part 🙂

@JamesIves
Copy link
Owner

Awesome, thank you again! I'll try and get this out this evening once I'm done with my testing.

@JamesIves JamesIves merged commit dc667b3 into JamesIves:dev Oct 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted Approved pull requests related to Hacktoberfest.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check if source folder exists and exit with helpful error message
3 participants