Refactor project to improve local dev and testing experience #11
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.
Although we've added some features in the intervening years, most of the relay code was written in 2019, and the state of Go development at that time was much different. Go modules were extremely new and we hadn't yet adopted them. IDE support for Go was in a much different state than it is today. Even our approaches to testing were different.
Right now the relay is receiving renewed focus, and that has made it clear that the local development and testing experience is now out of step with the rest of our code base. This PR makes a number of changes that bring the relay code into more alignment with our modern development approaches, with the aim of improving developer productivity when working on this code. Although there are more improvements we could make down the line, the changes in this PR address a lot of the low hanging fruit:
go/src
up to the top level of the repo.relay_test.go
file containing all unit tests, each individual plugin package now has its own set of tests. This is more sustainable as the number of plugins and tests increases. It also fixes a frustrating issue with the previous setup: because of the plugin architecture the relay uses, there was no actual source dependency between the plugins and the tests, sogo test
could get confused and use a cached version of the test output even when the plugins had changed. With the new arrangement, this won't happen anymore..env
. Previously, plugins read environment variables directly, making isolating the tests quite challenging and making it impossible to run the tests in parallel.It's a bit unfortunate that all of these changes are bundled into a single PR. It would be possible to tease them apart with enough effort, but there are dependencies between many of these changes - just as one example, the new plugin interface references types exposed by the relay code, but in the pre-Go-modules version of the code base it wasn't possible to do this, because the Go runtime could not tell that the type referenced in the plugin and the type referenced in the core relay code were the same type, so casting the plugin to an instance of the plugin interface would fail. (It's quite possible that there was a way to fix this in a GOPATH-based build, but I couldn't figure out how to do it.) The work involved in separating things out didn't seem worth it in this case, though I'm happy to revisit that if you feel differently @eugene-chang-fs.
Because of the introduction of the factory-based plugin interface and the transition to Go modules, this PR technically makes functional changes, but they're minor; these changes are mostly only visible to developers working on the project.