-
-
Notifications
You must be signed in to change notification settings - Fork 603
chore: readd dependabot, including a way to refresh the project files for all the modules #2997
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
Merged
mdelapenya
merged 26 commits into
testcontainers:main
from
mdelapenya:bring-back-dependabot
Mar 11, 2025
Merged
Changes from 23 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
336225b
chore: bring back dependabot generation
mdelapenya 15ef34b
chore: replace assert with require
mdelapenya 854a005
feat: add a modulegen command to refresh the project files
mdelapenya 96d2fb6
chore: exclude compose from the mkdocs nav entries
mdelapenya 39c813e
fix: remove extra comma after refresh
mdelapenya 79668fb
chore: readd dependabot updates
mdelapenya ef5785d
fix: lint
mdelapenya 3147018
chore: wrap errors in dependabot files
mdelapenya 12edc06
docs: document new types and functions
mdelapenya 3242f71
chore: simplify types merging generator and refresher
mdelapenya 4876835
chore: include modulegen in dependabot
mdelapenya 96c282f
chore: check modulegen is included in the dependabot updates
mdelapenya 25a1dce
docs: document new command
mdelapenya aff348c
chore: exclude dependabot changes from the build pipeline
mdelapenya b28f115
fix: lint
mdelapenya 43a4884
chore: wrap errors and add docs
mdelapenya e6d1327
chore: simplify dependabot config to use directories instead of one e…
mdelapenya 50185af
chore: use filepath
mdelapenya 05062d8
chore: more wrap errors
mdelapenya bfedc43
docs: be explicit
mdelapenya aeadc83
chore: more filepaths to fix WIndows tests
mdelapenya aadeaac
fix: module path uses slashes
mdelapenya 9064bdf
fix: test
mdelapenya d061059
chore: dependabot must follow unix file path separator
mdelapenya f703bde
Merge branch 'main' into bring-back-dependabot
mdelapenya 29cb0fa
Merge branch 'main' into bring-back-dependabot
mdelapenya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "runtime" | ||
| "slices" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/testcontainers/testcontainers-go/modulegen/internal/context" | ||
| "github.com/testcontainers/testcontainers-go/modulegen/internal/dependabot" | ||
| ) | ||
|
|
||
| // isWindows returns if the current OS is Windows. For that it checks the GOOS environment variable or the runtime.GOOS constant. | ||
| func isWindows() bool { | ||
| return os.Getenv("GOOS") == "windows" || runtime.GOOS == "windows" | ||
| } | ||
|
|
||
| func TestGetDependabotConfigFile(t *testing.T) { | ||
| if isWindows() { | ||
| t.Skip("skipping on windows because the dependabot config file uses the '/' separator") | ||
| } | ||
|
|
||
| ctx := context.New(filepath.Join(t.TempDir(), "testcontainers-go")) | ||
|
|
||
| githubDir := ctx.GithubDir() | ||
| cfgFile := ctx.DependabotConfigFile() | ||
| err := os.MkdirAll(githubDir, 0o777) | ||
| require.NoError(t, err) | ||
|
|
||
| err = os.WriteFile(cfgFile, []byte{}, 0o777) | ||
| require.NoError(t, err) | ||
|
|
||
| file := ctx.DependabotConfigFile() | ||
| require.NotNil(t, file) | ||
|
|
||
| require.True(t, strings.HasSuffix(file, filepath.Join("testcontainers-go", ".github", "dependabot.yml"))) | ||
| } | ||
|
|
||
| func TestExamplesHasDependabotEntry(t *testing.T) { | ||
| if isWindows() { | ||
| t.Skip("skipping on windows because the dependabot config file uses the '/' separator") | ||
| } | ||
|
|
||
| testProject := copyInitialProject(t) | ||
|
|
||
| examples, err := testProject.ctx.GetExamples() | ||
| require.NoError(t, err) | ||
| dependabotUpdates, err := dependabot.GetUpdates(testProject.ctx.DependabotConfigFile()) | ||
| require.NoError(t, err) | ||
|
|
||
| // should be the second item in the updates | ||
| gomodUpdate := dependabotUpdates[1] | ||
|
|
||
| require.Equal(t, "monthly", gomodUpdate.Schedule.Interval) | ||
|
|
||
| // all example modules exist in the dependabot updates | ||
| for _, example := range examples { | ||
| dependabotDir := filepath.Join(string(filepath.Separator), "examples", example) | ||
| require.True(t, slices.Contains(gomodUpdate.Directories, dependabotDir), "example %s is not present in the dependabot updates", example) | ||
| } | ||
| } | ||
|
|
||
| func TestModulesHasDependabotEntry(t *testing.T) { | ||
| if isWindows() { | ||
| t.Skip("skipping on windows because the dependabot config file uses the '/' separator") | ||
| } | ||
|
|
||
| testProject := copyInitialProject(t) | ||
|
|
||
| modules, err := testProject.ctx.GetModules() | ||
| require.NoError(t, err) | ||
| dependabotUpdates, err := dependabot.GetUpdates(testProject.ctx.DependabotConfigFile()) | ||
| require.NoError(t, err) | ||
|
|
||
| // should be the second item in the updates | ||
| gomodUpdate := dependabotUpdates[1] | ||
|
|
||
| require.Equal(t, "monthly", gomodUpdate.Schedule.Interval) | ||
|
|
||
| // all modules exist in the dependabot updates | ||
| for _, module := range modules { | ||
| dependabotDir := filepath.Join(string(filepath.Separator), "modules", module) | ||
| require.True(t, slices.Contains(gomodUpdate.Directories, dependabotDir), "modules %s is not present in the dependabot updates", modules) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,14 @@ | ||
| package context | ||
|
|
||
| // TestcontainersModuleVar is a struct that contains the name, title and image of a testcontainers module. | ||
| // It's used to hold the input values from the command line. | ||
| type TestcontainersModuleVar struct { | ||
| Name string | ||
| // Name is the name of the module. | ||
| Name string | ||
|
|
||
| // NameTitle is the title of the module. | ||
| NameTitle string | ||
| Image string | ||
|
|
||
| // Image is the image of the module. | ||
| Image string | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.