Skip to content

Commit f822bc2

Browse files
ci(node): update node engines version handling to reduce the setup time in CI (#269)
## Walkthrough The changes across various files reflect an update to the GitHub Actions workflows and configuration for a Node.js project. These updates include the introduction of custom actions for setting up Node.js, modifications to event triggers, and concurrency settings in workflows. There's also a shift in the coverage reporting configuration and the removal of specific linting rules. Additionally, there's a new script for validating Node.js versions and updates to the project's documentation to reflect the use of Volta for Node.js version management. ## Changes | File Path | Change Summary | |-----------|----------------| | `.github/actions/setup-node/action.yml` | Introduced custom GitHub Actions for setting up Node.js environment with `actions/setup-node@v4`. | | `.github/workflows/deploy.yml` | Updated workflow for NPM release, including custom Node.js setup and semantic release trigger. | | `.github/workflows/push_code_linting.yml` | Modified event triggers and concurrency, replaced Node.js setup with custom action. | | `.github/workflows/release_action.yml.disabled` | Replaced `setup-node` action with custom setup-node action. | | `.github/workflows/test.yml` | Updated test workflow with custom Node.js setup, coverage reporting, and deployment trigger. | | `.ncurc.yml` | Removed rejection of "chalk" package. | | `.npmrc` | Removed `use-node-version` config and updated branch patterns for lockfiles merging. | | `scripts/latest_valid_node_version.sh` | Added script to check for compatible Node.js version. | | `vitest.config.ts` | Updated coverage configuration to use 'v8' provider and modified reports directory and include paths. | | `.markdownlint.json` | Removed specific proper names and "code_blocks" setting from MD044 rule. | | `src/inputs.ts`, `src/readme-generator.ts` | Removed unused imports and commented-out code. | | `README.md` | Added note on using Volta for Node.js version management. |
1 parent f750ff0 commit f822bc2

12 files changed

+40
-38
lines changed

.github/workflows/push_code_linting.yml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
name: Code Linting Annotation
2-
on: [pull_request]
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
- next
7+
- beta
8+
- "*.x"
9+
push:
10+
branches:
11+
- main
12+
- next
13+
- beta
14+
- "*.x"
15+
316
concurrency:
4-
group: ci-${{ github.event.pull_request.number || github.ref }}
17+
group: ci-linting-${{ github.event.pull_request.number || github.ref }}
518
cancel-in-progress: true
619
jobs:
720
eslint_annotation:
@@ -21,15 +34,10 @@ jobs:
2134
steps:
2235
- uses: actions/checkout@v4.1.1
2336

24-
- id: get-node-version
25-
run: |
26-
NODE_VERSION=$(grep -oP '^node-version\s*=\s*\K.*' .npmrc | cut -d '.' -f 1-3)
27-
echo "node-version=${NODE_VERSION}" >> "$GITHUB_OUTPUT"
28-
29-
- uses: actions/setup-node@v4
30-
with:
31-
node-version: ${{ steps.get-node-version.outputs.node-version }}
32-
cache: "npm"
37+
- name: Install compatible Nodejs version
38+
id: setup-node
39+
uses: ./.github/actions/setup-node
40+
3341
- name: Install Deps
3442
run: npm install
3543
- uses: xt0rted/markdownlint-problem-matcher@v2

.github/workflows/release_action.yml.disabled

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,9 @@ jobs:
2525
ref: ${{ github.ref }}
2626
- name: Prepare repository
2727
run: git fetch --unshallow --tags
28-
- uses: actions/setup-node@v4
29-
with:
30-
node-version: '16.x'
31-
registry-url: 'https://registry.npmjs.org'
32-
always-auth: true
33-
cache: npm
28+
- name: Install compatible Nodejs version
29+
id: setup-node
30+
uses: ./.github/actions/setup-node
3431
- run: git config --global init.defaultBranch main
3532
- name: Get yarn cache directory path
3633
id: yarn-cache-dir-path

.github/workflows/test.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,6 @@ jobs:
4545
echo "$HOME/.local/bin" >> "${GITHUB_PATH}"
4646
echo "HOME=$HOME" >> "${GITHUB_ENV}"
4747
48-
- name: Configure Git
49-
run: |
50-
git config --global user.email "${{ github.event.pusher.email || 'stack@bitflight.io' }}"
51-
git config --global user.name "${{ github.event.pusher.name || 'GitHub[bot]' }}"
52-
git fetch --tags
53-
git status --porcelain -u
54-
5548
- run: npm install
5649
- run: npm run test
5750
- run: npm run coverage

.markdownlint.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
"MD043": false,
9696
// MD044/proper-names - Proper names should have the correct capitalization
9797
"MD044": {
98-
"names": ["JavaScript", "TypeScript", "TSLint", "ESLint"],
9998
"code_blocks": false
10099
},
101100
// MD045/no-alt-text - Images should have alternate text (alt text)

.ncurc.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
upgrade: true
2-
reject: ["chalk"]

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.x

.npmrc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,4 @@ bitflight-devops:registry=https://registry.npmjs.org/
66
# always-auth=true
77
merge-git-branch-lockfiles-branch-pattern[]=main
88
merge-git-branch-lockfiles-branch-pattern[]=release*
9-
use-node-version=20.7.0
10-
node-version=20.7.0
119
progress=false

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,5 +221,8 @@ You can modify the script below to include any extra variables you like or use n
221221
| <code>readme_after</code> | The content of the readme file after the changes were made |
222222
223223
<!-- end outputs -->
224+
225+
**NOTE**: [volta.sh](https://volta.sh/) is a great tool for managing node versions, and is configured in this directory. If you have volta installed, you can run `volta install` to install the correct version of node for this project.
226+
224227
<!-- start [.github/ghadocs/examples/] -->
225228
<!-- end [.github/ghadocs/examples/] -->

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
},
1919
"repository": {
2020
"type": "git",
21-
"url": "https://github.com/bitflight-devops/github-action-readme-generator"
21+
"url": "git+https://github.com/bitflight-devops/github-action-readme-generator.git"
2222
},
2323
"license": "APACHE",
2424
"author": "Jamie Nelson <jamie@bitflight.io>",
@@ -30,13 +30,15 @@
3030
"main": "dist/cjs/index.js",
3131
"module": "dist/mjs/index.js",
3232
"types": "dist/types/index.d.ts",
33-
"bin": "dist/bin/index.js",
33+
"bin": {
34+
"github-action-readme-generator": "dist/bin/index.js"
35+
},
3436
"files": [
3537
"package.json",
3638
"README.md",
3739
"LICENSE",
3840
"CHANGELOG.md",
39-
"/dist"
41+
"dist/"
4042
],
4143
"scripts": {
4244
"all": "npm run build && npm run format && npm run lint && npm run test",
@@ -93,8 +95,8 @@
9395
},
9496
"lint-staged": {
9597
"*.{md,json,yaml,yml,sh}": "prettier --write",
96-
"{src,__tests__}/**/*.js": "eslint --cache --fix",
97-
"*.{ts,mts,yml}": [
98+
"{src,__tests__}/**/*.ts": "eslint --cache --fix",
99+
"*.{yaml,yml}": [
98100
"eslint --cache --fix"
99101
]
100102
},
@@ -209,13 +211,17 @@
209211
"vitest": "^0.34.6"
210212
},
211213
"engines": {
212-
"node": ">= 18"
214+
"node": ">=20.0.0 <21.0.0",
215+
"npm": ">=10.0.0"
213216
},
214217
"os": [
215218
"!win32"
216219
],
217220
"publishConfig": {
218221
"access": "public",
219222
"registry": "https://registry.npmjs.org/"
223+
},
224+
"volta": {
225+
"node": "20.9.0"
220226
}
221227
}

0 commit comments

Comments
 (0)