From 7c537af904bdbf90dc28935f9d1308a9b31b0315 Mon Sep 17 00:00:00 2001 From: Joshua Shapiro Date: Thu, 7 Mar 2024 17:07:27 -0500 Subject: [PATCH 1/8] Test action with ghcr image --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 949b75b..1e359ff 100644 --- a/action.yaml +++ b/action.yaml @@ -14,7 +14,7 @@ outputs: description: The number of spelling errors runs: using: 'docker' - image: 'Dockerfile' + image: ghcr.io/alexslemonade/spelling:edge args: - ${{ inputs.dictionary }} - ${{ inputs.files }} From a92dc81d207c02d6be44dc36d4889fa1eac4fdaa Mon Sep 17 00:00:00 2001 From: Joshua Shapiro Date: Thu, 7 Mar 2024 17:13:01 -0500 Subject: [PATCH 2/8] get the name right --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 1e359ff..98316e3 100644 --- a/action.yaml +++ b/action.yaml @@ -14,7 +14,7 @@ outputs: description: The number of spelling errors runs: using: 'docker' - image: ghcr.io/alexslemonade/spelling:edge + image: ghcr.io/alexslemonade/spellcheck:edge args: - ${{ inputs.dictionary }} - ${{ inputs.files }} From ca4220a3f92e04e791c8731320c9f9683882d5e5 Mon Sep 17 00:00:00 2001 From: Joshua Shapiro Date: Thu, 7 Mar 2024 17:34:40 -0500 Subject: [PATCH 3/8] Update readme with usage --- README.md | 51 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index af1d0be..4a89d82 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,51 @@ # spellcheck -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. +This repository contains a GitHub action to run the [R `spelling` package](https://cran.r-project.org/web/packages/spelling/index.html). +The role of this action is to facilitate spell checking actions across `AlexsLemonade` repositories. -speeling +Currently the action will only spell check text in Rmd and md files + +## Usage + +To use this action, create a `.github/workflows/spellcheck.yml` file in your repository with the following contents (modified to fit your exact needs): + +```yaml +name: Check Spelling +on: + pull_request: + branches: + - main + +jobs: + spell-check: + runs-on: ubuntu-latest + name: Spell check files + steps: + + - name: Checkout + uses: actions/checkout@v4 + + - name: Spell check action + uses: alexslemonade/spellcheck + id: spell + with: + dictionary: components/dictionary.txt + + - name: Upload spell check errors + uses: actions/upload-artifact@v2 + with: + name: spell_check_errors + path: spell_check_errors.tsv + + - name: Fail if there are spelling errors + if: steps.spell.outputs.error_count > 0 + run: | + echo "There were ${{ steps.spell.outputs.error_count }} errors" + exit 1 +``` + +Note that the `dictionary` input to the spell check step is optional and defaults to `components/dictionary.txt`. +If you want to use a different dictionary, you can specify the path to the dictionary file in your repository. + +You can also specify specific files to spell check using the `files` input to the `alexslemonade/spellcheck` step. +Globs should work as expected. From ad53979aa711dda56988c294e85b938b523ed5eb Mon Sep 17 00:00:00 2001 From: Joshua Shapiro Date: Fri, 8 Mar 2024 09:51:04 -0500 Subject: [PATCH 4/8] Fix counting bug --- spell-check.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spell-check.R b/spell-check.R index ec13cc7..ca2fec5 100644 --- a/spell-check.R +++ b/spell-check.R @@ -12,7 +12,7 @@ dict_file <- arguments[1] arguments <- arguments[-1] # if there are arguments, check those files, otherwise check all markdown & rmd files -if (length(arguments) > 1) { +if (length(arguments) > 0) { files <- arguments[grepl(file_pattern, arguments)] } else { files <- list.files(pattern = file_pattern, recursive = TRUE, full.names = TRUE) From d6c7613fe04d6cfb5ac2e706a52d5c00c95a74e8 Mon Sep 17 00:00:00 2001 From: Joshua Shapiro Date: Fri, 8 Mar 2024 09:52:19 -0500 Subject: [PATCH 5/8] Update action to account for null/empty strings --- action.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/action.yaml b/action.yaml index 98316e3..2ccd85f 100644 --- a/action.yaml +++ b/action.yaml @@ -1,11 +1,11 @@ # action.yml -name: 'R spell check' -description: 'Spell check R, Rmd and md files' +name: "R spell check" +description: "Spell check R, Rmd and md files" inputs: - dictionary: # id of input - description: 'Dictionary file path' + dictionary: # id of input + description: "Dictionary file path" required: true - default: 'components/dictionary.txt' + default: "components/dictionary.txt" files: description: Glob of files to check required: false @@ -13,8 +13,8 @@ outputs: error_count: description: The number of spelling errors runs: - using: 'docker' + using: "docker" image: ghcr.io/alexslemonade/spellcheck:edge args: - - ${{ inputs.dictionary }} + - ${{ inputs.dictionary || 'components/dictionary.txt' }} - ${{ inputs.files }} From 4cd0d0b945f73d242252b4bf6a3ce95a65e31f5a Mon Sep 17 00:00:00 2001 From: Joshua Shapiro Date: Fri, 8 Mar 2024 09:54:45 -0500 Subject: [PATCH 6/8] Update suggested upload action --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4a89d82..18bca83 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ jobs: dictionary: components/dictionary.txt - name: Upload spell check errors - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: spell_check_errors path: spell_check_errors.tsv From 31d685487aab1912b49b49bd87b1a08d57a204de Mon Sep 17 00:00:00 2001 From: Joshua Shapiro Date: Fri, 8 Mar 2024 10:01:55 -0500 Subject: [PATCH 7/8] Add release push of docker image --- .github/workflows/build-docker.yaml | 2 ++ .github/workflows/test.yaml | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index 336418a..79f36cb 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -4,6 +4,8 @@ on: push: branches: - main + tags: + - "v*" pull_request: branches: - main diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index d21b35c..ad5d4e9 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,4 +1,5 @@ -on: [push] +on: + - workflow_dispatch jobs: spell-check: @@ -10,7 +11,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Spell check action - uses: ./ # Uses an action in the root directory + uses: ./ # Uses the action in the root directory id: spell # Use the output from the `spell check` step - name: Get the number of errors From c500ca065d1a0ad5e16ba0d3381c0cd7777f3fdf Mon Sep 17 00:00:00 2001 From: Joshua Shapiro Date: Fri, 8 Mar 2024 10:05:41 -0500 Subject: [PATCH 8/8] Use /dev/null for no dict --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 2ccd85f..9133886 100644 --- a/action.yaml +++ b/action.yaml @@ -16,5 +16,5 @@ runs: using: "docker" image: ghcr.io/alexslemonade/spellcheck:edge args: - - ${{ inputs.dictionary || 'components/dictionary.txt' }} + - ${{ inputs.dictionary || '/dev/null' }} - ${{ inputs.files }}