Skip to content

Commit

Permalink
Merge pull request #3 from FindHotel/sc-73628-migrate-terraform-provi…
Browse files Browse the repository at this point in the history
…der-sql-to-github

replace travis with gh actions
  • Loading branch information
Link512 committed Mar 22, 2023
2 parents 840c250 + 9313b9e commit 1045f4a
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 47 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
on:
push:
tags:
- "*"
name: Release

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.16.x

- name: Cache golang artifacts
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36 changes: 36 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
on: [push]
name: Test

jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.16.x

- name: Cache golang artifacts
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Ensure up to date deps
run: go mod tidy && git diff --no-patch --exit-code

- name: Setup environment
run: make install

- name: Test
run: make test

- name: Build
run: make build
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/terraform-provider-sql

dist/
39 changes: 39 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
before:
hooks:
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
ignore:
- goos: windows
goarch: arm64

archives:
- format: gz
name_template: >-
{{ .ProjectName }}_{{- .Os }}_{{ .Arch }}
format_overrides:
- goos: windows
format: zip
# https://goreleaser.com/customization/archive/#packaging-only-the-binaries
# we have to package the binaries only to maintain backwards compatibility with
# the old release system
files:
- none*
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

14 changes: 0 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,6 @@ help:
build:
go build

build-release-file:
@GOOS=$(OS) GOARCH=$(ARCH) go build -o $(PKGDIR)/terraform-provider-sql_$(OS)_$(ARCH) .
@gzip $(PKGDIR)/terraform-provider-sql_$(OS)_$(ARCH)

build-release:
@rm -rf $(PKGDIR)
@mkdir $(PKGDIR)
@for os in windows darwin linux ; do \
make build-release-file OS=$$os ARCH=amd64 ; \
done
@for os in darwin linux ; do \
make build-release-file OS=$$os ARCH=arm64 ; \
done

test:
go test $(TEST) -v $(TESTARGS)

Expand Down
10 changes: 6 additions & 4 deletions sql/resource_sql_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,24 @@ import (

_sql "database/sql"

_ "github.com/snowflakedb/gosnowflake"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
"github.com/stretchr/testify/assert"
)

func TestIdFromDataSource(t *testing.T) {
if result, err := idFromDataSource("dialict", "dialect://username:password@host?parameters"); assert.NoError(t, err) {
if result, err := idFromDataSource("dialect", "dialect://username:password@host?parameters"); assert.NoError(t, err) {
assert.Equal(t, "dialect://@host", result)
}
if result, err := idFromDataSource("dialict", "dialect://username:password@host"); assert.NoError(t, err) {
if result, err := idFromDataSource("dialect", "dialect://username:password@host"); assert.NoError(t, err) {
assert.Equal(t, "dialect://@host", result)
}
if result, err := idFromDataSource("dialict", "dialect://username:@host"); assert.NoError(t, err) {
if result, err := idFromDataSource("dialect", "dialect://username:@host"); assert.NoError(t, err) {
assert.Equal(t, "dialect://@host", result)
}
if result, err := idFromDataSource("dialict", "dialect://@host"); assert.NoError(t, err) {
if result, err := idFromDataSource("dialect", "dialect://@host"); assert.NoError(t, err) {
assert.Equal(t, "dialect://@host", result)
}
if result, err := idFromDataSource("dialect", "not connection string"); assert.NoError(t, err) {
Expand Down

0 comments on commit 1045f4a

Please sign in to comment.