Skip to content

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 4 commits into from
Jul 4, 2018
Merged

Use BATS for image testing #802

merged 4 commits into from
Jul 4, 2018

Conversation

chorrell
Copy link
Contributor

@chorrell chorrell commented Jul 1, 2018

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-tests

Also 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 a docker run command. I also did a bit of refactoring and added some new functions.

@chorrell chorrell requested a review from a team July 1, 2018 01:02
SimenB

This comment was marked as off-topic.

LaurentGoderre

This comment was marked as off-topic.

LaurentGoderre

This comment was marked as off-topic.

@chorrell
Copy link
Contributor Author

chorrell commented Jul 3, 2018

@nodejs/docker This good to merge now?

@LaurentGoderre
Copy link
Member

I would say so!

PeterDaveHello

This comment was marked as off-topic.

@PeterDaveHello PeterDaveHello merged commit b3fe000 into master Jul 4, 2018
@PeterDaveHello PeterDaveHello deleted the bats branch July 4, 2018 14:39
@PeterDaveHello
Copy link
Member

The next step would be the integration the tests with Travis CI?

@chorrell
Copy link
Contributor Author

chorrell commented Jul 4, 2018

What do you mean?

@PeterDaveHello
Copy link
Member

I guess we could also use BATS to test our shell scripts, to prevent some regression issues, and make sure the behavior.

@chorrell
Copy link
Contributor Author

chorrell commented Jul 4, 2018

Sure!

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants