Skip to content

Commit df3c8a0

Browse files
ci: use bot for auth
1 parent 1d4b84b commit df3c8a0

2 files changed

Lines changed: 306 additions & 6 deletions

File tree

.github/CONTRIBUTING.md

Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
# Contributing to MOSuite
2+
3+
## Proposing changes with issues
4+
5+
If you want to make a change, it's a good idea to first
6+
[open an issue](https://code-review.tidyverse.org/issues/)
7+
and make sure someone from the team agrees that it’s needed.
8+
9+
If you've decided to work on an issue,
10+
[assign yourself to the issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/assigning-issues-and-pull-requests-to-other-github-users#assigning-an-individual-issue-or-pull-request)
11+
so others will know you're working on it.
12+
13+
## Pull request process
14+
15+
We use [GitHub Flow](https://docs.github.com/en/get-started/using-github/github-flow)
16+
as our collaboration process.
17+
Follow the steps below for detailed instructions on contributing changes to
18+
MOSuite.
19+
20+
![GitHub Flow diagram](https://raw.githubusercontent.com/CCBR/CCBR_NextflowTemplate/main/.github/img/GitHub-Flow_bg-white.png)
21+
22+
23+
### Clone the repo
24+
25+
If you are a member of [CCBR](https://github.com/CCBR),
26+
you can clone this repository to your computer or development environment.
27+
Otherwise, you will first need to
28+
[fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo)
29+
the repo and clone your fork. You only need to do this step once.
30+
31+
```sh
32+
git clone https://github.com/NIDAP-Community/MOSuite-CodeOcean
33+
```
34+
35+
> Cloning into 'MOSuite'... <br>
36+
> remote: Enumerating objects: 1136, done. <br>
37+
> remote: Counting objects: 100% (463/463), done. <br>
38+
> remote: Compressing objects: 100% (357/357), done. <br>
39+
> remote: Total 1136 (delta 149), reused 332 (delta 103), pack-reused 673 <br>
40+
> Receiving objects: 100% (1136/1136), 11.01 MiB | 9.76 MiB/s, done. <br>
41+
> Resolving deltas: 100% (530/530), done. <br>
42+
43+
```sh
44+
cd MOSuite
45+
```
46+
47+
### If this is your first time cloning the repo, install dependencies
48+
49+
- In an R console, install the R development dependencies with
50+
`devtools::install_dev_deps()`, and then make sure the package passes R CMD
51+
check by running `devtools::check()`. If R CMD check doesn't pass cleanly,
52+
it's a good idea to ask for help before continuing.
53+
54+
- Install [`pre-commit`](https://pre-commit.com/#install) if you don't already
55+
have it. Then from the repo's root directory, run
56+
57+
```sh
58+
pre-commit install
59+
```
60+
61+
This will install the repo's pre-commit hooks.
62+
You'll only need to do this step the first time you clone the repo.
63+
64+
### Create a branch
65+
66+
Create a Git branch for your pull request (PR). Give the branch a descriptive
67+
name for the changes you will make, such as `iss-10` if it is for a specific
68+
issue.
69+
70+
```sh
71+
# create a new branch and switch to it
72+
git branch iss-10
73+
git switch iss-10
74+
```
75+
76+
> Switched to a new branch 'iss-10'
77+
78+
### Make your changes
79+
80+
Edit the code, write unit tests, and update the documentation as needed.
81+
82+
#### style
83+
84+
New code should follow the [tidyverse style guide](https://style.tidyverse.org).
85+
You can use the [styler](https://CRAN.R-project.org/package=styler) package to
86+
apply these styles, but please don't restyle code that has nothing to do with
87+
your PR.
88+
89+
A brief overview of conventions according to the tidyverse style guide:
90+
91+
- most object names (variables and functions) should be in [snake_case](https://style.tidyverse.org/syntax.html#sec-objectnames)
92+
- function names should use [verbs](https://style.tidyverse.org/functions.html#naming) where possible
93+
- use `<-` for assignment
94+
- use [pipes](https://style.tidyverse.org/pipes.html) to chain operations on a single object
95+
96+
Please see the [tidyverse style guide](https://style.tidyverse.org) for more details.
97+
98+
#### test
99+
100+
Most changes to the code will also need unit tests to demonstrate that the
101+
changes work as intended.
102+
Use [`testthat`](https://testthat.r-lib.org/) to create your unit tests and test
103+
the code.
104+
Test files are organized as described in
105+
<https://style.tidyverse.org/tests.html>.
106+
Take a look at the existing code in this package for examples.
107+
108+
#### document
109+
110+
If you have written a new function or changed the API of an existing function,
111+
you will need to update the function's documentation using
112+
[roxygen2](https://cran.r-project.org/package=roxygen2) with
113+
[Markdown syntax](https://roxygen2.r-lib.org/articles/rd-formatting.html).
114+
See instructions on writing roxygen2 comments here:
115+
<https://r-pkgs.org/man.html>.
116+
If the function is used in a vignette, you may also need to update the vignette.
117+
118+
#### check
119+
120+
After making your changes, run `devtools::check()` from an R console to make
121+
sure the package still passes R CMD check.
122+
123+
### Commit and push your changes
124+
125+
If you're not sure how often you should commit or what your commits should
126+
consist of, we recommend following the "atomic commits" principle where each
127+
commit contains one new feature, fix, or task.
128+
Learn more about atomic commits here:
129+
<https://www.freshconsulting.com/insights/blog/atomic-commits/>
130+
131+
First, add the files that you changed to the staging area:
132+
133+
```sh
134+
git add path/to/changed/files/
135+
```
136+
137+
Then make the commit.
138+
Your commit message should follow the
139+
[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)
140+
specification.
141+
Briefly, each commit should start with one of the approved types such as
142+
`feat`, `fix`, `docs`, etc. followed by a description of the commit.
143+
Take a look at the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/#summary)
144+
for more detailed information about how to write commit messages.
145+
146+
147+
```sh
148+
git commit -m 'feat: create function for awesome feature'
149+
```
150+
151+
pre-commit will enforce that your commit message and the code changes are
152+
styled correctly and will attempt to make corrections if needed.
153+
154+
> Check for added large files..............................................Passed <br>
155+
> Fix End of Files.........................................................Passed <br>
156+
> Trim Trailing Whitespace.................................................Failed <br>
157+
> - hook id: trailing-whitespace <br>
158+
> - exit code: 1 <br>
159+
> - files were modified by this hook <br>
160+
> <br>
161+
> Fixing path/to/changed/files/file.txt <br>
162+
> <br>
163+
> codespell................................................................Passed <br>
164+
> style-files..........................................(no files to check)Skipped <br>
165+
> readme-rmd-rendered..................................(no files to check)Skipped <br>
166+
> use-tidy-description.................................(no files to check)Skipped <br>
167+
168+
In the example above, one of the hooks modified a file in the proposed commit,
169+
so the pre-commit check failed. You can run `git diff` to see the changes that
170+
pre-commit made and `git status` to see which files were modified. To proceed
171+
with the commit, re-add the modified file(s) and re-run the commit command:
172+
173+
```sh
174+
git add path/to/changed/files/file.txt
175+
git commit -m 'feat: create function for awesome feature'
176+
```
177+
178+
This time, all the hooks either passed or were skipped
179+
(e.g. hooks that only run on R code will not run if no R files were
180+
committed).
181+
When the pre-commit check is successful, the usual commit success message
182+
will appear after the pre-commit messages showing that the commit was created.
183+
184+
> Check for added large files..............................................Passed <br>
185+
> Fix End of Files.........................................................Passed <br>
186+
> Trim Trailing Whitespace.................................................Passed <br>
187+
> codespell................................................................Passed <br>
188+
> style-files..........................................(no files to check)Skipped <br>
189+
> readme-rmd-rendered..................................(no files to check)Skipped <br>
190+
> use-tidy-description.................................(no files to check)Skipped <br>
191+
> Conventional Commit......................................................Passed <br>
192+
> [iss-10 9ff256e] feat: create function for awesome feature <br>
193+
> 1 file changed, 22 insertions(+), 3 deletions(-) <br>
194+
195+
Finally, push your changes to GitHub:
196+
197+
```sh
198+
git push
199+
```
200+
201+
If this is the first time you are pushing this branch, you may have to
202+
explicitly set the upstream branch:
203+
204+
```sh
205+
git push --set-upstream origin iss-10
206+
```
207+
208+
> Enumerating objects: 7, done. <br>
209+
> Counting objects: 100% (7/7), done. <br>
210+
> Delta compression using up to 10 threads <br>
211+
> Compressing objects: 100% (4/4), done. <br>
212+
> Writing objects: 100% (4/4), 648 bytes | 648.00 KiB/s, done. <br>
213+
> Total 4 (delta 3), reused 0 (delta 0), pack-reused 0 <br>
214+
> remote: Resolving deltas: 100% (3/3), completed with 3 local objects. <br>
215+
> remote: <br>
216+
> remote: Create a pull request for 'iss-10' on GitHub by visiting: <br>
217+
> remote: https://github.com/NIDAP-Community/MOSuite-CodeOcean/pull/new/iss-10 <br>
218+
> remote: <br>
219+
> To https://github.com/NIDAP-Community/MOSuite-CodeOcean <br>
220+
> <br>
221+
> [new branch] iss-10 -> iss-10 <br>
222+
> branch 'iss-10' set up to track 'origin/iss-10'. <br>
223+
224+
We recommend pushing your commits often so they will be backed up on GitHub.
225+
You can view the files in your branch on GitHub at
226+
`https://github.com/NIDAP-Community/MOSuite-CodeOcean/tree/<your-branch-name>`
227+
(replace `<your-branch-name>` with the actual name of your branch).
228+
229+
### Create the PR
230+
231+
Once your branch is ready, create a PR on GitHub:
232+
<https://github.com/NIDAP-Community/MOSuite-CodeOcean/pull/new/>
233+
234+
Select the branch you just pushed:
235+
236+
![Create a new PR from your branch](https://raw.githubusercontent.com/CCBR/CCBR_NextflowTemplate/main/.github/img/new-PR.png)
237+
238+
Edit the PR title and description.
239+
The title should briefly describe the change.
240+
Follow the comments in the template to fill out the body of the PR, and
241+
you can delete the comments (everything between `<!--` and `-->`) as you go.
242+
When you're ready, click 'Create pull request' to open it.
243+
244+
![Open the PR after editing the title and description](https://raw.githubusercontent.com/CCBR/CCBR_NextflowTemplate/main/.github/img/create-PR.png)
245+
246+
Optionally, you can mark the PR as a draft if you're not yet ready for it to
247+
be reviewed, then change it later when you're ready.
248+
249+
### Wait for a maintainer to review your PR
250+
251+
We will do our best to follow the tidyverse code review principles:
252+
<https://code-review.tidyverse.org/>.
253+
The reviewer may suggest that you make changes before accepting your PR in
254+
order to improve the code quality or style.
255+
If that's the case, continue to make changes in your branch and push them to
256+
GitHub, and they will appear in the PR.
257+
258+
Once the PR is approved, the maintainer will merge it and the issue(s) the PR
259+
links will close automatically.
260+
Congratulations and thank you for your contribution!
261+
262+
### After your PR has been merged
263+
264+
After your PR has been merged, update your local clone of the repo by
265+
switching to the main branch and pulling the latest changes:
266+
267+
```sh
268+
git checkout main
269+
git pull
270+
```
271+
272+
It's a good idea to run `git pull` before creating a new branch so it will
273+
start from the most recent commits in main.
274+
275+
## Helpful links for more information
276+
277+
- This contributing guide was adapted from the [tidyverse contributing guide](https://github.com/tidyverse/tidyverse/blob/main/.github/CONTRIBUTING.md)
278+
- [GitHub Flow](https://docs.github.com/en/get-started/using-github/github-flow)
279+
- [tidyverse style guide](https://style.tidyverse.org)
280+
- [tidyverse code review principles](https://code-review.tidyverse.org)
281+
- [reproducible examples](https://www.tidyverse.org/help/#reprex)
282+
- [R packages book](https://r-pkgs.org/)
283+
- packages:
284+
- [usethis](https://usethis.r-lib.org/)
285+
- [devtools](https://devtools.r-lib.org/)
286+
- [testthat](https://testthat.r-lib.org/)
287+
- [styler](https://styler.r-lib.org/)
288+
- [roxygen2](https://roxygen2.r-lib.org)
Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Add issues/PRs to the TechDev project
1+
name: TechDev-project
22

33
on:
44
issues:
@@ -8,19 +8,31 @@ on:
88
types:
99
- opened
1010

11-
permissions: read-all
11+
permissions:
12+
issues: write
13+
pull-requests: write
14+
contents: read
1215

1316
jobs:
1417
add-to-project:
1518
runs-on: ubuntu-latest
1619
steps:
17-
- name: add to TechDev project
18-
uses: actions/add-to-project@v1.0.2
20+
- name: Generate a token
21+
id: generate-token
22+
if: ${{ inputs.github-token == '' }}
23+
uses: actions/create-github-app-token@v2
24+
with:
25+
app-id: ${{ vars.CCBR_BOT_APP_ID }}
26+
private-key: ${{ secrets.CCBR_BOT_PRIVATE_KEY }}
27+
owner: CCBR
28+
29+
- uses: actions/add-to-project@v1.0.2
1930
with:
2031
project-url: https://github.com/orgs/CCBR/projects/17
21-
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
32+
github-token: ${{ steps.generate-token.outputs.token }}
33+
2234
- name: add to MOSuite project
2335
uses: actions/add-to-project@v1.0.2
2436
with:
2537
project-url: https://github.com/orgs/CCBR/projects/32
26-
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
38+
github-token: ${{ steps.generate-token.outputs.token }}

0 commit comments

Comments
 (0)