Skip to content

Commit

Permalink
Update to node20 and refine several development flows (#432)
Browse files Browse the repository at this point in the history
* Simply replaced to node20

kachick/wait-other-jobs#564

* `npm install --save-dev @tsconfig/strictest @tsconfig/node20`

* Refer upstream tsconfig again

This made failure in jest

* Update node20 and refine environments

See https://github.com/kachick/wait-other-jobs/pulls for more detail

- Update node20
- Replace jest with node18+ test runner
- Refer upstream tsconfig
- Replace ncc role with esbuild

* Update dist with added build task

* `npm uninstall @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint`

* Replace eslint with `deno lint`
  • Loading branch information
kachick committed Oct 5, 2023
1 parent cd91829 commit bfde82d
Show file tree
Hide file tree
Showing 25 changed files with 8,538 additions and 19,452 deletions.
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

42 changes: 0 additions & 42 deletions .eslintrc.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ updates:
ignore:
- dependency-name: '@types/*'
update-types: ['version-update:semver-major']
groups:
eslint-dependencies:
patterns:
- '*eslint*'
64 changes: 27 additions & 37 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,71 +6,61 @@ on:
- '.github/dependabot.yml'
- 'LICENSE'
- '.editorconfig'
- '.eslintrc.js'
- 'README.md'
- '.vscode/**'
pull_request:
paths-ignore:
- '.github/dependabot.yml'
- 'LICENSE'
- '.editorconfig'
- '.eslintrc.js'
- 'README.md'
- '.vscode/**'
jobs:
build:
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
with:
node-version: 16
node-version: '20.8.0' # selfup { "regex": "\\d[^']+", "script": "node --version | tr -d v" }
cache: npm
- name: install dependencies
run: npm ci --ignore-scripts
- name: Test
run: npm test
- name: Ensure we can make package
run: npm run package
# dependabot E-mail address: https://github.com/orgs/community/discussions/26560
- name: Update build files
run: |
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git config user.name 'github-actions[bot]'
git add dist
if ! git diff --exit-code --quiet
then
git commit -m 'Update build files'
git push
fi
if: ${{ github.actor == 'dependabot[bot]' || github.actor == 'renovate[bot]' }}
- name: Prevent missing commits after compile
- run: npm ci --ignore-scripts
- run: npm run build
- name: Check no diff for products
run: git add --intent-to-add . && git diff --exit-code

test:
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
with:
node-version: '20.8.0' # selfup { "regex": "\\d[^']+", "script": "node --version | tr -d v" }
cache: npm
- run: npm ci --ignore-scripts
- run: npm test

typecheck:
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
with:
node-version: 16
node-version: '20.8.0' # selfup { "regex": "\\d[^']+", "script": "node --version | tr -d v" }
cache: npm
- name: install dependencies
run: npm ci --ignore-scripts
- run: npm ci --ignore-scripts
- name: Typecheck
run: npm run typecheck

lint:
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- uses: denoland/setup-deno@0df5d9c641efdff149993c321fc27c11c5df8623 # v1.1.3
with:
node-version: 16
cache: npm
- name: install dependencies
run: npm ci --ignore-scripts
- name: Lint
run: npm run lint:check
deno-version: '1.37.1' # selfup { "regex": "\\d[^']+", "script": "deno --version | head -n 1 | cut -d ' ' -f 2" }
- run: deno lint
2 changes: 0 additions & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ on:
- 'LICENSE'
- '.editorconfig'
- 'dprint.json'
- '.eslintrc.js'
- 'README.md'
- '.vscode/**'
pull_request:
Expand All @@ -24,7 +23,6 @@ on:
- 'LICENSE'
- '.editorconfig'
- 'dprint.json'
- '.eslintrc.js'
- 'README.md'
- '.vscode/**'

Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ typings/
# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
Expand Down
1 change: 0 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"github.vscode-github-actions",
"editorconfig.editorconfig",
"dprint.dprint",
Expand Down
66 changes: 20 additions & 46 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,45 @@

## Setup

### Nix

1. Install [Nix](https://nixos.org/) package manager
2. Run `nix develop` or `nix develop --command 'zsh'`
2. Run `nix develop` or `direnv allow`
3. You can use development tasks

```console
> nix develop
(prepared bash)

> npm install
64 packages are looking for funding
run `npm fund` for details

found 0 vulnerabilities..
(prepared shell)
```

> makers help
Tools
----------
check - ...
help - ...
### Tasks

```console
> makers check
...tests, typechecks, linters...
[cargo-make] INFO - Build Done in 2.14 seconds.
```

See also [scripts](package.json) for tasks details.
See also [scripts](package.json) and [Makefile](Makefile.toml) for tasks details.

## REPL

```typescript
> npm run repl
Welcome to Node.js v16.19.0.

> my-new-action@1.0.0 repl
> tsx

Welcome to Node.js v20.8.0.
Type ".help" for more information.

> // You can use `import()` function, not `import statement`.
>
> const { info, isDebug, debug } = await import('@actions/core');
undefined
> isDebug()
false

> // TypeScript syntax can be used, but no typechecking executed.
> const foo: number = 42;
> const { wait } = await import('./src/wait.ts');
undefined

> // Utils can be loaded
> const { readableDuration } = await import('./src/wait.ts');
> readableDuration(4200)
'about 4 seconds'
Uncaught SyntaxError: Unexpected identifier 'wait'
> await wait(42)
'done!'
```

## Why using ncc and esbuild?

Honestly I want to have only one tool. However keeping ncc for compatibility. Quote from [esbuild documents](https://github.com/esbuild/esbuild.github.io/blob/b431563203d117c4cf9f467481960aeaabcc0fde/src/content/getting-started.yml#L268-L314).

```plaintext
You also may not want to bundle your dependencies with esbuild. There are many node-specific features that esbuild doesn't support while bundling such as __dirname, import.meta.url, fs.readFileSync, and *.node native binary modules. You can exclude all of your dependencies from the bundle by setting packages to external:
esbuild app.jsx --bundle --platform=node --packages=external
If you do this, your dependencies must still be present on the file system at run-time since they are no longer included in the bundle.
```

## Why using nodejs16 instead of deno/bun/nodejs18?

They are not yet supported in JavaScript action engine.

- <https://github.com/actions/runner/blob/5421fe3f7107f770c904ed4c7e506ae7a5cde2c2/src/Runner.Worker/ActionManifestManager.cs#L492>
- <https://github.com/kachick/wait-other-jobs/pull/273#issuecomment-1306058624>

After bumped to nodejs18, I'd like to replace jest with [built-in test runner](https://github.com/nodejs/node/pull/42325).
56 changes: 15 additions & 41 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,59 +8,26 @@ script = [
"npm ci --ignore-scripts",
]

[tasks.format-check]
category = "Tools"
description = "Run formatters without changes"
script = [
"dprint check",
]

[tasks.format-apply]
[tasks.fmt]
category = "Tools"
description = "Run formatters with changes"
script = [
"dprint fmt",
]

[tasks.fmt]
alias = "format-apply"

[tasks.typos-check]
category = "Tools"
description = "Run typo checker without changes"
script = [
"typos . .github .vscode",
]

[tasks.lint-apply]
category = "Tools"
description = "Run linters with changes"
dependencies = [
# Do not run parallel, because of dprint is superfast and eslint is slow. So sequential makes useful here.
"format-apply",
]
script = [
"npm run lint:fix",
]

[tasks.lint-check]
[tasks.lint]
category = "Tools"
description = "Run linters without changes"
dependencies = [
# Do not run parallel, because of dprint is superfast and eslint is slow. So sequential makes useful here.
"format-check",
]
script = [
"npm run lint:check",
"dprint check",
"deno lint",
"typos . .github .vscode",
"actionlint",
]

[tasks.lint]
alias = "lint-check"

[tasks.test-ts]
[tasks.test]
category = "Tools"
description = 'Test typescripts'
description = 'Test'
script = [
"npm test",
]
Expand All @@ -72,6 +39,13 @@ script = [
"npm run typecheck",
]

[tasks.build]
category = "Tools"
description = 'Build that actually run in production'
script = [
"npm run build",
]

[tasks.package]
category = "Tools"
description = 'Correctness in TypeScript'
Expand All @@ -82,7 +56,7 @@ script = [
[tasks.check]
category = "Tools"
description = 'Parallel runner for all tests and linters'
run_task = { name = ["typos-check", "test-ts", "typecheck", "lint-check"], parallel = true }
run_task = { name = ["test", "typecheck", "lint", "build"], parallel = true }

[tasks.all]
category = "Tools"
Expand Down

0 comments on commit bfde82d

Please sign in to comment.