Skip to content

Commit 219dc52

Browse files
authored
gh-49: Add linting rules from exercises repo (#54)
1 parent b990e91 commit 219dc52

48 files changed

Lines changed: 576 additions & 380 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/README.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ R console:
1010

1111
```r
1212
# Install/Update sandpaper
13-
options(repos = c(carpentries = "https://carpentries.r-universe.dev/",
13+
options(repos = c(carpentries = "https://carpentries.r-universe.dev/",
1414
CRAN = "https://cloud.r-project.org"))
1515
install.packages("sandpaper")
1616

@@ -34,21 +34,21 @@ This workflow does the following:
3434

3535
1. checks out the lesson
3636
2. provisions the following resources
37-
- R
38-
- pandoc
39-
- lesson infrastructure (stored in a cache)
40-
- lesson dependencies if needed (stored in a cache)
37+
- R
38+
- pandoc
39+
- lesson infrastructure (stored in a cache)
40+
- lesson dependencies if needed (stored in a cache)
4141
3. builds the lesson via `sandpaper:::ci_deploy()`
4242

4343
#### Caching
4444

45-
This workflow has two caches; one cache is for the lesson infrastructure and
46-
the other is for the the lesson dependencies if the lesson contains rendered
45+
This workflow has two caches; one cache is for the lesson infrastructure and
46+
the other is for the lesson dependencies if the lesson contains rendered
4747
content. These caches are invalidated by new versions of the infrastructure and
48-
the `renv.lock` file, respectively. If there is a problem with the cache,
48+
the `renv.lock` file, respectively. If there is a problem with the cache,
4949
manual invaliation is necessary. You will need maintain access to the repository
5050
and you can either go to the actions tab and [click on the caches button to find
51-
and invalidate the failing cache](https://github.blog/changelog/2022-10-20-manage-caches-in-your-actions-workflows-from-web-interface/)
51+
and invalidate the failing cache](https://github.blog/changelog/2022-10-20-manage-caches-in-your-actions-workflows-from-web-interface/)
5252
or by setting the `CACHE_VERSION` secret to the current date (which will
5353
invalidate all of the caches).
5454

@@ -58,32 +58,32 @@ invalidate all of the caches).
5858

5959
These workflows run on a schedule and at the maintainer's request. Because they
6060
create pull requests that update workflows/require the downstream actions to run,
61-
they need a special repository/organization secret token called
62-
`SANDPAPER_WORKFLOW` and it must have the `public_repo` and `workflow` scope.
61+
they need a special repository/organization secret token called
62+
`SANDPAPER_WORKFLOW` and it must have the `public_repo` and `workflow` scope.
6363

6464
This can be an individual user token, OR it can be a trusted bot account. If you
6565
have a repository in one of the official Carpentries accounts, then you do not
6666
need to worry about this token being present because the Carpentries Core Team
6767
will take care of supplying this token.
6868

69-
If you want to use your personal account: you can go to
69+
If you want to use your personal account: you can go to
7070
<https://github.com/settings/tokens/new?scopes=public_repo,workflow&description=Sandpaper%20Token>
7171
to create a token. Once you have created your token, you should copy it to your
7272
clipboard and then go to your repository's settings > secrets > actions and
7373
create or edit the `SANDPAPER_WORKFLOW` secret, pasting in the generated token.
7474

7575
If you do not specify your token correctly, the runs will not fail and they will
76-
give you instructions to provide the token for your repository.
76+
give you instructions to provide the token for your repository.
7777

7878
### 02 Maintain: Update Workflow Files (update-workflow.yaml)
7979

80-
The {sandpaper} repository was designed to do as much as possible to separate
81-
the tools from the content. For local builds, this is absolutely true, but
82-
there is a minor issue when it comes to workflow files: they must live inside
83-
the repository.
80+
The {sandpaper} repository was designed to do as much as possible to separate
81+
the tools from the content. For local builds, this is true, but
82+
there is a minor issue when it comes to workflow files: they must live inside
83+
the repository.
8484

8585
This workflow ensures that the workflow files are up-to-date. The way it work is
86-
to download the update-workflows.sh script from GitHub and run it. The script
86+
to download the update-workflows.sh script from GitHub and run it. The script
8787
will do the following:
8888

8989
1. check the recorded version of sandpaper against the current version on github
@@ -100,25 +100,25 @@ This update is run weekly or on demand.
100100

101101
For lessons that have generated content, we use {renv} to ensure that the output
102102
is stable. This is controlled by a single lockfile which documents the packages
103-
needed for the lesson and the version numbers. This workflow is skipped in
103+
needed for the lesson and the version numbers. This workflow is skipped in
104104
lessons that do not have generated content.
105105

106106
Because the lessons need to remain current with the package ecosystem, it's a
107-
good idea to make sure these packages can be updated periodically. The
107+
good idea to make sure these packages can be updated periodically. The
108108
update cache workflow will do this by checking for updates, applying them in a
109109
branch called `updates/packages` and creating a pull request with _only the
110-
lockfile changed_.
110+
lockfile changed_.
111111

112112
From here, the markdown documents will be rebuilt and you can inspect what has
113-
changed based on how the packages have updated.
113+
changed based on how the packages have updated.
114114

115115
## Pull Request and Review Management
116116

117-
Because our lessons execute code, pull requests are a secruity risk for any
118-
lesson and thus have security measures associted with them. **Do not merge any
117+
Because our lessons execute code, pull requests are a security risk for any
118+
lesson and thus have security measures associated with them. **Do not merge any
119119
pull requests that do not pass checks and do not have bots commented on them.**
120120

121-
This series of workflows all go together and are described in the following
121+
This series of workflows all go together and are described in the following
122122
diagram and the below sections:
123123

124124
![Graph representation of a pull request](https://carpentries.github.io/sandpaper/articles/img/pr-flow.dot.svg)
@@ -129,22 +129,22 @@ This workflow runs every time a pull request is created and its purpose is to
129129
validate that the pull request is okay to run. This means the following things:
130130

131131
1. The pull request does not contain modified workflow files
132-
2. If the pull request contains modified workflow files, it does not contain
132+
2. If the pull request contains modified workflow files, it does not contain
133133
modified content files (such as a situation where @carpentries-bot will
134134
make an automated pull request)
135135
3. The pull request does not contain an invalid commit hash (e.g. from a fork
136136
that was made before a lesson was transitioned from styles to use the
137137
workbench).
138138

139-
Once the checks are finished, a comment is issued to the pull request, which
140-
will allow maintainers to determine if it is safe to run the
139+
Once the checks are finished, a comment is issued to the pull request, which
140+
will allow maintainers to determine if it is safe to run the
141141
"Receive Pull Request" workflow from new contributors.
142142

143143
### Receive Pull Request (pr-receive.yaml)
144144

145145
**Note of caution:** This workflow runs arbitrary code by anyone who creates a
146146
pull request. GitHub has safeguarded the token used in this workflow to have no
147-
priviledges in the repository, but we have taken precautions to protect against
147+
privileges in the repository, but we have taken precautions to protect against
148148
spoofing.
149149

150150
This workflow is triggered with every push to a pull request. If this workflow
@@ -154,8 +154,8 @@ started.
154154

155155
The first step of this workflow is to check if it is valid (e.g. that no
156156
workflow files have been modified). If there are workflow files that have been
157-
modified, a comment is made that indicates that the workflow is not run. If
158-
both a workflow file and lesson content is modified, an error will occurr.
157+
modified, a comment is made that indicates that the workflow is not run. If
158+
both a workflow file and lesson content is modified, an error will occur.
159159

160160
The second step (if valid) is to build the generated content from the pull
161161
request. This builds the content and uploads three artifacts:
@@ -164,7 +164,7 @@ request. This builds the content and uploads three artifacts:
164164
2. A summary of changes after the rendering process (diff)
165165
3. The rendered files (build)
166166

167-
Because this workflow builds generated content, it follows the same general
167+
Because this workflow builds generated content, it follows the same general
168168
process as the `sandpaper-main` workflow with the same caching mechanisms.
169169

170170
The artifacts produced are used by the next workflow.
@@ -183,9 +183,9 @@ The steps in this workflow are:
183183
Importantly: if the pull request is invalid, the branch is not created so any
184184
malicious code is not published.
185185

186-
From here, the maintainer can request changes from the author and eventually
187-
either merge or reject the PR. When this happens, if the PR was valid, the
188-
preview branch needs to be deleted.
186+
From here, the maintainer can request changes from the author and eventually
187+
either merge or reject the PR. When this happens, if the PR was valid, the
188+
preview branch needs to be deleted.
189189

190190
### Send Close PR Signal (pr-close-signal.yaml)
191191

@@ -194,5 +194,5 @@ pull request number for the next action
194194

195195
### Remove Pull Request Branch (pr-post-remove-branch.yaml)
196196

197-
Tiggered by `pr-close-signal.yaml`. This removes the temporary branch associated with
197+
Triggered by `pr-close-signal.yaml`. This removes the temporary branch associated with
198198
the pull request (if it was created).

.github/workflows/linting.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: Linting
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
types:
10+
- opened
11+
- ready_for_review
12+
- reopened
13+
- synchronize
14+
15+
concurrency:
16+
cancel-in-progress: true
17+
group: >-
18+
${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
19+
20+
jobs:
21+
linting:
22+
if: github.event.pull_request.draft == false
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
27+
28+
- name: Install pre-commit and fortitude
29+
run: python -m pip install -r requirements.txt
30+
31+
- name: Run pre-commit
32+
run: prek run --all-files --color always --verbose

.markdownlint.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"default": true,
3+
"MD013": { "line_length": 132 },
4+
"MD024": false, # Multiple headings with the same content
5+
"MD041": false, # First line in a file should be a top-level heading
6+
}

.pre-commit-config.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
repos:
3+
- repo: https://github.com/PlasmaFAIR/fortitude-pre-commit
4+
rev : v0.7.2
5+
hooks:
6+
- id: fortitude
7+
- repo: https://github.com/crate-ci/typos
8+
rev: v1.34.0
9+
hooks:
10+
- id: typos
11+
args:
12+
- --force-exclude
13+
- --hidden
14+
- repo: https://github.com/igorshubovych/markdownlint-cli
15+
rev: v0.45.0
16+
hooks:
17+
- id: markdownlint-fix
18+
args:
19+
- --dot
20+
- repo: https://github.com/pre-commit/pre-commit-hooks
21+
rev: v5.0.0
22+
hooks:
23+
- id: check-added-large-files
24+
args:
25+
- --enforce-all
26+
- --maxkb=1000
27+
exclude: \.dic$
28+
- id: check-case-conflict
29+
- id: check-executables-have-shebangs
30+
- id: check-merge-conflict
31+
- id: check-shebang-scripts-are-executable
32+
- id: destroyed-symlinks
33+
- id: end-of-file-fixer
34+
- id: mixed-line-ending
35+
args:
36+
- --fix=lf
37+
- id: trailing-whitespace
38+
- repo: https://github.com/errata-ai/vale
39+
rev: v3.13.0
40+
hooks:
41+
- id: vale
42+
name: vale sync
43+
pass_filenames: false
44+
args: [sync]
45+
- id: vale
46+
args: [--config=./.vale.ini]

.typos.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[default]
2+
extend-ignore-re = [
3+
# Custom ignore regex patterns:
4+
# https://github.com/crate-ci/typos/blob/master/docs/reference.md#example-configurations
5+
".*(?:#|--|//|/*).*(?:typos):\\s?ignore[^\\n]*\\n",
6+
".*(?:typos):\\s?ignore-next-line[^\\n]*\\n[^\\n]*",
7+
]

.vale.ini

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
StylesPath = .github/styles
2+
3+
# https://github.com/errata-ai/packages
4+
Packages = proselint,\
5+
RedHat,\
6+
write-good
7+
8+
[formats]
9+
qmd = md
10+
11+
[*.{md,qmd}]
12+
BasedOnStyles = proselint,\
13+
RedHat,\
14+
Vale,\
15+
write-good
16+
17+
# Disable
18+
RedHat.Definitions = NO
19+
RedHat.Ellipses = NO
20+
RedHat.GitLinks = NO
21+
RedHat.Headings = NO
22+
RedHat.PascalCamelCase = NO
23+
RedHat.PassiveVoice = NO
24+
RedHat.ReadabilityGrade = NO
25+
RedHat.Slash = NO
26+
RedHat.Spelling = NO
27+
RedHat.TermsErrors = NO
28+
Vale.Spelling = NO
29+
write-good.E-Prime = NO
30+
write-good.Passive = NO
31+
write-good.TooWordy = NO
32+
write-good.ThereIs = NO
33+
34+
# `vale sync` in CI means the packages are then linted, so turn them off
35+
[.github/styles/**]
36+
BasedOnStyles =

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This template CITATION.cff file was generated with cffinit.
22
# Visit https://bit.ly/cffinit to replace its contents
33
# with information about your lesson.
4-
# Remember to update this file periodically,
4+
# Remember to update this file periodically,
55
# ensuring that the author list and other fields remain accurate.
66

77
cff-version: 1.2.0

CODE_OF_CONDUCT.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ we pledge to follow the [The Carpentries Code of Conduct][coc].
88
Instances of abusive, harassing, or otherwise unacceptable behavior
99
may be reported by following our [reporting guidelines][coc-reporting].
1010

11-
1211
[coc-reporting]: https://docs.carpentries.org/topic_folders/policies/incident-reporting.html
1312
[coc]: https://docs.carpentries.org/topic_folders/policies/code-of-conduct.html

CONTRIBUTING.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ documentation][template-doc].
4343
2. If you wish to change the template used for workshop websites, please refer
4444
to [The Workbench documentation][template-doc].
4545

46-
4746
### What to Contribute
4847

4948
There are many ways to contribute, from writing new exercises and improving
@@ -107,17 +106,14 @@ email][contact].
107106
[contact]: mailto:team@carpentries.org
108107
[cp-site]: https://carpentries.org/
109108
[dc-issues]: https://github.com/issues?q=user%3Adatacarpentry
110-
[dc-lessons]: https://datacarpentry.org/lessons/
111109
[dc-site]: https://datacarpentry.org/
112-
[discuss-list]: https://carpentries.topicbox.com/groups/discuss
113110
[github]: https://github.com
114111
[github-flow]: https://guides.github.com/introduction/flow/
115112
[github-join]: https://github.com/join
116113
[how-contribute]: https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github
117114
[issues]: https://carpentries.org/help-wanted-issues/
118115
[lc-issues]: https://github.com/issues?q=user%3ALibraryCarpentry
119116
[swc-issues]: https://github.com/issues?q=user%3Aswcarpentry
120-
[swc-lessons]: https://software-carpentry.org/lessons/
121117
[swc-site]: https://software-carpentry.org/
122118
[lc-site]: https://librarycarpentry.org/
123119
[template-doc]: https://carpentries.github.io/workbench/

LICENSE.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ terms.
2323
Under the following terms:
2424

2525
- **Attribution**---You must give appropriate credit (mentioning that your work
26-
is derived from work that is Copyright (c) The Carpentries and, where
26+
is derived from work that is Copyright © The Carpentries and, where
2727
practical, linking to <https://carpentries.org/>), provide a [link to the
2828
license][cc-by-human], and indicate if changes were made. You may do so in
2929
any reasonable manner, but not in any way that suggests the licensor endorses
3030
you or your use.
3131

3232
- **No additional restrictions**---You may not apply legal terms or
3333
technological measures that legally restrict others from doing anything the
34-
license permits. With the understanding that:
34+
license permits. With the understanding that:
3535

3636
Notices:
3737

38-
* You do not have to comply with the license for elements of the material in
38+
- You do not have to comply with the license for elements of the material in
3939
the public domain or where your use is permitted by an applicable exception
4040
or limitation.
41-
* No warranties are given. The license may not give you all of the permissions
41+
- No warranties are given. The license may not give you all of the permissions
4242
necessary for your intended use. For example, other rights such as publicity,
4343
privacy, or moral rights may limit how you use the material.
4444

@@ -74,6 +74,5 @@ Carpentry" and their respective logos are registered trademarks of [The Carpentr
7474
[cc-by-human]: https://creativecommons.org/licenses/by/4.0/
7575
[cc-by-legal]: https://creativecommons.org/licenses/by/4.0/legalcode
7676
[mit-license]: https://opensource.org/licenses/mit-license.html
77-
[ci]: https://communityin.org/
7877
[osi]: https://opensource.org
7978
[the-carpentries]: https://carpentries.org

0 commit comments

Comments
 (0)