Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
noamcattan committed Oct 3, 2023
1 parent 216027e commit 7677ebb
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 23 deletions.
5 changes: 2 additions & 3 deletions gen/atlas.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ jobs:
{{- with .DirName }}
dir-name: '{{ . }}'
{{- end }}
{{ template "UseServices" (args .Driver "localhost") }}
{{ template "UseServices" . }}
- uses: ariga/atlas-action/migrate/push@master
if: github.ref == 'refs/heads/master'
with:
dir: 'file://{{ .Path }}'
{{- with .DirName }}
dir-name: '{{ . }}'
{{- end }}
{{ template "UseServices" (args .Driver "localhost") }}
cloud-token: {{`${{ secrets.`}}{{ .SecretName }}{{` }}`}}
{{ template "UseServices" . }}
7 changes: 0 additions & 7 deletions gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,9 @@ var (
files embed.FS

tmpl = template.Must(template.New("atlas-sync-action").
Funcs(argsFunc()).
ParseFS(files, "*.tmpl"))
)

func argsFunc() template.FuncMap {
return template.FuncMap{"args": func(els ...any) []any {
return els
}}
}

// Generate the content of the atlas ci lint yaml.
func Generate(cfg *Config) ([]byte, error) {
if err := validateDriver(cfg.Driver); err != nil {
Expand Down
16 changes: 7 additions & 9 deletions gen/services.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,13 @@
{{- end }}

{{- define "UseServices" }}
{{- $Driver := index . 0 }}
{{- $Host := index . 1 }}
{{- if eq $Driver "mysql" -}}
dev-url: 'mysql://root:pass@{{- $Host }}:3306/dev'
{{- else if eq $Driver "postgres" -}}
dev-url: 'postgres://postgres:pass@{{- $Host }}:5432/dev?search_path=public&sslmode=disable'
{{- else if eq $Driver "mariadb" -}}
dev-url: 'maria://root:pass@{{- $Host }}:3306/dev'
{{- else if eq $Driver "sqlite" -}}
{{- if eq .Driver "mysql" -}}
dev-url: 'mysql://root:pass@localhost:3306/dev'
{{- else if eq .Driver "postgres" -}}
dev-url: 'postgres://postgres:pass@localhost:5432/dev?search_path=public&sslmode=disable'
{{- else if eq .Driver "mariadb" -}}
dev-url: 'maria://root:pass@localhost:3306/dev'
{{- else if eq .Driver "sqlite" -}}
dev-url: 'sqlite://dev?mode=memory'
{{- end -}}
{{- end -}}
2 changes: 1 addition & 1 deletion gen/testdata/mariadb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- master
paths:
- .github/workflows/ci-atlas.yaml
- 'migrations/*'
pull_request:
paths:
Expand Down Expand Up @@ -48,4 +49,3 @@ jobs:
dir: 'file://migrations'
dir-name: 'name'
dev-url: 'maria://root:pass@localhost:3306/dev'
cloud-token: ${{ secrets.ATLAS_CLOUD_TOKEN }}
2 changes: 1 addition & 1 deletion gen/testdata/mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- master
paths:
- .github/workflows/ci-atlas.yaml
- 'migrations/*'
pull_request:
paths:
Expand Down Expand Up @@ -48,4 +49,3 @@ jobs:
dir: 'file://migrations'
dir-name: 'name'
dev-url: 'mysql://root:pass@localhost:3306/dev'
cloud-token: ${{ secrets.ATLAS_CLOUD_TOKEN }}
2 changes: 1 addition & 1 deletion gen/testdata/postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- master
paths:
- .github/workflows/ci-atlas.yaml
- 'migrations/*'
pull_request:
paths:
Expand Down Expand Up @@ -48,4 +49,3 @@ jobs:
dir: 'file://migrations'
dir-name: 'name'
dev-url: 'postgres://postgres:pass@localhost:5432/dev?search_path=public&sslmode=disable'
cloud-token: ${{ secrets.ATLAS_CLOUD_TOKEN }}
2 changes: 1 addition & 1 deletion gen/testdata/sqlite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- master
paths:
- .github/workflows/ci-atlas.yaml
- 'migrations/*'
pull_request:
paths:
Expand Down Expand Up @@ -33,4 +34,3 @@ jobs:
dir: 'file://migrations'
dir-name: 'name'
dev-url: 'sqlite://dev?mode=memory'
cloud-token: ${{ secrets.ATLAS_CLOUD_TOKEN }}

0 comments on commit 7677ebb

Please sign in to comment.