-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nuke node modules #43
Conversation
fe7ee3b
to
45e2819
Compare
Maybe you want to do some of those things in a separate PR ? E.g. bumping |
My plan is to get the CI green and then I can split the changes in separate PR if necessary.
I wanted to go straight for the final version, since I don't to pollute the git history even more unused binary artifacts :D
I'm trying to debug why it fails on Windows.
I actually locally upgraded Node.js from v12 to v14, but in VSCode, I got a warning saying that according to the schema for Edit: Indeed only |
1a5373a
to
fc426c1
Compare
Committing diff --git a/node_modules/@actions/core/package.json b/node_modules/@actions/core/package.json
index 5b66e79..ca8275c 100644
--- a/node_modules/@actions/core/package.json
+++ b/node_modules/@actions/core/package.json
@@ -2,7 +2,7 @@
"_args": [
[
"@actions/[email protected]",
- "/Users/geod24/projects/dlang/setup-dlang"
+ "/home/zlx/code/repos/dlang/dlang-community/setup-dlang"
]
], --- a/node_modules/@actions/exec/package.json
+++ b/node_modules/@actions/exec/package.json
@@ -1,36 +1,39 @@
{
- "_from": "@actions/exec@^1.0.0",
+ "_args": [
+ [
+ "@actions/[email protected]",
+ "/home/zlx/code/repos/dlang/dlang/dlang-community/setup-dlang"
+ ]
+ ],
+ "_from": "@actions/[email protected]",
"_id": "@actions/[email protected]",
"_inBundle": false,
"_integrity": "sha512-4DPChWow9yc9W3WqEbUj8Nr86xkpyE29ZzWjXucHItclLbEW6jr80Zx4nqv18QL6KK65+cifiQZXvnqgTV6oHw==",
"_location": "/@actions/exec",
"_phantomChildren": {},
"_requested": {
- "type": "range",
+ "type": "version",
"registry": true,
- "raw": "@actions/exec@^1.0.0",
+ "raw": "@actions/[email protected]",
"name": "@actions/exec",
"escapedName": "@actions%2fexec",
"scope": "@actions",
- "rawSpec": "^1.0.0",
+ "rawSpec": "1.0.4",
"saveSpec": null,
- "fetchSpec": "^1.0.0"
+ "fetchSpec": "1.0.4"
},
"_requiredBy": [
"/@actions/tool-cache"
],
"_resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.4.tgz",
- "_shasum": "99d75310e62e59fc37d2ee6dcff6d4bffadd3a5d",
- "_spec": "@actions/exec@^1.0.0",
- "_where": "/Users/geod24/projects/dlang/setup-dlang/node_modules/@actions/tool-cache",
+ "_spec": "1.0.4",
+ "_where": "/home/zlx/code/repos/dlang/dlang/dlang-community/setup-dlang",
"bugs": {
"url": "https://github.com/actions/toolkit/issues"
},
- "bundleDependencies": false,
"dependencies": {
"@actions/io": "^1.0.1"
},
- "deprecated": false, 🤦 |
4287ead
to
e28e1d2
Compare
Despite the completely unhelpful error message, I think I found the issue - it tries to execute the script I see two possible solutions:
It seems to me that 2. is the simplest one and I will go with it. The disadvantage is that updating |
e28e1d2
to
f1435d2
Compare
Hm, so the bundling tool doesn't take care of any additional resources that can be provided by the package? It only bundles JS and discards the rest? |
A JS bundler (like webpack, which ncc uses internally) simply follows the In this case, |
The following files and folders are intensionally not committed: * `node_modules/.bin/ncc` * `node_modules/@vercel/` Since doing so would be pointless, because the next commit is going to delete them.
f1435d2
to
4d4dc25
Compare
@mihails-strasuns if you're worried about this, if you prefer, I can simply change the git diff --no-index -- ./scripts ./node_modules/@actions/tool-cache/scripts |
@Geod24 @mihails-strasuns This PR should be finally ready for review - please take a look! |
}, | ||
"devDependencies": { | ||
"@types/node": "^12.7.4", | ||
"@types/node": "^14.14.25", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't that still be 12 if we're using node12, or it's unrelated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can think of @types/node
as the druntime bindings in core.sys
, but less important. It's less important, since it doesn't influence codegen / ABI, like core.sys, but simply type checking - it tells the TypeScript compiler which functions are available and what type of parameters they expect. Upgrading to a new version of @types/node
is generally safe as almost always it means that they added new bindings or fixed existing ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, unlike say freebsd, where you really need to match definitions in core.sys
with version of freebsd that the final application will run on, @types/node
can be used with both older and newer Node.js versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the worst case, using a new version @types/node
may allow us to use an API that is not available in older Node.js, but we have a CI pipeline to check for that ;)
… `ncc` Detailed description of changes: * Update the `build` script in `package.json` so that it builds and "links" the TypeScript code along with all of its (transitive) dependencies in a single `index.js` file using `@vercel/ncc`. * Add / copy `scripts/{Invoke-7zdec.ps1,externals/7zdec.exe}` from `node_modules/@actions/tool-cache/scripts` as its needed by the aforementioned dependency on Windows and it used to be included in the `node_modules` folder which will be deleted by the next commit. * Change the `main` file in `package.json` and `action.yml` to `dist/index.js`. `ncc` allows only the out dir can be specified - the filename is always `index.js`. * Add `lib/` and `dist/*` to .gitingore, but exclude `dist/index.js` from the list so it will be committed. * Delete the `lib/` folder * `node_modules` will be deleted in the next commit to make make the reviewing easier. * Add the `dist/index.js` file produced by running `npm run build`. * Add a `.gitattributes` file in order to set mark `dist/**` as `binary` for git diff and merge purposes. A wildcard is used as a sourcemap file could also be included later if necessary, which should also be considered a "binary" file. * Update `.gitignore` to the latest version from here: `https://github.com/github/gitignore/blob/master/Node.gitignore` * Set the `target` in `tsconfig.json` to `es2017`, which is [supported by current Node.js version - v12][1], as should make for cleaner generated "down-leveled" code as it has native async/await support [1]: https://node.green/
4d4dc25
to
360d27f
Compare
I split the deletion of node_modules in its own commit, so now reviewing the PR commit-by-commit should be much easier. I also updated the commit message of commit 5361e1b to better explain what's going on. |
And also update the `description` field.
360d27f
to
1dd7ff7
Compare
I added commit 7ab9fc9 which adds a final step to our CI pipeline which installs Node.js 12, and runs: set -euxo pipefail
npm ci
npm run build
git diff --stat --exit-code HEAD The goal is to ensure that no contributor is able to have his pull request merged, unless they correctly update the To verify that this catches modified files I push this commit 76539ab which simply adds a few newlines to the end of the file. As you can see here this discrepancy is correctly caught: https://github.com/dlang-community/setup-dlang/pull/43/checks?check_run_id=1865501855 This adds an extras 40 seconds to each of our test matrix permutations, but I think it's worth it for the piece of mind ;) |
76539ab
to
1dd7ff7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only improvement that comes to my mind is automatically generating ìndex.js` in the CI upon merge (i.e. using auto-merge label) rather than requiring contributors to do that on their side. This can be done as a separate PR though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Only thing missing from my side would be a note for contributors in the README.
Yes, that's a good idea, but it would require giving the CI git credentials to push commits to the repo, so I prefer to leave this for a separate PR.
Good point - I will add later today. |
It already has it. Look for persist-credentials. But yeah, separate PR LGTM. |
Actually, if we automatize it, there's no point in adding instructions that will be deleted, so let's go ahead with this. |
Thanks for the review guys! |
[.editorconfig]: Enable
trim_trailing_whitespace
[package.json]: Add
@vercel/ncc@^0.27.0
dev dependency[build]: Replace
node_modules
with a single-file bundle produced byncc
Detailed description of changes:
Update the
build
script inpackage.json
so that it builds and "links" the TypeScript code along with all of its (transitive) dependencies in a singleindex.js
file using@vercel/ncc
.Add / copy
scripts/{Invoke-7zdec.ps1,externals/7zdec.exe}
fromnode_modules/@actions/tool-cache/scripts
as its needed by the aforementioned dependency on Windows and it used to be included in thenode_modules
folder which will be deleted by the next commit.Change the
main
file inpackage.json
andaction.yml
todist/index.js
.ncc
allows only the out dir can be specified - the filename is alwaysindex.js
.Add
lib/
anddist/*
to .gitingore, but excludedist/index.js
from the list so it will be committed.Delete the
lib/
folderAdd the
dist/index.js
file produced by runningnpm run build
.Add a
.gitattributes
file in order to set markdist/**
asbinary
for git diff and merge purposes. A wildcard is used as a sourcemap file could also be included later if necessary, which should also be considered a "binary" file.Update
.gitignore
to the latest version from here:https://github.com/github/gitignore/blob/master/Node.gitignore
Set the
target
intsconfig.json
toes2017
, which is supported by current Node.js version - v12, as should make for cleaner generated "down-leveled" code as it has native async/await suppor[node_modules]: Delete the folder from git
[package.json]: Upgrade dependencies to their latest available versions
[ci]: Verify that
dist/index.js
is correctly generated[package.json]: Bump the version to
1.1.0
And also update the
description
field.