Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
Replace to node20 (#533)
Browse files Browse the repository at this point in the history
* Replace to node20

* `npm uninstall esbuild && npm install esbuild --save-dev`

* `npm run build`

* `npm uninstall typescript tsx && npm install typescript tsx --save-dev`

* Workaround to load toolkit codes

And fix some use of assert.equal or deepEqual

* Update CI

* Required to fetch submodules
  • Loading branch information
kachick authored Oct 5, 2023
1 parent 29a1bbc commit 7985bd4
Show file tree
Hide file tree
Showing 17 changed files with 23,534 additions and 31,694 deletions.
File renamed without changes.
65 changes: 34 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,46 @@ on:
- 'README.md'
- '.vscode/**'
jobs:
build:
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 run build
- name: Check no diff for products
run: git add --intent-to-add . && git diff --exit-code

test:
# To update git diff
permissions:
pull-requests: write
contents: write
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
submodules: true # Fetch example project
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
# https://yoshiori.hatenablog.com/entry/2021/12/08/220839
ref: ${{ github.event.pull_request.head.ref }}
- uses: actions/setup-node@v3
submodules: recursive
- 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 (Need to build before 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: git add --intent-to-add . && git diff --exit-code
- run: npm ci --ignore-scripts
- run: npm test

typecheck:
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
- name: Typecheck
run: npm run typecheck

lint:
timeout-minutes: 15
Expand Down
34 changes: 7 additions & 27 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,19 @@ See also [scripts](package.json) for tasks details.

```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;
undefined

> // Utils can be loaded
> const { parsePackage } = await import('./src/elm-package-detector.ts');
> parsePackage('elm-explorations/test', '2.1.0')
Expand All @@ -56,24 +57,3 @@ PackageURL {
subpath: null
}
```

## 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).

```
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).
29 changes: 6 additions & 23 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,13 @@ script = [
"git submodule update --init --recursive",
]

[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]
category = "Tools"
description = "Run linters without changes"
Expand All @@ -49,7 +32,7 @@ script = [
"actionlint",
]

[tasks.test-ts]
[tasks.test]
category = "Tools"
description = 'Test typescripts'
script = [
Expand All @@ -63,17 +46,17 @@ script = [
"npm run typecheck",
]

[tasks.package]
[tasks.build]
category = "Tools"
description = 'Correctness in TypeScript'
description = 'Build'
script = [
"npm run package",
"npm run build",
]

[tasks.check]
category = "Tools"
description = 'Parallel runner for all tests and linters'
run_task = { name = ["typos-check", "test-ts", "typecheck", "lint"], parallel = true }
run_task = { name = ["test", "typecheck", "lint", "build"], parallel = true }

[tasks.all]
category = "Tools"
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ inputs:
required: false
default: 'elm.json'
runs:
using: 'node16'
using: 'node20'
main: 'dist/index.js'
Loading

0 comments on commit 7985bd4

Please sign in to comment.