-
Notifications
You must be signed in to change notification settings - Fork 2k
Use BATS for image testing #802
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
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Switches testing to the BATS testing framework: https://github.com/bats-core/bats-core
@nodejs/docker This good to merge now? |
I would say so! |
The next step would be the integration the tests with Travis CI? |
What do you mean? |
I guess we could also use BATS to test our shell scripts, to prevent some regression issues, and make sure the behavior. |
Sure! |
This was referenced Oct 20, 2021
MasonM
added a commit
to MasonM/docker-node
that referenced
this pull request
Oct 23, 2021
BATS was initially added to this repository in nodejs#802, but was then removed in nodejs#1339. This adds it back, and hooks it up to Github Actions.
MasonM
added a commit
to MasonM/docker-node
that referenced
this pull request
Oct 23, 2021
BATS was initially added to this repository in nodejs#802, but was then removed in nodejs#1339. This adds it back, and hooks it up to Github Actions. This also fixes nodejs#1583, which happened due to a bug in the "Build image" step: the build context was set to the root project directory, which meant the `COPY docker-entrypoint.sh /usr/local/bin/` instruction was copying the base `docker-entrypoint.sh` file into the Docker image instead of the one in the variant directory. Changing the context to the variant directory solves that.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This switches the current tests to the BATS testing framework:
https://github.com/bats-core/bats-core
Longer term this will allow us to add more sophisticated tests for the images using a TAP-compliant testing framework. Eventually we can start introducing some more basic tests for Node as well as npm and yarn. The Travis-Ci build instances have BATS preinstalled and it defaults to showing the results in TAP format, which might be useful.
I've been wanting to do this for a while but it wasn't until I was working on a proposal/branch for the "core" variant (the node image without yarn or npm) that I decided to finally take this on. I needed a way to skip the npm and yarn tests for the "core" image which meant I would have to make significant changes to the current
test-image.sh
approach. Given the effort involved to do that, it seemed like a good opportunity to try BATS since it already provides a way to skip tests conditionally: https://github.com/bats-core/bats-core#skip-easily-skip-testsAlso note that in this PR I'm changing how we run the tests. Previously the tests were run by mounting the
test-image.sh
script in the target container. In order to work with the Alpine image each test is now run as a part of adocker run
command. I also did a bit of refactoring and added some new functions.