Skip to content

Sort inputs and remove whitespaces after exclamation - #473

Closed
mondeja wants to merge 9 commits into
actions:mainfrom
mondeja:fix-345
Closed

mondeja wants to merge 9 commits into
actions:mainfrom
mondeja:fix-345

Conversation

@mondeja

@mondeja mondeja commented Nov 28, 2020

Copy link
Copy Markdown
Contributor

Fixes #345

@mondeja

mondeja commented Nov 28, 2020

Copy link
Copy Markdown
Contributor Author

I'm not sure why is prettier failing in Windows 🤔

Comment thread __tests__/actionUtils.test.ts Resolved
Comment thread __tests__/restore.test.ts Resolved
Comment thread src/utils/actionUtils.ts Outdated
.split("\n")
.map(s => s.trim())
.filter(x => x !== "");
.map(s => s.replace(/^\!\s+/, '!').trim())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what does this line do and why is this required?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All white spaces after an exclamation sign in lines starting with exclamation sign are removed. Is required for normalization of excluded paths.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mondeja Is this normalization really required? In most cases, I've seen people never use spaces after ! . A simple trim() should be good enough. @bishal-pdMSFT thoughts?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, can you push a commit to rerun the workflows, I'm unable to see the old logs to check by windows build is failing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it is really "required". It seems that can be declared with space but the hash will not be the same.

A simple trim() should be good enough.

I don't follow you. This implementation is not trimming, ! foo should be converted to !foo but .trim() does not modificates it ('! foo'.trim() === '! foo' is true).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand but what I'm saying is that people don't normally use ! foo, they'll just use !foo directly, as mentioned in our docs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be some prettier issue for windows. Can you run npm run format once to see if it produces any changes?

@mondeja mondeja Feb 22, 2022 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm run format does not produce changes in my Ubuntu, seems only failing in Windows.

I understand but what I'm saying is that people don't normally use ! foo, they'll just use !foo directly, as mentioned in our docs.

I haven't used the space in the past and don't have any preference about it. Just implemented here because it is possble to include the space after the exclamation sign using @actions/glob API directly:

> const glob = require('@actions/glob');
> const globber = await glob.create(['node_modules/.bin/*', '! node_modules/.bin/mkdirp'].join('\n'))
> await globber.glob()

But is up to you to include this change or not, keeping in mind that although is possible and works the hash will not match if in one run the space exists and in other not.

@mondeja
mondeja requested a review from a team as a code owner February 22, 2022 11:37
@vsvipul
vsvipul requested a review from bishal-pdMSFT May 11, 2022 09:30
@vsvipul vsvipul assigned Phantsure and vsvipul and unassigned Phantsure May 11, 2022
@vsvipul

vsvipul commented Jun 21, 2022

Copy link
Copy Markdown
Contributor

@mondeja Unless the windows-latest test is fixed, I won't be able to merge this. Please see if you can fix it.

@mondeja

mondeja commented Jun 21, 2022 •

Copy link
Copy Markdown
Contributor Author

Unless the windows-latest test is fixed, I won't be able to merge this. Please see if you can fix it.

OK, but I need approval for workflow runs because I'm not able to reproduce the error locally.

@mondeja

mondeja commented Jun 21, 2022

Copy link
Copy Markdown
Contributor Author

Not totally sure if it is passing now, but I've tried to rebuild and raises conflicts, that's why I've force pushed. IHMO, the dist/ folder must not be pushed to main, just to releases branches.

@vsvipul

vsvipul commented Jun 26, 2022

Copy link
Copy Markdown
Contributor

@mondeja Yes, please regenerate dist/ as that will be required for merging. When we create a new release, users using actions/cache@v3 will be pointed to the new release with this code.

@mondeja

mondeja commented Jun 27, 2022

Copy link
Copy Markdown
Contributor Author

Regenerated, see the conflicts

@vsvipul

vsvipul commented Jun 27, 2022

Copy link
Copy Markdown
Contributor

Hmm for dist/ files there shouldn't be conflicts. I'll take a look.

@vsvipul

vsvipul commented Jun 27, 2022

Copy link
Copy Markdown
Contributor

@mondeja What version of npm are you using ?
I checkout out your branch and regenerated dist/ . There were some changes -

@vsvipul ➜ /workspaces/cache (fix-345) $ npm run build

> [email protected] build /workspaces/cache
> tsc && ncc build -o dist/restore src/restore.ts && ncc build -o dist/save src/save.ts

ncc: Version 0.20.5
ncc: Compiling file index.js
ncc: Using [email protected] (local user-provided)
2445kB  dist/restore/index.js
2445kB  [5775ms] - ncc 0.20.5
ncc: Version 0.20.5
ncc: Compiling file index.js
ncc: Using [email protected] (local user-provided)
2445kB  dist/save/index.js
2445kB  [4773ms] - ncc 0.20.5
@vsvipul ➜ /workspaces/cache (fix-345 ✗) $ git diff
diff --git a/dist/restore/index.js b/dist/restore/index.js
index 1700b8e..f8f36f1 100644
--- a/dist/restore/index.js
+++ b/dist/restore/index.js
@@ -48,6 +48,25 @@ module.exports =
 
 "use strict";
 
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+    if (k2 === undefined) k2 = k;
+    o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+    Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+    o["default"] = v;
+});

@mondeja

mondeja commented Jun 27, 2022 •

Copy link
Copy Markdown
Contributor Author

Node v16 and NPM v8, what version should I use?

@vsvipul

vsvipul commented Jun 27, 2022

Copy link
Copy Markdown
Contributor

Hi @mondeja dist/ files should not be generated, I just tried on main with your changes. Can you try to update your main from actions/cache and then rebase this branch from that main.

@mondeja

mondeja commented Jun 27, 2022 •

Copy link
Copy Markdown
Contributor Author

Done. I've reverted to the change previous regeneration, merged main and force pushed.

Trying to regenerate with npm run build I'm getting the next errors, so I've not regenerated this time:

Errors
src/restore.ts:55:25 - error TS1196: Catch clause variable cannot have a type annotation.

55         } catch (error: unknown) {
                           ~~~~~~~

src/restore.ts:64:21 - error TS1196: Catch clause variable cannot have a type annotation.

64     } catch (error: unknown) {
                       ~~~~~~~

src/save.ts:52:25 - error TS1196: Catch clause variable cannot have a type annotation.

52         } catch (error: unknown) {
                           ~~~~~~~

src/save.ts:62:21 - error TS1196: Catch clause variable cannot have a type annotation.

62     } catch (error: unknown) {
                       ~~~~~~~

src/utils/actionUtils.ts:81:16 - error TS2339: Property 'isFeatureAvailable' does not exist on type 'typeof import("/...path/to/.../cache/node_modules/@actions/cache/lib/cache")'.

81     if (!cache.isFeatureAvailable()) {
                  ~~~~~~~~~~~~~~~~~~


Found 5 errors.

@vsvipul

vsvipul commented Aug 17, 2022

Copy link
Copy Markdown
Contributor

Apologies for the delay, I'll try to take a look this week and see if I can cherry pick and commit this change without the check dist/ check failing.

@vsvipul

vsvipul commented Aug 22, 2022

Copy link
Copy Markdown
Contributor

Cherry-picked this commit and working on it in #903. So, closing this for now. Thank you the contribution. Will get merged soon. 🙌

@vsvipul vsvipul closed this Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Normalize path in version hash

4 participants