Skip to content

Commit

Permalink
chore: no need to generate the ci.yml anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Nov 8, 2024
1 parent 0a387e9 commit b638baa
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 243 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# This file is autogenerated by the 'modulegen' tool.
# Please update the 'ci.yml' template instead.
name: Main pipeline

on:
Expand Down
145 changes: 0 additions & 145 deletions modulegen/_template/ci.yml.tmpl

This file was deleted.

6 changes: 2 additions & 4 deletions modulegen/internal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/testcontainers/testcontainers-go/modulegen/internal/sonar"
"github.com/testcontainers/testcontainers-go/modulegen/internal/tools"
"github.com/testcontainers/testcontainers-go/modulegen/internal/vscode"
"github.com/testcontainers/testcontainers-go/modulegen/internal/workflow"
)

func Generate(moduleVar context.TestcontainersModuleVar, isModule bool) error {
Expand Down Expand Up @@ -82,9 +81,8 @@ func GenerateFiles(ctx context.Context, tcModule context.TestcontainersModule) e
// not in the new module to be added, that's why they happen after the actual
// module generation
projectGenerators := []ProjectGenerator{
workflow.Generator{}, // update github ci workflow
vscode.Generator{}, // update vscode workspace
sonar.Generator{}, // update sonar-project.properties
vscode.Generator{}, // update vscode workspace
sonar.Generator{}, // update sonar-project.properties
}

for _, generator := range projectGenerators {
Expand Down
40 changes: 0 additions & 40 deletions modulegen/internal/workflow/main.go

This file was deleted.

17 changes: 0 additions & 17 deletions modulegen/internal/workflow/types.go

This file was deleted.

34 changes: 0 additions & 34 deletions modulegen/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,11 @@ func TestGenerate(t *testing.T) {
tmpCtx := context.New(t.TempDir())
examplesTmp := filepath.Join(tmpCtx.RootDir, "examples")
examplesDocTmp := filepath.Join(tmpCtx.DocsDir(), "examples")
githubWorkflowsTmp := tmpCtx.GithubWorkflowsDir()

err := os.MkdirAll(examplesTmp, 0o777)
require.NoError(t, err)
err = os.MkdirAll(examplesDocTmp, 0o777)
require.NoError(t, err)
err = os.MkdirAll(githubWorkflowsTmp, 0o777)
require.NoError(t, err)

err = copyInitialMkdocsConfig(t, tmpCtx)
require.NoError(t, err)
Expand Down Expand Up @@ -283,12 +280,7 @@ func TestGenerate(t *testing.T) {
_, err = os.Stat(moduleDocFile)
require.NoError(t, err) // error nil implies the file exist

mainWorkflowFile := filepath.Join(githubWorkflowsTmp, "ci.yml")
_, err = os.Stat(mainWorkflowFile)
require.NoError(t, err) // error nil implies the file exist

assertModuleDocContent(t, module, moduleDocFile)
assertModuleGithubWorkflowContent(t, mainWorkflowFile)

generatedTemplatesDir := filepath.Join(examplesTmp, moduleNameLower)
// do not generate examples_test.go for examples
Expand All @@ -303,14 +295,11 @@ func TestGenerateModule(t *testing.T) {
tmpCtx := context.New(t.TempDir())
modulesTmp := filepath.Join(tmpCtx.RootDir, "modules")
modulesDocTmp := filepath.Join(tmpCtx.DocsDir(), "modules")
githubWorkflowsTmp := tmpCtx.GithubWorkflowsDir()

err := os.MkdirAll(modulesTmp, 0o777)
require.NoError(t, err)
err = os.MkdirAll(modulesDocTmp, 0o777)
require.NoError(t, err)
err = os.MkdirAll(githubWorkflowsTmp, 0o777)
require.NoError(t, err)

err = copyInitialMkdocsConfig(t, tmpCtx)
require.NoError(t, err)
Expand Down Expand Up @@ -339,12 +328,7 @@ func TestGenerateModule(t *testing.T) {
_, err = os.Stat(moduleDocFile)
require.NoError(t, err) // error nil implies the file exist

mainWorkflowFile := filepath.Join(githubWorkflowsTmp, "ci.yml")
_, err = os.Stat(mainWorkflowFile)
require.NoError(t, err) // error nil implies the file exist

assertModuleDocContent(t, module, moduleDocFile)
assertModuleGithubWorkflowContent(t, mainWorkflowFile)

generatedTemplatesDir := filepath.Join(modulesTmp, moduleNameLower)
assertExamplesTestContent(t, module, filepath.Join(generatedTemplatesDir, "examples_test.go"))
Expand Down Expand Up @@ -439,24 +423,6 @@ func assertModuleContent(t *testing.T, module context.TestcontainersModule, exam
require.Equal(t, "\treturn c, nil", data[41])
}

// assert content GitHub workflow for the module
func assertModuleGithubWorkflowContent(t *testing.T, moduleWorkflowFile string) {
t.Helper()
content, err := os.ReadFile(moduleWorkflowFile)
require.NoError(t, err)

data := sanitiseContent(content)
ctx := getTestRootContext(t)

modulesList, err := ctx.GetModules()
require.NoError(t, err)
assert.Equal(t, " module: ["+strings.Join(modulesList, ", ")+"]", data[96])

examplesList, err := ctx.GetExamples()
require.NoError(t, err)
assert.Equal(t, " module: ["+strings.Join(examplesList, ", ")+"]", data[111])
}

// assert content go.mod
func assertGoModContent(t *testing.T, module context.TestcontainersModule, tcVersion string, goModFile string) {
t.Helper()
Expand Down
1 change: 0 additions & 1 deletion scripts/bump-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ function main() {
for f in $(find "${ROOT_DIR}/.github/workflows" -name "*.yml"); do
bumpCIMatrix "${f}" "${escapedCurrentGoVersion}" "${escapedGoVersion}"
done
bumpCIMatrix "${ROOT_DIR}/modulegen/_template/ci.yml.tmpl" "${escapedCurrentGoVersion}" "${escapedGoVersion}"

# bump devcontainer file
bumpDevcontainer "${ROOT_DIR}/.devcontainer/devcontainer.json" "${escapedCurrentGoVersion}" "${escapedGoVersion}"
Expand Down

0 comments on commit b638baa

Please sign in to comment.