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

Store experiments in contexts #2316

Merged
merged 4 commits into from
Aug 24, 2023
Merged

Store experiments in contexts #2316

merged 4 commits into from
Aug 24, 2023

Conversation

DrJosh9000
Copy link
Contributor

@DrJosh9000 DrJosh9000 commented Aug 23, 2023

The main change is to associate experiments with contexts (as values). Enabling or disabling an experiment creates a new context.

Most code has context plumbed through correctly, so adopting it wasn't too hard. The bulk of the updates are to tests.

But now that experiments is not a "global variable", we can parallelise more tests!

@DrJosh9000 DrJosh9000 force-pushed the experiments-in-context branch 3 times, most recently from e90c6e3 to c9c238c Compare August 23, 2023 02:11
@DrJosh9000 DrJosh9000 changed the title WIP: Store experiments in contexts Store experiments in contexts Aug 23, 2023
@DrJosh9000 DrJosh9000 force-pushed the experiments-in-context branch 2 times, most recently from e39c123 to 95fa8de Compare August 23, 2023 02:19
@DrJosh9000 DrJosh9000 marked this pull request as ready for review August 23, 2023 02:20
@DrJosh9000 DrJosh9000 requested a review from a team August 23, 2023 02:20
@DrJosh9000
Copy link
Contributor Author

This is ready, if anyone wants to poke at it.

@DrJosh9000 DrJosh9000 force-pushed the experiments-in-context branch from 95fa8de to 1bbe285 Compare August 23, 2023 23:52
Copy link
Contributor

@triarius triarius left a comment

Choose a reason for hiding this comment

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

This makes me so happy!

Just mainly, I think the move to internal can happen now. It's supposedly imported by ~~~2~~ 4 libraries, but that just looks like a fork of the agent.

Even if it's imported by real modules, there's legitimate reason modules outside the agent to use it.

clicommand/global.go Outdated Show resolved Hide resolved
experiments/experiments.go Outdated Show resolved Hide resolved
@@ -29,10 +29,10 @@ var commitPattern = bintest.MatchPattern(`(?ms)\Acommit [0-9a-f]+\nabbrev-commit
const gitShowFormatArg = "--format=commit %H%nabbrev-commit %h%nAuthor: %an <%ae>%n%n%w(0,4,4)%B"

func TestWithResolvingCommitExperiment(t *testing.T) {
// t.Parallel() cannot be used with experiments.Enable()
defer experiments.EnableWithUndo(experiments.ResolveCommitAfterCheckout)()
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh yeah, not needing this is a win too!

// This context needs to be stored here in order to pass experiments to tests,
// because testing.M can only Run (without passing arguments or context).
// In ordinary code, pass contexts as arguments!
var mainCtx = context.Background()
Copy link
Contributor

Choose a reason for hiding this comment

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

☹️

@DrJosh9000 DrJosh9000 force-pushed the experiments-in-context branch from 1bbe285 to a599ede Compare August 24, 2023 00:20
It was missing `tc := tc` in the loop. With that added,
`post-checkout` failed consistently rather than rarely.
(Looks like `post-checkout` shouldn't upload the artifact.)
@DrJosh9000 DrJosh9000 force-pushed the experiments-in-context branch from a599ede to 5be1f98 Compare August 24, 2023 00:23
Copy link
Contributor

@triarius triarius left a comment

Choose a reason for hiding this comment

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

💜

@DrJosh9000 DrJosh9000 enabled auto-merge August 24, 2023 00:31
@DrJosh9000 DrJosh9000 merged commit 59dd492 into main Aug 24, 2023
@DrJosh9000 DrJosh9000 deleted the experiments-in-context branch August 24, 2023 00:42
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.

2 participants