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

Make it a full action #2

Merged
merged 9 commits into from
Mar 7, 2024
Merged

Conversation

jashapiro
Copy link
Member

Here I am adding action.yaml to make this a fully operational github action. I also modified the script to output counts directly to the GITHUB_OUTPUT environment variable.

There is also a test action to demonstrate usage.

Still TBD: fixing the intentional spelling error and using a docker image from the registry in the action (rather than the Dockerfile) to prevent rebuilding every time the action runs.

@jashapiro jashapiro requested a review from sjspielman March 7, 2024 15:18
Copy link
Member

@sjspielman sjspielman left a comment

Choose a reason for hiding this comment

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

what do you think about optparse?

I was also thinking about whether we want a second script for checking jupyter notebooks. I had thought pyspelling might be an option for us, but I was tricked into thinking it would be able to check jupyter notebooks just because it's written in python :/ . Looks like someone tried to make it happen once, but this doesn't seem like something we also want to make happen. This remains the only real tool I can find, and it's interactive:https://github.com/jupyterlab-contrib/spellchecker . So, I don't really have anything to suggest to automate spell checking there, meaning what we've got is what we've got!

@@ -3,3 +3,4 @@
This repository contains a Docker image with the [R `spelling` package](https://cran.r-project.org/web/packages/spelling/index.html) installed.
The role of this repository is to facilitate spell checking actions across `AlexsLemonade` repositories.

speeling
Copy link
Member

Choose a reason for hiding this comment

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

I think the important question here is whether we want to just have this here, or integrate it more sneakily. Like,

The role of this repository is to facilitate speell checking actions across AlexsLemonade repositories.

Either way, it must stay in some capacity.

image: 'Dockerfile'
args:
- ${{ inputs.dictionary }}
- ${{ inputs.files }}
Copy link
Member

Choose a reason for hiding this comment

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

:sad:

Comment on lines +10 to +13
# dictionary is required first argument
dict_file <- arguments[1]

arguments <- arguments[-1]
Copy link
Member

Choose a reason for hiding this comment

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

I kind of wonder if we want to just do optparse here. It'll add another dependency but maybe it's worth it to be more explicit, especially if we also want to allow for another argument with a different pattern besides Rmd/rmd/md

Copy link
Member Author

Choose a reason for hiding this comment

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

We could, but I think for the first version this probably makes the most sense.

spell-check.R Outdated
# Save spell errors to file
readr::write_tsv(spelling_errors, "spell_check_errors.tsv")
# Save spelling errors to file
write.table(spelling_errors, "spell_check_errors.tsv", sep = "\t", quote = FALSE, row.names = FALSE)
Copy link
Member

Choose a reason for hiding this comment

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

no readr 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

I mean, we could install readr too. I'm not actually opposed to that, given the ugly state of affairs there.

Copy link
Member

Choose a reason for hiding this comment

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

I don't have much preference either way, so up to you

Comment on lines +38 to +39
# Save error count to GITHUB_OUTPUT
system(paste0("echo 'error_count=", nrow(spelling_errors), "'>> $GITHUB_OUTPUT"))
Copy link
Member

Choose a reason for hiding this comment

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

ah! yes

@jashapiro
Copy link
Member Author

I was also thinking about whether we want a second script for checking jupyter notebooks.

File an issue for it! One idea I had was to export the notebook as markdown using nbconvert and then spell check that? It will be a bit harder to go through the output for fixes as line numbers will be wrong, but should still be doable.

Comment on lines +12 to +13
- name: Spell check action
uses: ./ # Uses an action in the root directory
Copy link
Member

Choose a reason for hiding this comment

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

You have this as a TBD in your opening PR comment, but I don't think it's TBD here - it's TBD for porting this action into other repos

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know what you mean. It is a change that needs to be made in action.yaml, but can't be made until we have at least one build pushed. It can happen in this PR or a later one. (There is an interesting cyclical dependency, which would be removed be deleting the test action and replacing it with example implementation in the readme)

Copy link
Member

Choose a reason for hiding this comment

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

Right - I am just noting that the TBD phrasing you have in your opening comment is relevant to next steps, but not to merging this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Either way. I could implement it all here, or in a next PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd probably rather have this all merged in so we can test with a built image.

Copy link
Member

Choose a reason for hiding this comment

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

I'd probably rather have this all merged in so we can test with a built image.

So, implement it all here? that's fine with me

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, I meant merge in the current state. That will trigger a build and push of the image, so we can then test with a pulled image in the next update.

Copy link
Member Author

Choose a reason for hiding this comment

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

It needs to be this version of the Docker image/script, with the changes to inputs and outputs.

@sjspielman sjspielman self-requested a review March 7, 2024 20:35
Copy link
Member

@sjspielman sjspielman left a comment

Choose a reason for hiding this comment

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

go for it, next steps in my branch

@jashapiro jashapiro merged commit 8a68700 into sjspielman/setup-repo Mar 7, 2024
1 check passed
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