From 6b37a488ab4ecb7a04cf536d5a1dce50e4be216a Mon Sep 17 00:00:00 2001 From: Binaek Sarkar Date: Thu, 11 Jan 2024 23:54:28 +0530 Subject: [PATCH 01/12] unsafe.pointer --- helpers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers.go b/helpers.go index 4a3b1ba1..9e770733 100644 --- a/helpers.go +++ b/helpers.go @@ -197,7 +197,7 @@ func valToBuffer(val interface{}, oid C.Oid, buffer C.StringInfo) (err error) { } C.resetStringInfo(buffer) - C.appendBinaryStringInfo(buffer, C.CString(valueString), C.int(len(valueString))) + C.appendBinaryStringInfo(buffer, unsafe.Pointer(C.CString(valueString)), C.int(len(valueString))) return } From 726ac15c8033a366c5d507ee129dfa0c933b47bd Mon Sep 17 00:00:00 2001 From: Binaek Sarkar Date: Thu, 11 Jan 2024 23:54:36 +0530 Subject: [PATCH 02/12] always use netgo --- fdw/Makefile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fdw/Makefile b/fdw/Makefile index d8db9983..476337f6 100644 --- a/fdw/Makefile +++ b/fdw/Makefile @@ -36,9 +36,11 @@ include $(PGXS) OS := $(shell uname) # Check if the OS is Mac OS/Darwin -ifeq ($(OS),Darwin) - BUILD_TAGS = netgo -endif +# ifeq ($(OS),Darwin) +# BUILD_TAGS = netgo +# endif + +BUILD_TAGS = netgo ifeq ($(shell uname -s),Darwin) export CGO_LDFLAGS = -Wl,-undefined,dynamic_lookup From a8fd74d8c812d04a5e9c7f444665e5d09210adc7 Mon Sep 17 00:00:00 2001 From: Binaek Sarkar Date: Thu, 11 Jan 2024 23:56:47 +0530 Subject: [PATCH 03/12] no unsafe.pointer --- helpers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers.go b/helpers.go index 9e770733..4a3b1ba1 100644 --- a/helpers.go +++ b/helpers.go @@ -197,7 +197,7 @@ func valToBuffer(val interface{}, oid C.Oid, buffer C.StringInfo) (err error) { } C.resetStringInfo(buffer) - C.appendBinaryStringInfo(buffer, unsafe.Pointer(C.CString(valueString)), C.int(len(valueString))) + C.appendBinaryStringInfo(buffer, C.CString(valueString), C.int(len(valueString))) return } From 93f4a010d5d06e8dac41cd2818d880459c6c74e7 Mon Sep 17 00:00:00 2001 From: Binaek Sarkar Date: Fri, 12 Jan 2024 00:04:35 +0530 Subject: [PATCH 04/12] move mod_buld cache check --- .github/workflows/test.yml | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d01d9a9d..d06825f6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,24 +39,6 @@ jobs: repository: turbot/steampipe path: steampipe - - name: Build Steampipe - run: | - echo "PATH=$PATH:$HOME/build:/home/runner" >> $GITHUB_ENV - ls /home/runner/work/steampipe-postgres-fdw/steampipe-postgres-fdw - cd /home/runner/work/steampipe-postgres-fdw/steampipe-postgres-fdw/steampipe - go get - go build -o /home/runner/steampipe - - - name: Run steampipe - run: | - steampipe query "select 1 as col" - - - name: Checkout FDW - uses: actions/checkout@v4 - with: - repository: turbot/steampipe-postgres-fdw - path: steampipe-postgres-fdw - - name: Fetching Go Cache Paths id: go-cache-paths run: | @@ -76,6 +58,24 @@ jobs: with: path: ${{ steps.go-cache-paths.outputs.go-mod }} key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} + + - name: Build Steampipe + run: | + echo "PATH=$PATH:$HOME/build:/home/runner" >> $GITHUB_ENV + ls /home/runner/work/steampipe-postgres-fdw/steampipe-postgres-fdw + cd /home/runner/work/steampipe-postgres-fdw/steampipe-postgres-fdw/steampipe + go get + go build -o /home/runner/steampipe + + - name: Run steampipe + run: | + steampipe query "select 1 as col" + + - name: Checkout FDW + uses: actions/checkout@v4 + with: + repository: turbot/steampipe-postgres-fdw + path: steampipe-postgres-fdw - name: Setup apt-get run: |- From 2fa4c86ff53110e4f77a7cbac8626d7abb1c564e Mon Sep 17 00:00:00 2001 From: Binaek Sarkar Date: Fri, 12 Jan 2024 00:14:47 +0530 Subject: [PATCH 05/12] always use netgo --- fdw/Makefile | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/fdw/Makefile b/fdw/Makefile index 476337f6..71b4132d 100644 --- a/fdw/Makefile +++ b/fdw/Makefile @@ -35,13 +35,6 @@ include $(PGXS) # Determine the operating system OS := $(shell uname) -# Check if the OS is Mac OS/Darwin -# ifeq ($(OS),Darwin) -# BUILD_TAGS = netgo -# endif - -BUILD_TAGS = netgo - ifeq ($(shell uname -s),Darwin) export CGO_LDFLAGS = -Wl,-undefined,dynamic_lookup endif @@ -50,7 +43,7 @@ go: ../fdw.go # we are building with the net package from go # this has the caveat that, since we are not binding to lresolv, DNS resolution may # have some subtle differences from system DNS resolution - CGO_ENABLED=1 go build -o steampipe_postgres_fdw.a -tags "$(BUILD_TAGS)" -buildmode=c-archive ../*.go + CGO_ENABLED=1 go build -o steampipe_postgres_fdw.a -tags "netgo" -buildmode=c-archive ../*.go inst: mkdir -p ../build-${PLATFORM} From 6403a47ff646064f2ff74990a86a765000f97a24 Mon Sep 17 00:00:00 2001 From: Binaek Sarkar Date: Fri, 12 Jan 2024 00:18:12 +0530 Subject: [PATCH 06/12] test on darwin (amd and arm) --- .github/workflows/test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d06825f6..aafe9a9b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,7 +25,10 @@ jobs: build_and_test: name: Build and run tests needs: golangci_lint - runs-on: ubuntu-20.04 + strategy: + matrix: + platform: [macos-latest, macos-latest-large, ubuntu-20.04] + runs-on: ${{ matrix.platform }} steps: - name: Set up Go uses: actions/setup-go@v5 From 87483a15898c4094e0e6b5aa0834bad95ba5d78b Mon Sep 17 00:00:00 2001 From: Binaek Sarkar Date: Fri, 12 Jan 2024 00:19:44 +0530 Subject: [PATCH 07/12] disable other platforms for test --- .github/workflows/test.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aafe9a9b..d06825f6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,10 +25,7 @@ jobs: build_and_test: name: Build and run tests needs: golangci_lint - strategy: - matrix: - platform: [macos-latest, macos-latest-large, ubuntu-20.04] - runs-on: ${{ matrix.platform }} + runs-on: ubuntu-20.04 steps: - name: Set up Go uses: actions/setup-go@v5 From 6081673078f624d55cddf1e1abc2b1f3321685bf Mon Sep 17 00:00:00 2001 From: Binaek Sarkar Date: Fri, 12 Jan 2024 15:17:58 +0530 Subject: [PATCH 08/12] try static binding --- fdw/Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fdw/Makefile b/fdw/Makefile index 71b4132d..4888cd01 100644 --- a/fdw/Makefile +++ b/fdw/Makefile @@ -35,6 +35,11 @@ include $(PGXS) # Determine the operating system OS := $(shell uname) +# Check if the OS is Mac OS/Darwin +ifeq ($(OS),Darwin) + BUILD_TAGS = netgo +endif + ifeq ($(shell uname -s),Darwin) export CGO_LDFLAGS = -Wl,-undefined,dynamic_lookup endif @@ -43,7 +48,7 @@ go: ../fdw.go # we are building with the net package from go # this has the caveat that, since we are not binding to lresolv, DNS resolution may # have some subtle differences from system DNS resolution - CGO_ENABLED=1 go build -o steampipe_postgres_fdw.a -tags "netgo" -buildmode=c-archive ../*.go + CGO_ENABLED=1 go build -ldflags "-linkmode 'external' -extldflags '-static' -o steampipe_postgres_fdw.a -tags "$(BUILD_TAGS)" -buildmode=c-archive ../*.go inst: mkdir -p ../build-${PLATFORM} From c6681060564d9c817b573f8635217d066d6ebb10 Mon Sep 17 00:00:00 2001 From: Binaek Sarkar Date: Fri, 12 Jan 2024 15:42:40 +0530 Subject: [PATCH 09/12] terminate quoted string --- fdw/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdw/Makefile b/fdw/Makefile index 4888cd01..12d7af23 100644 --- a/fdw/Makefile +++ b/fdw/Makefile @@ -48,7 +48,7 @@ go: ../fdw.go # we are building with the net package from go # this has the caveat that, since we are not binding to lresolv, DNS resolution may # have some subtle differences from system DNS resolution - CGO_ENABLED=1 go build -ldflags "-linkmode 'external' -extldflags '-static' -o steampipe_postgres_fdw.a -tags "$(BUILD_TAGS)" -buildmode=c-archive ../*.go + CGO_ENABLED=1 go build -ldflags "-linkmode 'external' -extldflags '-static'" -o steampipe_postgres_fdw.a -tags "$(BUILD_TAGS)" -buildmode=c-archive ../*.go inst: mkdir -p ../build-${PLATFORM} From 7e917dbd425ab1964bb664cc68f7d6d0193deac0 Mon Sep 17 00:00:00 2001 From: Binaek Sarkar Date: Fri, 12 Jan 2024 16:08:51 +0530 Subject: [PATCH 10/12] try with ubuntu latest --- .github/workflows/test.yml | 2 +- fdw/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d06825f6..515fff39 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,7 +25,7 @@ jobs: build_and_test: name: Build and run tests needs: golangci_lint - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Set up Go uses: actions/setup-go@v5 diff --git a/fdw/Makefile b/fdw/Makefile index 12d7af23..9f2a0ca6 100644 --- a/fdw/Makefile +++ b/fdw/Makefile @@ -48,7 +48,7 @@ go: ../fdw.go # we are building with the net package from go # this has the caveat that, since we are not binding to lresolv, DNS resolution may # have some subtle differences from system DNS resolution - CGO_ENABLED=1 go build -ldflags "-linkmode 'external' -extldflags '-static'" -o steampipe_postgres_fdw.a -tags "$(BUILD_TAGS)" -buildmode=c-archive ../*.go + CGO_ENABLED=1 go build -o steampipe_postgres_fdw.a -tags "$(BUILD_TAGS)" -buildmode=c-archive ../*.go inst: mkdir -p ../build-${PLATFORM} From 86cf76bbc0122b65b72e8d37086318156e604057 Mon Sep 17 00:00:00 2001 From: Binaek Sarkar Date: Fri, 12 Jan 2024 16:41:01 +0530 Subject: [PATCH 11/12] upload artifact --- .github/workflows/test.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 515fff39..c6b838ad 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,7 +25,7 @@ jobs: build_and_test: name: Build and run tests needs: golangci_lint - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Set up Go uses: actions/setup-go@v5 @@ -113,6 +113,17 @@ jobs: run: | cd ~/work/steampipe-postgres-fdw/steampipe-postgres-fdw/steampipe-postgres-fdw/ make install + + - name: GZip + run: | + cd ~/work/steampipe-postgres-fdw/steampipe-postgres-fdw/steampipe-postgres-fdw + tar -czvf ../build.tar.gz ./build-$(uname) + + - name: Upload FDW Build + uses: actions/upload-artifact@v4 + with: + name: fdw-build + path: build.tar.gz - name: Setup BATS uses: mig4/setup-bats@v1 From eccfa326912b30aec689ec95b32f3ee4dd5c4f91 Mon Sep 17 00:00:00 2001 From: Binaek Sarkar Date: Fri, 12 Jan 2024 16:42:56 +0530 Subject: [PATCH 12/12] ubuntu-latest --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c6b838ad..5b4494d2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,7 +25,7 @@ jobs: build_and_test: name: Build and run tests needs: golangci_lint - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Set up Go uses: actions/setup-go@v5