Skip to content

Commit

Permalink
Handle workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
blampe committed Dec 19, 2024
1 parent 77f5bc6 commit b55398b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions provider-ci/internal/pkg/migrations/consolidate_modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ func (consolidateModules) Migrate(_, outDir string) error {
if _, err := run("git", "mv", "-f", "provider/go.sum", "go.sum"); err != nil {
return fmt.Errorf("moving provider/go.sum: %w", err)
}
// Update our workspace, if it exists. It's OK if these fail.
_, _ = run("go", "work", "edit", "-dropuse=./provider")
_, _ = run("go", "work", "edit", "-use=./")

// Load the module as JSON.
out, err := run("go", "mod", "edit", "-json", "go.mod")
Expand Down Expand Up @@ -91,6 +94,8 @@ func (consolidateModules) Migrate(_, outDir string) error {
_, _ = run("git", "rm", "examples/go.sum")
_, _ = run("git", "rm", "tests/go.mod")
_, _ = run("git", "rm", "tests/go.sum")
_, _ = run("go", "work", "edit", "-dropuse=./examples")
_, _ = run("go", "work", "edit", "-dropuse=./tests")

// Rewrite our module path and determine our new import, if it's changed.
//
Expand Down
2 changes: 1 addition & 1 deletion provider-ci/internal/pkg/migrations/migrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func assertDirectoryContains(t *testing.T, dir1, dir2 string) {
}

stat, err := os.Stat(filepath.Join(dir1, entry.Name()))
assert.NoError(t, err)
require.NoError(t, err)
assert.Equal(t, entry.IsDir(), stat.IsDir())

subPath1 := filepath.Join(dir1, entry.Name())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
go 1.23.3

use (
./examples
./provider
./tests
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
go 1.23.3

use ./

0 comments on commit b55398b

Please sign in to comment.