Skip to content

Commit e962b19

Browse files
authored
Merge pull request nf-core#1804 from mashehu/prevent-file-deletion
2 parents c645fe2 + 0f5c125 commit e962b19

8 files changed

Lines changed: 147 additions & 20 deletions

File tree

.github/renovate.json5

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
$schema: "https://docs.renovatebot.com/renovate-schema.json",
3+
extends: ["github>nf-core/ops//.github/renovate/default.json5"],
4+
baseBranchPatterns: ["master"],
5+
}

.github/workflows/fix-linting.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Fix linting from a comment
2+
on:
3+
issue_comment:
4+
types: [created]
5+
6+
jobs:
7+
fix-linting:
8+
# Only run if comment is on a PR with the main repo, and if it contains the magic keywords
9+
if: >
10+
contains(github.event.comment.html_url, '/pull/') &&
11+
contains(github.event.comment.body, '@nf-core-bot fix linting') &&
12+
github.repository == 'nf-core/test-datasets'
13+
runs-on: ubuntu-latest
14+
steps:
15+
# Use the @nf-core-bot token to check out so we can push later
16+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6
17+
with:
18+
token: ${{ secrets.nf_core_bot_auth_token }}
19+
20+
# indication that the linting is being fixed
21+
- name: React on comment
22+
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5
23+
with:
24+
comment-id: ${{ github.event.comment.id }}
25+
reactions: eyes
26+
27+
# Action runs on the issue comment, so we don't get the PR by default
28+
# Use the gh cli to check out the PR
29+
- name: Checkout Pull Request
30+
run: gh pr checkout ${{ github.event.issue.number }}
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.nf_core_bot_auth_token }}
33+
34+
# Install and run prek
35+
- name: Run prek
36+
id: prek
37+
uses: j178/prek-action@91fd7d7cf70ae1dee9f4f44e7dfa5d1073fe6623 # v1
38+
continue-on-error: true
39+
40+
# indication that the linting has finished
41+
- name: react if linting finished succesfully
42+
if: steps.prek.outcome == 'success'
43+
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5
44+
with:
45+
comment-id: ${{ github.event.comment.id }}
46+
reactions: "+1"
47+
48+
- name: Commit & push changes
49+
id: commit-and-push
50+
if: steps.prek.outcome == 'failure'
51+
run: |
52+
git config user.email "core@nf-co.re"
53+
git config user.name "nf-core-bot"
54+
git config push.default upstream
55+
git add .
56+
git status
57+
git commit -m "[automated] Fix code linting"
58+
git push
59+
60+
- name: react if linting errors were fixed
61+
id: react-if-fixed
62+
if: steps.commit-and-push.outcome == 'success'
63+
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5
64+
with:
65+
comment-id: ${{ github.event.comment.id }}
66+
reactions: hooray
67+
68+
- name: react if linting errors were not fixed
69+
if: steps.commit-and-push.outcome == 'failure'
70+
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5
71+
with:
72+
comment-id: ${{ github.event.comment.id }}
73+
reactions: confused
74+
75+
- name: react if linting errors were not fixed
76+
if: steps.commit-and-push.outcome == 'failure'
77+
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5
78+
with:
79+
issue-number: ${{ github.event.issue.number }}
80+
body: |
81+
@${{ github.actor }} I tried to fix the linting errors, but it didn't work. Please fix them manually.
82+
See [CI log](https://github.com/nf-core/test-datasets/actions/runs/${{ github.run_id }}) for more details.

.github/workflows/lint-code.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Lint tools code formatting
2+
on:
3+
pull_request:
4+
5+
# Cancel if a newer run is started
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
pre-commit:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6
16+
17+
- name: Run prek
18+
uses: j178/prek-action@91fd7d7cf70ae1dee9f4f44e7dfa5d1073fe6623 # v1

.pre-commit-config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/mirrors-prettier
3+
rev: "v3.1.0"
4+
hooks:
5+
- id: prettier
6+
additional_dependencies:
7+
- prettier@3.7.1
8+
- repo: https://github.com/pre-commit/pre-commit-hooks
9+
rev: v6.0.0
10+
hooks:
11+
- id: trailing-whitespace
12+
args:
13+
- --markdown-linebreak-ext=md
14+
- id: end-of-file-fixer
15+
- repo: local
16+
hooks:
17+
- id: prevent-file-deletion
18+
name: Prevent file deletions
19+
language: system
20+
entry: bash -c 'git diff --cached --name-only --diff-filter=D | grep -q . && echo "❌ File deletions are not allowed. Ask on slack for exceptions" && exit 1 || exit 0'
21+
pass_filenames: false

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# ![nfcore/test-datasets](docs/images/test-datasets_logo.png)
2+
23
Test data to be used for automated testing with the nf-core pipelines
34

45
> ⚠️ **Do not merge your test data to `master`! Each pipeline has a dedicated branch (and a special one for modules)**
@@ -13,8 +14,8 @@ The principle for nf-core test data is as small as possible, as large as necessa
1314

1415
nf-core/test-datasets comes with documentation in the `docs/` directory:
1516

16-
01. [Add a new test dataset](https://github.com/nf-core/test-datasets/blob/master/docs/ADD_NEW_DATA.md)
17-
02. [Use an existing test dataset](https://github.com/nf-core/test-datasets/blob/master/docs/USE_EXISTING_DATA.md)
17+
1. [Add a new test dataset](https://github.com/nf-core/test-datasets/blob/master/docs/ADD_NEW_DATA.md)
18+
2. [Use an existing test dataset](https://github.com/nf-core/test-datasets/blob/master/docs/USE_EXISTING_DATA.md)
1819

1920
## Downloading test data
2021

docs/ADD_NEW_DATA.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
Please fill in the appropriate checklist below (delete whatever is not relevant). These are the most common things requested when adding a new test dataset.
44

5-
- [ ] Check [here](https://github.com/nf-core/test-datasets/branches/all) that there isn't already a branch containing data that could be used
6-
- If this is the case, follow the [documentation on how to use an existing test dataset](https://github.com/nf-core/test-datasets/blob/master/docs/USE_EXISTING_DATA.md)
7-
- [ ] Fork the [nf-core/test-datasets repository](https://github.com/nf-core/test-datasets) to your GitHub account
8-
- [ ] Create a new branch on your fork
9-
- [ ] Check your proposed test data follows the [guidelines](https://nf-co.re/docs/contributing/test_data_guidelines)
10-
- [ ] Add your test dataset
11-
- [ ] If you clone it locally use `git clone <url> --branch <branch> --single-branch`
12-
- [ ] Make a PR on a new branch with a relevant name
13-
- [ ] Wait for the PR to be merged
14-
- [ ] Use this newly created branch for your tests
5+
- [ ] Check [here](https://github.com/nf-core/test-datasets/branches/all) that there isn't already a branch containing data that could be used
6+
- If this is the case, follow the [documentation on how to use an existing test dataset](https://github.com/nf-core/test-datasets/blob/master/docs/USE_EXISTING_DATA.md)
7+
- [ ] Fork the [nf-core/test-datasets repository](https://github.com/nf-core/test-datasets) to your GitHub account
8+
- [ ] Create a new branch on your fork
9+
- [ ] Check your proposed test data follows the [guidelines](https://nf-co.re/docs/contributing/test_data_guidelines)
10+
- [ ] Add your test dataset
11+
- [ ] If you clone it locally use `git clone <url> --branch <branch> --single-branch`
12+
- [ ] Make a PR on a new branch with a relevant name
13+
- [ ] Wait for the PR to be merged
14+
- [ ] Use this newly created branch for your tests

docs/USE_EXISTING_DATA.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
Please fill in the appropriate checklist below (delete whatever is not relevant). These are the most common things requested when adding a new test dataset.
44

5-
- [ ] Check [here](https://github.com/nf-core/test-datasets/branches/all) to find the branch corresponding to the test dataset you want to use (i.e., `modules`, or a given pipeline)
6-
- [ ] Alternatively use nf-core tools to search and explore, e.g. `nf-core test-datasets list` (press tab for options), and then `nf-core test-datasets search -b modules fasta` (press tab for options)
7-
- [ ] You can also use the flag `--generate-nf-path` to generate config ready strings
8-
- [ ] Specify in the `conf/test.config` the path to the files from the test dataset
9-
- [ ] Set up your CI tests following the nf-core best practices
10-
- [ ] For pipelines: [tests/default.nf.test](https://github.com/nf-core/tools/blob/main/nf_core/pipeline-template/tests/default.nf.test))
11-
- [ ] For modules: [tests/main.nf.test](https://github.com/nf-core/tools/blob/main/nf_core/module-template/tests/main.nf.test.j2)
5+
- [ ] Check [here](https://github.com/nf-core/test-datasets/branches/all) to find the branch corresponding to the test dataset you want to use (i.e., `modules`, or a given pipeline)
6+
- [ ] Alternatively use nf-core tools to search and explore, e.g. `nf-core test-datasets list` (press tab for options), and then `nf-core test-datasets search -b modules fasta` (press tab for options)
7+
- [ ] You can also use the flag `--generate-nf-path` to generate config ready strings
8+
- [ ] Specify in the `conf/test.config` the path to the files from the test dataset
9+
- [ ] Set up your CI tests following the nf-core best practices
10+
- [ ] For pipelines: [tests/default.nf.test](https://github.com/nf-core/tools/blob/main/nf_core/pipeline-template/tests/default.nf.test))
11+
- [ ] For modules: [tests/main.nf.test](https://github.com/nf-core/tools/blob/main/nf_core/module-template/tests/main.nf.test.j2)

docs/images/test-datasets_logo.svg

Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)