exercism / go-test-runner

GNU Affero General Public License v3.0
15 stars 17 forks source link

Build extra Go packages into the docker image #84

Closed andrerfcsantos closed 1 year ago

andrerfcsantos commented 1 year ago

Similar to what other tracks already have, this builds extra Go packages into the docker image so students can use them in their solutions.

The list of packages was discussed here https://github.com/exercism/go/issues/2379

coveralls commented 1 year ago

Pull Request Test Coverage Report for Build 3256884287


Totals Coverage Status
Change from base Build 3184568547: 0.0%
Covered Lines: 388
Relevant Lines: 501

💛 - Coveralls
junedev commented 1 year ago

@andrerfcsantos Please don't merge yet. I have some input but didn't have the time to test it out yet.

andrerfcsantos commented 1 year ago

While considering alternatives, I tried to optimize for easy instructions, both for users and for maintainers.

I've also thought of making the external dependencies a dependency of the test runner, but ultimately decided against it because:

Some other considerations:

junedev commented 1 year ago

Thanks for clarifying your reasoning here.

While I understand the theoretical arguments, I don't think there is a very strong case.

Anyway, you can merge this if you want.

Re the "test" I added: It is not an actual test case for the test runner. It is really only an example that can be executed manually. I think CI does not execute the tests inside the final docker container so a normal test case executed via CI would not tell us whether the external dependency mgmt works. (@ErikSchierboom mentioned some kind of golden/end2end tests but I don't know how that was set up.)

andrerfcsantos commented 1 year ago

Thanks for explaining.

There are good points there.

I'll defer merging, maybe we should think about this a bit more.

ErikSchierboom commented 1 year ago

@junedev I don't think the golden tests are setup here. I would have expected a bin/run-tests-in-docker.sh file here: https://github.com/exercism/go-test-runner/tree/main/bin Adding golden tests should be fairly straightforward though:

  1. Copy the run-tests.sh and run-tests-in-docker.sh files from https://github.com/exercism/generic-test-runner/tree/main/bin
  2. Add a tests directory that contains sub-directories for the different types of scenarios you want to test. The way this works is to have these sub-directories be like regular exercises, but setup in a way to have a specific type of output. This output is then included in the sub-directory in the form of a expected_results.json file. I'd include the scenarios listed in https://github.com/exercism/generic-test-runner/tree/main/tests, but you'd also add an external packages example.
  3. Run the ./bin/run-tests-in-docker.sh file within your test.yml workflow: https://github.com/exercism/go-test-runner/blob/main/.github/workflows/test.yml (see https://github.com/exercism/generic-test-runner/blob/main/.github/workflows/ci.yml#L20)
andrerfcsantos commented 1 year ago

@junedev Updated the PR to use something similar to your version. The difference is that I kept the separate module for dependency management, as I think is cleaner this way. Let me know if this fully addresses your concerns or if there is something I overlooked. I think this is better indeed, so thanks for the feedback 👍

@ErikSchierboom Thanks for the summary!

@ErikSchierboom @junedev If that's ok by you, I'd be more comfortable with addressing the golden tests in a separate issue/PR. I added tests in this PR, but like june said, these tests are not running in CI anywhere as far as I can tell (I did run them locally using docker with no network access and they are passing). Maybe we can address running tests in CI together with the golden tests as they seem to be closely related tasks.

andrerfcsantos commented 1 year ago

I wonder about the term "extra packages". I have not really heard that before. Shouldn't it say "external" or "third-party" instead of "extra"?

External packages sound good, changed the naming to it.

You added 2 examples/tests now. Are they covering different aspects? If not, one would be enough.

The new test added uses code that imports golang.org/x/exp/contraints, so the idea here is to test if golang.org/x/exp is being built in the image. The idea is to have 1 test (at least) per external dependency supported.