Skip to content
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

Implement a basic Roc test runner #4

Merged
merged 22 commits into from
Aug 22, 2024

Conversation

ageron
Copy link
Contributor

@ageron ageron commented Aug 21, 2024

This PR implements a basic test runner for Roc:

  • Dockerfile is based on debian:latest, it installs Roc and runs download-basic-cli.roc to ensure the basic-cli platform is in Roc's cache (since the container will run without network access)
  • bin/run.sh runs roc test ... and captures the output. It sanitises it (i.e., normalises) by removing timing output (e.g., "in 123 ms.").
  • If the tests succeed, then result.json will contain {version: 1, status: "pass"}. If the tests fail, then if the sanitised output contains -- EXPECT FAILED in or -- EXPECT PANICKED in , then result.json will contain status="fail", or else it will contain status="error" (which means that none of the tests could run).
  • tests/{slug}/{slug}-test.roc for slug in all-fail, empty-file, partial-fail, success, and syntax-error, implement a very basic test for each of these basic scenarios. The corresponding expected output is in tests/{slug}/expected_results.json.

@ageron ageron requested a review from a team as a code owner August 21, 2024 21:05
@ageron
Copy link
Contributor Author

ageron commented Aug 21, 2024

Mmmh, the tests pass on my machine (using podman on MacOS), but they seem to fail here with a weird DlOpen error (failed to map segment from shared object). Investigating...

Dockerfile Outdated
@@ -1,8 +1,23 @@
FROM alpine:3.18
FROM debian:latest
Copy link
Member

Choose a reason for hiding this comment

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

Can we pin this to a specific Debian version? If feasible, it might be better to use an Alpine image to reduce the overall image size. That'll save Exercism money since we're deploying 71+ different Docker images to each test runner machine in the cloud.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can definitely pin this to debian:bookworm instead. However, I tried using alpine, but Roc failed, probably because I need to install some libraries. I'll start with debian:bookworm, and I'll switch to alpine asap.

Copy link
Member

Choose a reason for hiding this comment

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

If Alpine doesn't work out, that's fine. It's just a nice starting point for reducing file size, but I don't believe all tracks can use Alpine images due to some limitations in what's available.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Trying to solve the DlOpen error (see above), I've switched to Ubuntu 22.24. Still works fine on my machine but fails in Github CI. I think it might be a permission issue on the /tmp folder (see this SO answer).

Copy link
Member

Choose a reason for hiding this comment

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

What I know about Docker or Github CI can fit in a thimble, but Erik can probably help you out further. He's pretty handy. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked into migrating to Alpine, but Roc is currently built on glibc whereas Alpine uses musl. There's an ongoing effort to make Roc support musl, so we should be able to migrate to Alpine once that work is completed.

@ageron
Copy link
Contributor Author

ageron commented Aug 21, 2024

The DlOpen error (failed to map segment from shared object) is probably due to a permission issue with the /tmp folder (see this SO answer). Have you see this before? It might be possible to fix it by creating our own tmp folder and pointing TMPDIR to it, since Github action's /tmp folder does not seem to be writable (not sure about this).

@ageron
Copy link
Contributor Author

ageron commented Aug 22, 2024

I'm really stumped by the DlOpen error. I've tried many things now, and it still fails on Github Actions, while the same Docker container works just fine on my machine. 😢 I've asked the Roc community for some help. Please let me know if you have any idea of what this could be. Perhaps AppArmor is activated on the host and is blocking something?

@ErikSchierboom
Copy link
Member

This is an impressive PR, well done! I've just pushed a commit to fix the tmp folder issue. CI still fails though

@ageron
Copy link
Contributor Author

ageron commented Aug 22, 2024

Thanks @ErikSchierboom !
I've tried compiling Roc from the latest source code, and it actually solved the problem, hurray, I was going nuts.
The Roc devs are planning to make a new release very shortly, so we won't have to use my version more than a week or so.

@ageron
Copy link
Contributor Author

ageron commented Aug 22, 2024

Great, the tests finally pass! 👍
Note that the Dockerfile currently downloads the latest release from the official github repo, but then it replaces the roc executable with the version I compiled from the latest source (which I uploaded to my ageron/prototype-roc-test-runner repo). When the Roc devs publish the next release, I'll remove this part of the Dockerfile.

@ageron ageron merged commit 81b41be into exercism:main Aug 22, 2024
1 check passed
@ageron ageron deleted the basic-roc-test-runner branch August 22, 2024 10:21
@ageron
Copy link
Contributor Author

ageron commented Aug 22, 2024

Thanks for your help @ErikSchierboom

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.

3 participants