Skip to content

Commit f68c663

Browse files
authored
Merge pull request #417 from per1234/task
Migrate project infrastructure to Task
2 parents 5673b0c + 90d503f commit f68c663

23 files changed

+5226
-465
lines changed

Diff for: .github/CONTRIBUTING.md

+50-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,25 @@ The **Node.js** version in use is defined in the `engines.node` field of [`packa
1313

1414
[nvm](https://github.com/nvm-sh/nvm) is recommended to easily switch between Node.js versions.
1515

16+
#### Python
17+
18+
**Python**-based tools are used for some project development operations.
19+
20+
The **Python** version in use is defined in the `tool.poetry.dependencies` field of [`pyproject.toml`](../pyproject.toml).
21+
22+
#### Task
23+
24+
The [**Task**](https://taskfile.dev) task runner tool is used for all common development and validation operations.
25+
26+
Follow the installation instructions here:<br />
27+
https://taskfile.dev/installation/
28+
1629
### 2. Install dependencies
1730

1831
To work on the codebase you have to install all the dependencies:
1932

2033
```
21-
npm install
34+
task npm:install-deps
2235
```
2336

2437
### 3. Coding
@@ -32,26 +45,25 @@ Make sure to write or update tests for your work when appropriate.
3245
Format the code to follow the standard style for the project:
3346

3447
```
35-
npm run format
48+
task general:format-prettier
3649
```
3750

3851
### 5. Run tests
3952

4053
To run tests set the environment variable `GITHUB_TOKEN` with a valid Personal Access Token and then:
4154

4255
```
43-
npm run test
56+
task js:test
4457
```
4558

4659
See the [official Github documentation][pat-docs] to learn more about Personal Access Tokens.
4760

4861
### 6. Build
4962

50-
It is necessary to compile the code before it can be used by GitHub Actions. Remember to run these commands before committing any code changes:
63+
It is necessary to compile the code before it can be used by GitHub Actions. Remember to run this commands before committing any code changes:
5164

5265
```
53-
npm run build
54-
npm run pack
66+
task build
5567
```
5668

5769
### 7. Commit
@@ -60,6 +72,38 @@ Everything is now ready to make your contribution to the project, so commit it t
6072

6173
Thanks!
6274

75+
## Common Development Operations
76+
77+
### Running Checks
78+
79+
Checks and tests are set up to ensure the project content is functional and compliant with the established standards.
80+
81+
You can run the full suite of checks by running the following command from a terminal in a path under the repository:
82+
83+
```text
84+
task check
85+
```
86+
87+
### Automatic Corrections
88+
89+
Tools are provided to automatically bring the project into compliance with some of the required checks.
90+
91+
You can make these automatic fixes by running the following command from a terminal in a path under the repository:
92+
93+
```text
94+
task fix
95+
```
96+
97+
### Other Operations
98+
99+
Individual tasks are provided for each specific common validation and automated correction operation. The convenience `check` and `fix` tasks run all of the relevant individual tasks, so it is not necessary for the contributor to use the individual tasks. However, in some cases it may be more efficient to run the single specific task of interest.
100+
101+
You can learn the names of all the available tasks by running the following command from a terminal in a path under the repository:
102+
103+
```text
104+
task --list
105+
```
106+
63107
## Release workflow
64108

65109
Instructions for releasing a new version of the action:

Diff for: .github/workflows/check-npm-task.yml

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-npm-task.md
2+
name: Check npm
3+
4+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
5+
on:
6+
create:
7+
push:
8+
paths:
9+
- ".github/workflows/check-npm-task.ya?ml"
10+
- "**/.npmrc"
11+
- "**/package.json"
12+
- "**/package-lock.json"
13+
- "Taskfile.ya?ml"
14+
pull_request:
15+
paths:
16+
- ".github/workflows/check-npm-task.ya?ml"
17+
- "**/.npmrc"
18+
- "**/package.json"
19+
- "**/package-lock.json"
20+
- "Taskfile.ya?ml"
21+
schedule:
22+
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
23+
- cron: "0 8 * * TUE"
24+
workflow_dispatch:
25+
repository_dispatch:
26+
27+
jobs:
28+
run-determination:
29+
runs-on: ubuntu-latest
30+
permissions: {}
31+
outputs:
32+
result: ${{ steps.determination.outputs.result }}
33+
steps:
34+
- name: Determine if the rest of the workflow should run
35+
id: determination
36+
run: |
37+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
38+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
39+
if [[
40+
"${{ github.event_name }}" != "create" ||
41+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
42+
]]; then
43+
# Run the other jobs.
44+
RESULT="true"
45+
else
46+
# There is no need to run the other jobs.
47+
RESULT="false"
48+
fi
49+
50+
echo "result=$RESULT" >> $GITHUB_OUTPUT
51+
52+
validate:
53+
name: validate (${{ matrix.project.path }})
54+
needs: run-determination
55+
if: needs.run-determination.outputs.result == 'true'
56+
runs-on: ubuntu-latest
57+
permissions:
58+
contents: read
59+
60+
strategy:
61+
fail-fast: false
62+
matrix:
63+
project:
64+
- path: .
65+
66+
steps:
67+
- name: Checkout repository
68+
uses: actions/checkout@v4
69+
70+
- name: Setup Node.js
71+
uses: actions/setup-node@v4
72+
with:
73+
node-version-file: package.json
74+
75+
- name: Install Task
76+
uses: arduino/setup-task@v2
77+
with:
78+
repo-token: ${{ secrets.GITHUB_TOKEN }}
79+
version: 3.x
80+
81+
- name: Validate package.json
82+
run: |
83+
task \
84+
--silent \
85+
npm:validate \
86+
PROJECT_PATH="${{ matrix.project.path }}"
87+
88+
check-sync:
89+
name: check-sync (${{ matrix.project.path }})
90+
needs: run-determination
91+
if: needs.run-determination.outputs.result == 'true'
92+
runs-on: ubuntu-latest
93+
permissions:
94+
contents: read
95+
96+
strategy:
97+
fail-fast: false
98+
matrix:
99+
project:
100+
- path: .
101+
102+
steps:
103+
- name: Checkout repository
104+
uses: actions/checkout@v4
105+
106+
- name: Setup Node.js
107+
uses: actions/setup-node@v4
108+
with:
109+
node-version-file: package.json
110+
111+
- name: Install Task
112+
uses: arduino/setup-task@v2
113+
with:
114+
repo-token: ${{ secrets.GITHUB_TOKEN }}
115+
version: 3.x
116+
117+
- name: Install npm dependencies
118+
run: |
119+
task \
120+
npm:install-deps \
121+
PROJECT_PATH="${{ matrix.project.path }}"
122+
123+
- name: Check package-lock.json
124+
run: |
125+
git \
126+
diff \
127+
--color \
128+
--exit-code \
129+
"${{ matrix.project.path }}/package-lock.json"

Diff for: .github/workflows/check-npm.yml

-169
This file was deleted.

0 commit comments

Comments
 (0)