Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
Fix generated GitLab ci YAML (#2086)
Browse files Browse the repository at this point in the history
* gitlab-ci: Default to Golang 1.15

Given the policy by the golang team to support and maintain only the
latest two Go releases defaulting to Go 1.8 effectily made buffalo test
with a EOL'ed Golang.

This change defaults to 1.15, and allows the user to switch to 1.16 with
the already present latest switch.

* gitlab-ci: Leverage gomodules over GOPATH

Prior to this change, the `.gitlab-ci.yml` linked the directories so
that GOPATH would work. Given buffalo now always uses gomodules these
steps are no longer required, and currently even break the pipeline
created from the generated CI definitions.

By just executing the job in the `/builds` subdirectory gomodules work
as expected again.

* gitlab-ci: Update postgres connection details

Docker links the containers differently than was priorly assumed for
GitLab CI. As such the out-of-the-box settings weren't properly working.
This change resolves that in the CI YAML definitions to isolate the
changes from local setups.
  • Loading branch information
ZJvandeWeg authored Mar 11, 2021
1 parent 9b96319 commit b3c3975
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
9 changes: 3 additions & 6 deletions genny/ci/templates/-dot-gitlab-ci-no-pop.yml.tmpl
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
before_script:
- ln -s /builds /go/src/$(echo "{{.opts.App.PackagePkg}}" | cut -d "/" -f1)
- cd /go/src/{{.opts.App.PackagePkg}}
- mkdir -p public/assets
- go get -u github.com/gobuffalo/buffalo/buffalo
- go mod download
- export PATH="$PATH:$GOPATH/bin"

stages:
- test
Expand All @@ -17,12 +14,12 @@ stages:
.use-golang-image: &use-golang-latest
image: golang:latest

.use-golang-image: &use-golang-1-8
image: golang:1.8
.use-golang-image: &use-golang-1-15
image: golang:1.15

test:
# Change to "<<: *use-golang-latest" to use the latest Go version
<<: *use-golang-1-8
<<: *use-golang-1-15
<<: *test-vars
stage: test
script:
Expand Down
15 changes: 8 additions & 7 deletions genny/ci/templates/-dot-gitlab-ci.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ before_script:
{{- else if eq .opts.DBType "mysql" }}
- apt-get update && apt-get install -y mysql-client
{{- end }}
- ln -s /builds /go/src/$(echo "{{.opts.App.PackagePkg}}" | cut -d "/" -f1)
- cd /go/src/{{.opts.App.PackagePkg}}
- mkdir -p public/assets
- go get -u github.com/gobuffalo/buffalo/buffalo
- go mod download
- export PATH="$PATH:$GOPATH/bin"

stages:
- test
Expand All @@ -19,22 +16,26 @@ stages:
GO_ENV: "test"
{{- if eq .opts.DBType "postgres" }}
POSTGRES_DB: "{{.opts.App.Name.File}}_test"
POSTGRES_USER: runner
POSTGRES_PASSSWORD: ""
POSTGRES_HOST_AUTH_METHOD: trust
TEST_DATABASE_URL: "postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?sslmode=disable"
{{- else if eq .opts.DBType "mysql" }}
MYSQL_DATABASE: "{{.opts.App.Name.File}}_test"
MYSQL_ROOT_PASSWORD: "root"
{{- end }}
TEST_DATABASE_URL: "{{.testDbUrl}}"
{{- end }}

# Golang version choice helper
.use-golang-image: &use-golang-latest
image: golang:latest

.use-golang-image: &use-golang-1-8
image: golang:1.8
.use-golang-image: &use-golang-1-15
image: golang:1.15

test:
# Change to "<<: *use-golang-latest" to use the latest Go version
<<: *use-golang-1-8
<<: *use-golang-1-15
<<: *test-vars
stage: test
services:
Expand Down

0 comments on commit b3c3975

Please sign in to comment.