Skip to content

Commit

Permalink
add postgres to gh actions generator
Browse files Browse the repository at this point in the history
Signed-off-by: Kristoffer Dalby <[email protected]>
  • Loading branch information
kradalby committed Feb 15, 2024
1 parent 43b4255 commit e162e84
Showing 1 changed file with 29 additions and 17 deletions.
46 changes: 29 additions & 17 deletions cmd/gh-action-integration-generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ jobs:
--volume $PWD:$PWD -w $PWD/integration \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume $PWD/control_logs:/tmp/control \
--env HEADSCALE_INTEGRATION_POSTGRES={{ if .Postgres }}1{{ else }}0{{ end }} \
golang:1 \
go run gotest.tools/gotestsum@latest -- ./... \
-failfast \
-timeout 120m \
-parallel 1 \
-run "^{{.Name}}$"
-run "^{{.Test}}$"
- uses: actions/upload-artifact@v3
if: always() && steps.changed-files.outputs.any_changed == 'true'
Expand Down Expand Up @@ -145,29 +146,40 @@ func findTests() []string {

func main() {
type testConfig struct {
Name string
Name string
Test string
Postgres bool
}

tests := findTests()

removeTests()

for _, test := range tests {
log.Printf("generating workflow for %s", test)

var content bytes.Buffer

if err := jobTemplate.Execute(&content, testConfig{
Name: test,
}); err != nil {
log.Fatalf("failed to render template: %s", err)
}

testPath := path.Join(githubWorkflowPath, fmt.Sprintf(jobFileNameTemplate, test))

err := os.WriteFile(testPath, content.Bytes(), workflowFilePerm)
if err != nil {
log.Fatalf("failed to write github job: %s", err)
for _, postgres := range []bool{false, true} {
log.Printf("generating workflow for %s", test)

name := test
if postgres {
name = test + "-postgres"
}

var content bytes.Buffer

if err := jobTemplate.Execute(&content, testConfig{
Name: name,
Test: test,
Postgres: postgres,
}); err != nil {
log.Fatalf("failed to render template: %s", err)
}

testPath := path.Join(githubWorkflowPath, fmt.Sprintf(jobFileNameTemplate, name))

err := os.WriteFile(testPath, content.Bytes(), workflowFilePerm)
if err != nil {
log.Fatalf("failed to write github job: %s", err)
}
}
}
}

0 comments on commit e162e84

Please sign in to comment.