-
Notifications
You must be signed in to change notification settings - Fork 143
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
Test balena push with docker-compose using symlinks #2408
Conversation
2bb979f
to
2b1f9a0
Compare
lib/utils/ignore.ts
Outdated
const isDirectory = | ||
entry.isDirectory() || | ||
(entry.isSymbolicLink() && | ||
(await fs.stat(await fs.realpath(fpath))).isDirectory()); |
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.
Is the realpath()
call necessary? I understand that fs.stat()
will (recursively) follow symlinks if fpath
is a symlink (as opposed to fs.lstat()
), so it would not be necessary to explicitly resolve the symlink with realpath()
.
(await fs.stat(await fs.realpath(fpath))).isDirectory()); | |
(await fs.stat(fpath)).isDirectory()); |
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.
TIL that fs.stat()
does follow symbolic links. Nice catch 👍
@@ -0,0 +1 @@ | |||
../symlink-fixtures/service1/ |
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.
Build is failing on Windows with:
glob error [Error: EPERM: operation not permitted, scandir 'C:\var\lib\concourse\worker\volumes\live\a9a3a529-20a6-4d2c-748a-bf5059dd242b\volume\tests\test-data\projects\docker-compose\symbolic-links\service1'] {
errno: -4048,
code: 'EPERM',
syscall: 'scandir',
path: 'C:\\var\\lib\\concourse\\worker\\volumes\\live\\a9a3a529-20a6-4d2c-748a-bf5059dd242b\\volume\\tests\\test-data\\projects\\docker-compose\\symbolic-links\\service1'
}
It rings a bell that Windows doesn't play nicely with soft links, however out of the 5 existing tests that touch the dockerignore2
test project that uses soft links, I think only one is currently being skipped on Windows:
push
: https://github.com/balena-io/balena-cli/blob/v12.55.4/tests/commands/push.spec.ts#L355push
: https://github.com/balena-io/balena-cli/blob/v12.55.4/tests/commands/push.spec.ts#L412tarDirectory
: https://github.com/balena-io/balena-cli/blob/v12.55.4/tests/utils/tarDirectory.spec.ts#L92tarDirectory
: https://github.com/balena-io/balena-cli/blob/v12.55.4/tests/utils/tarDirectory.spec.ts#L147- "live push": https://github.com/balena-io/balena-cli/blob/v12.55.4/tests/utils/device/live.spec.ts#L230
So maybe some investigation on how come that 4 other tests don't need to be skipped on Windows (maybe they don't really exercise the soft link aspect?) before skipping this test on Windows as well.
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.
how come that 4 other tests don't need to be skipped on Windows
tarDirectory
: https://github.com/balena-io/balena-cli/blob/v12.55.4/tests/utils/tarDirectory.spec.ts#L147
This is the one that is completely skipped on Windows:
const itSkipWindows = process.platform === 'win32' ? it.skip : it;
itSkipWindows('should produce a compatible tar stream (symbolic links)'
This test is not skipped but it cheats :-) with:
...(isWindows
? {
'lib/src-a.txt': { fileSize: 5, type: 'file' },
'src/src-a.txt': { fileSize: 5, type: 'file' },
}
: {}),
push
: https://github.com/balena-io/balena-cli/blob/v12.55.4/tests/commands/push.spec.ts#L412tarDirectory
: https://github.com/balena-io/balena-cli/blob/v12.55.4/tests/utils/tarDirectory.spec.ts#L92- "live push": https://github.com/balena-io/balena-cli/blob/v12.55.4/tests/utils/device/live.spec.ts#L230
I think these 3 tests pass on Windows because git clone
on Windows makes a real copy of the file that is pointed to by the symlink.
So, I think it would be fair to skip this test-data/projects/docker-compose/symbolic-links/service1
test case on Windows, for example with the itSkipWindows
trick.
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.
Looks like it's related to symlinks to folders on windows 🤔
I will skip it for now since I don't have the bandwith to further investigate this, and it already adds value as is.
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.
Oh wait, this might actually be a balena-lint bug :)
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.
I don't think so, the balena-lint issue was caused by the commit that added the itNoWin
call.
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.
This might work, based on the comments in that issue of glob
:
See: balena-io-modules/node-balena-lint#82
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.
Agrrrrr. I now fails is the test:source
step.
Should I just drop the tests to get this fixed sooner than later?
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.
See: #2410
And I will leave this PR having only the test case, just in case someone has the patience to fix them for Windows...
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.
Before dropping the tests, how about:
- Do not commit the
service1
soft link to the git repo. - Have the new test case (added by this PR) dynamically create (and clean up) the soft link with
fs.symlink
that you had suggested in Flowdock. - Re-add
itNoWin
to the test case so that the soft link is never created on Windows.
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.
During my research I saw ppl facing such issues when creating symlinks as well, but at this point it sounds more promising than the committed one. I will add a reminder for later this week.
Note for self:
See: balanced-mt/serverless-plugin-typescript@0f57f0c
6957e74
to
a67aaf4
Compare
Build failed quickly for all platforms because of missing
|
a67aaf4
to
1d2abb7
Compare
7e219c7
to
2ff0141
Compare
Change-type: patch See: https://www.flowdock.com/app/rulemotion/i-cli/threads/Yo53CeVqtfSoo4Dw_qO8B0ZD2Nu Signed-off-by: Thodoris Greasidis <[email protected]>
27a9c8b
to
989a2e3
Compare
Change-type: patch
See: https://www.flowdock.com/app/rulemotion/i-cli/threads/Yo53CeVqtfSoo4Dw_qO8B0ZD2Nu
Signed-off-by: Thodoris Greasidis [email protected]
Resolves: #
Change-type: major|minor|patch
Depends-on:
See:
Please check the CONTRIBUTING.md file for relevant information and some
guidance. Keep in mind that the CLI is a cross-platform application that runs
on Windows, macOS and Linux. Tests will be automatically run by balena CI on
all three operating systems, but this will only help if you have added test
code that exercises the modified or added feature code.
Note that each commit message (currently only the first line) will be
automatically copied to the CHANGELOG.md file, so try writing it in a way
that describes the feature or fix for CLI users.
If there isn't a linked issue or if the linked issue doesn't quite match the
PR, please add a PR description to explain its purpose or the features that it
implements. Adding PR comments to blocks of code that aren't self explanatory
usually helps with the review process.
If the PR introduces security considerations or affects the development, build
or release process, please be sure to highlight this in the PR description.
Thank you very much for your contribution!