From 75b78a45c07bf3ab5cf2ff71908062622e329fef Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Wed, 14 Oct 2020 21:17:03 -0600 Subject: [PATCH 01/10] use Make + XGO to build static binaries. attempt #3 --- .github/workflows/build.yaml | 72 +++++------------------------------- Makefile | 64 ++++++++++++++++++++++++++++++++ docker/Dockerfile.xgo | 7 ++++ 3 files changed, 81 insertions(+), 62 deletions(-) create mode 100644 Makefile create mode 100644 docker/Dockerfile.xgo diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index fe6c3fb..f660f81 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -6,7 +6,7 @@ jobs: build: name: Build runs-on: ubuntu-latest - container: golang:1.13 + container: karalabe/xgo-1.13.x env: PROJECT_PATH: /go/src/github.com/analogj/scrutiny CGO_ENABLED: 1 @@ -29,65 +29,9 @@ jobs: GOOS: linux GOARCH: amd64 run: | - apt-get update && apt-get install -y file cd $PROJECT_PATH - echo "###### Build Web ######" - go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=amd64" -o scrutiny-web-linux-amd64 -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go - echo "###### Build Collector ######" - go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=amd64" -o scrutiny-collector-metrics-linux-amd64 -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go - - chmod +x scrutiny-web-linux-amd64 - chmod +x scrutiny-collector-metrics-linux-amd64 - - file scrutiny-web-linux-amd64 - ldd scrutiny-web-linux-amd64 || true - file scrutiny-collector-metrics-linux-amd64 - ldd scrutiny-collector-metrics-linux-amd64 || true - - name: Build arm - env: - GOOS: linux - GOARCH: arm - run: | - cd $PROJECT_PATH - go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=arm" -o scrutiny-web-linux-arm -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go - go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=arm" -o scrutiny-collector-metrics-linux-arm -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go - - chmod +x scrutiny-web-linux-arm - chmod +x scrutiny-collector-metrics-linux-arm - - - name: Build arm64 - env: - GOOS: linux - GOARCH: arm64 - run: | - cd $PROJECT_PATH - go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=arm64" -o scrutiny-web-linux-arm64 -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go - go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=arm64" -o scrutiny-collector-metrics-linux-arm64 -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go - - chmod +x scrutiny-web-linux-arm64 - chmod +x scrutiny-collector-metrics-linux-arm64 - - - name: Build windows - env: - GOOS: windows - GOARCH: amd64 - run: | - cd $PROJECT_PATH - go build -ldflags "-X main.goos=windows -X main.goarch=amd64" -o scrutiny-web-windows-amd64.exe -tags "static" webapp/backend/cmd/scrutiny/scrutiny.go - go build -ldflags "-X main.goos=windows -X main.goarch=amd64" -o scrutiny-collector-metrics-windows-amd64.exe -tags "static" collector/cmd/collector-metrics/collector-metrics.go - - - name: Build freebsd - env: - GOOS: freebsd - GOARCH: amd64 - run: | - cd $PROJECT_PATH - go build -ldflags "-extldflags=-static -X main.goos=freebsd -X main.goarch=amd64" -o scrutiny-web-freebsd-amd64 -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go - go build -ldflags "-extldflags=-static -X main.goos=freebsd -X main.goarch=amd64" -o scrutiny-collector-metrics-freebsd-amd64 -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go - - chmod +x scrutiny-web-freebsd-amd64 - chmod +x scrutiny-collector-metrics-freebsd-amd64 + make all - name: Archive uses: actions/upload-artifact@v2 @@ -98,10 +42,14 @@ jobs: ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-linux-amd64 ${{ env.PROJECT_PATH }}/scrutiny-web-linux-arm64 ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-linux-arm64 - ${{ env.PROJECT_PATH }}/scrutiny-web-linux-arm - ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-linux-arm - ${{ env.PROJECT_PATH }}/scrutiny-web-windows-amd64.exe - ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-windows-amd64.exe + ${{ env.PROJECT_PATH }}/scrutiny-web-linux-arm-5 + ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-linux-arm-5 + ${{ env.PROJECT_PATH }}/scrutiny-web-linux-arm-6 + ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-linux-arm-6 + ${{ env.PROJECT_PATH }}/scrutiny-web-linux-arm-7 + ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-linux-arm-7 + ${{ env.PROJECT_PATH }}/scrutiny-web-windows-4.0-amd64.exe + ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-windows-4.0-amd64.exe ${{ env.PROJECT_PATH }}/scrutiny-web-freebsd-amd64 ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-freebsd-amd64 - uses: codecov/codecov-action@v1 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..89393b2 --- /dev/null +++ b/Makefile @@ -0,0 +1,64 @@ +export CGO_ENABLED = 1 + + +BINARY=\ + linux/amd64 \ + linux/arm-5 \ + linux/arm-6 \ + linux/arm-7 \ + linux/arm64 \ + + +.PHONY: all $(BINARY) +all: $(BINARY) windows/amd64 freebsd/amd64 + +$(BINARY): OS = $(word 1,$(subst /, ,$*)) +$(BINARY): ARCH = $(word 2,$(subst /, ,$*)) +$(BINARY): build/scrutiny-web-%: + @echo "building web binary (OS = $(OS), ARCH = $(ARCH))" + xgo -v --targets="$(OS)/$(ARCH)" -ldflags "-extldflags=-static -X main.goos=$(OS) -X main.goarch=$(ARCH)" -out scrutiny-web -tags "static netgo sqlite_omit_load_extension" ./webapp/backend/cmd/scrutiny/ + + chmod +x "/build/scrutiny-web-$(OS)-$(ARCH)" + file "/build/scrutiny-web-$(OS)-$(ARCH)" || true + ldd "/build/scrutiny-web-$(OS)-$(ARCH)" || true + + @echo "building collector binary (OS = $(OS), ARCH = $(ARCH))" + xgo -v --targets="$(OS)/$(ARCH)" -ldflags "-extldflags=-static -X main.goos=$(OS) -X main.goarch=$(ARCH)" -out scrutiny-collector-metrics -tags "static netgo" ./collector/cmd/collector-metrics/ + + chmod +x "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)" + file "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)" || true + ldd "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)" || true + +windows/amd64: OS = windows +windows/amd64: ARCH = amd64 +windows/amd64: + @echo "building web binary (OS = $(OS), ARCH = $(ARCH))" + xgo -v --targets="$(OS)/$(ARCH)" -ldflags "-extldflags=-static -X main.goos=$(OS) -X main.goarch=$(ARCH)" -out scrutiny-web -tags "static netgo sqlite_omit_load_extension" ./webapp/backend/cmd/scrutiny/ + + @echo "building collector binary (OS = $(OS), ARCH = $(ARCH))" + xgo -v --targets="$(OS)/$(ARCH)" -ldflags "-extldflags=-static -X main.goos=$(OS) -X main.goarch=$(ARCH)" -out scrutiny-collector-metrics -tags "static netgo" ./collector/cmd/collector-metrics/ + +freebsd/amd64: OS = freebsd +freebsd/amd64: ARCH = amd64 +freebsd/amd64: GOOS = freebsd +freebsd/amd64: GOARCH = amd64 +freebsd/amd64: CGO_ENABLED = 1 +freebsd/amd64: + mkdir -p /build + + @echo "building web binary (OS = $(OS), ARCH = $(ARCH))" + go build -ldflags "-extldflags=-static -X main.goos=$(OS) -X main.goarch=$(ARCH)" -o /build/scrutiny-web-$(OS)-$(ARCH) -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go + + chmod +x "/build/scrutiny-web-$(OS)-$(ARCH)" + file "/build/scrutiny-web-$(OS)-$(ARCH)" || true + ldd "/build/scrutiny-web-$(OS)-$(ARCH)" || true + + @echo "building collector binary (OS = $(OS), ARCH = $(ARCH))" + go build -ldflags "-extldflags=-static -X main.goos=$(OS) -X main.goarch=$(ARCH)" -o /build/scrutiny-collector-metrics-$(OS)-$(ARCH) -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go + + chmod +x "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)" + file "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)" || true + ldd "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)" || true + +# clean: +# rm scrutiny-collector-metrics-* scrutiny-web-* diff --git a/docker/Dockerfile.xgo b/docker/Dockerfile.xgo new file mode 100644 index 0000000..1bb32bd --- /dev/null +++ b/docker/Dockerfile.xgo @@ -0,0 +1,7 @@ +FROM karalabe/xgo-1.13.x + +WORKDIR /go/src/github.com/analogj/scrutiny + +COPY . /go/src/github.com/analogj/scrutiny + +RUN make all From a83aab79bf70a4d8d94d4fd02b27c91dc7284e86 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Wed, 14 Oct 2020 21:22:46 -0600 Subject: [PATCH 02/10] use Make + XGO to build static binaries. attempt #3 --- .github/workflows/build.yaml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f660f81..eecf3c9 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -38,20 +38,20 @@ jobs: with: name: binaries.zip path: | - ${{ env.PROJECT_PATH }}/scrutiny-web-linux-amd64 - ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-linux-amd64 - ${{ env.PROJECT_PATH }}/scrutiny-web-linux-arm64 - ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-linux-arm64 - ${{ env.PROJECT_PATH }}/scrutiny-web-linux-arm-5 - ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-linux-arm-5 - ${{ env.PROJECT_PATH }}/scrutiny-web-linux-arm-6 - ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-linux-arm-6 - ${{ env.PROJECT_PATH }}/scrutiny-web-linux-arm-7 - ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-linux-arm-7 - ${{ env.PROJECT_PATH }}/scrutiny-web-windows-4.0-amd64.exe - ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-windows-4.0-amd64.exe - ${{ env.PROJECT_PATH }}/scrutiny-web-freebsd-amd64 - ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-freebsd-amd64 + /build/scrutiny-web-linux-amd64 + /build/scrutiny-collector-metrics-linux-amd64 + /build/scrutiny-web-linux-arm64 + /build/scrutiny-collector-metrics-linux-arm64 + /build/scrutiny-web-linux-arm-5 + /build/scrutiny-collector-metrics-linux-arm-5 + /build/scrutiny-web-linux-arm-6 + /build/scrutiny-collector-metrics-linux-arm-6 + /build/scrutiny-web-linux-arm-7 + /build/scrutiny-collector-metrics-linux-arm-7 + /build/scrutiny-web-windows-4.0-amd64.exe + /build/scrutiny-collector-metrics-windows-4.0-amd64.exe + /build/scrutiny-web-freebsd-amd64 + /build/scrutiny-collector-metrics-freebsd-amd64 - uses: codecov/codecov-action@v1 with: file: ${{ env.PROJECT_PATH }}/coverage.txt From c9620b5f87b06bf068bbca08fc0aa33a998d63e1 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Thu, 15 Oct 2020 23:38:58 -0600 Subject: [PATCH 03/10] use Make + XGO to build static binaries. attempt #3 --- .github/workflows/build.yaml | 8 +-- .github/workflows/release.yaml | 120 +++++++++++++++------------------ 2 files changed, 55 insertions(+), 73 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index eecf3c9..05a52ed 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -14,9 +14,6 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Test - env: - GOOS: linux - GOARCH: amd64 run: | mkdir -p $PROJECT_PATH cp -a $GITHUB_WORKSPACE/* $PROJECT_PATH/ @@ -24,10 +21,7 @@ jobs: go mod vendor go test -race -coverprofile=coverage.txt -covermode=atomic -v -tags "static" $(go list ./... | grep -v /vendor/) - - name: Build amd64 - env: - GOOS: linux - GOARCH: amd64 + - name: Build Binaries run: | cd $PROJECT_PATH diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index da0781b..639f8c8 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -31,9 +31,6 @@ jobs: version_metadata_path: ${{ github.event.inputs.version_metadata_path }} github_token: ${{ secrets.SCRUTINY_GITHUB_TOKEN }} - name: Test - env: - GOOS: linux - GOARCH: amd64 run: | mkdir -p $PROJECT_PATH cp -a $GITHUB_WORKSPACE/* $PROJECT_PATH/ @@ -42,62 +39,11 @@ jobs: go mod vendor go test -v -tags "static" $(go list ./... | grep -v /vendor/) - - name: Build amd64 - env: - GOOS: linux - GOARCH: amd64 - run: | - cd $PROJECT_PATH - go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=amd64" -o scrutiny-web-linux-amd64 -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go - go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=amd64" -o scrutiny-collector-metrics-linux-amd64 -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go - - chmod +x scrutiny-web-linux-amd64 - chmod +x scrutiny-collector-metrics-linux-amd64 - - - name: Build arm - env: - GOOS: linux - GOARCH: arm - run: | - cd $PROJECT_PATH - go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=arm" -o scrutiny-web-linux-arm -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go - go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=arm" -o scrutiny-collector-metrics-linux-arm -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go - - chmod +x scrutiny-web-linux-arm - chmod +x scrutiny-collector-metrics-linux-arm - - - name: Build arm64 - env: - GOOS: linux - GOARCH: arm64 - run: | - cd $PROJECT_PATH - go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=arm64" -o scrutiny-web-linux-arm64 -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go - go build -ldflags "-extldflags=-static -X main.goos=linux -X main.goarch=arm64" -o scrutiny-collector-metrics-linux-arm64 -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go - - chmod +x scrutiny-web-linux-arm64 - chmod +x scrutiny-collector-metrics-linux-arm64 - - - name: Build windows - env: - GOOS: windows - GOARCH: amd64 + - name: Build Binaries run: | - cd $PROJECT_PATH - go build -ldflags "-X main.goos=windows -X main.goarch=amd64" -o scrutiny-web-windows-amd64.exe -tags "static" webapp/backend/cmd/scrutiny/scrutiny.go - go build -ldflags "-X main.goos=windows -X main.goarch=amd64" -o scrutiny-collector-metrics-windows-amd64.exe -tags "static" collector/cmd/collector-metrics/collector-metrics.go - - name: Build freebsd - env: - GOOS: freebsd - GOARCH: amd64 - run: | cd $PROJECT_PATH - go build -ldflags "-extldflags=-static -X main.goos=freebsd -X main.goarch=amd64" -o scrutiny-web-freebsd-amd64 -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go - go build -ldflags "-extldflags=-static -X main.goos=freebsd -X main.goarch=amd64" -o scrutiny-collector-metrics-freebsd-amd64 -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go - - chmod +x scrutiny-web-freebsd-amd64 - chmod +x scrutiny-collector-metrics-freebsd-amd64 + make all - name: Commit uses: EndBug/add-and-commit@v4 # You can change this to use a specific version @@ -131,7 +77,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ${{ env.PROJECT_PATH }}/scrutiny-web-linux-amd64 + asset_path: /build/scrutiny-web-linux-amd64 asset_name: scrutiny-web-linux-amd64 asset_content_type: application/octet-stream - name: Release Asset - Collector - linux-amd64 @@ -141,7 +87,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-linux-amd64 + asset_path: /build/scrutiny-collector-metrics-linux-amd64 asset_name: scrutiny-collector-metrics-linux-amd64 asset_content_type: application/octet-stream @@ -153,7 +99,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ${{ env.PROJECT_PATH }}/scrutiny-web-linux-arm64 + asset_path: /build/scrutiny-web-linux-arm64 asset_name: scrutiny-web-linux-arm64 asset_content_type: application/octet-stream - name: Release Asset - Collector - linux-arm64 @@ -163,29 +109,71 @@ jobs: GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-linux-arm64 + asset_path: /build/scrutiny-collector-metrics-linux-arm64 asset_name: scrutiny-collector-metrics-linux-arm64 asset_content_type: application/octet-stream - - name: Release Asset - Web - linux-arm + - name: Release Asset - Web - linux-arm-5 + id: upload-release-asset5 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: /build/scrutiny-web-linux-arm-5 + asset_name: scrutiny-web-linux-arm-5 + asset_content_type: application/octet-stream + - name: Release Asset - Collector - linux-arm-5 + id: upload-release-asset6 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: /buildd/scrutiny-collector-metrics-linux-arm-5 + asset_name: scrutiny-collector-metrics-linux-arm-5 + asset_content_type: application/octet-stream + + - name: Release Asset - Web - linux-arm-6 + id: upload-release-asset5 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: /build/scrutiny-web-linux-arm-6 + asset_name: scrutiny-web-linux-arm-6 + asset_content_type: application/octet-stream + - name: Release Asset - Collector - linux-arm-6 + id: upload-release-asset6 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: /buildd/scrutiny-collector-metrics-linux-arm-6 + asset_name: scrutiny-collector-metrics-linux-arm-6 + asset_content_type: application/octet-stream + + - name: Release Asset - Web - linux-arm-7 id: upload-release-asset5 uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ${{ env.PROJECT_PATH }}/scrutiny-web-linux-arm - asset_name: scrutiny-web-linux-arm + asset_path: /build/scrutiny-web-linux-arm-7 + asset_name: scrutiny-web-linux-arm-7 asset_content_type: application/octet-stream - - name: Release Asset - Collector - linux-arm + - name: Release Asset - Collector - linux-arm-7 id: upload-release-asset6 uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-linux-arm - asset_name: scrutiny-collector-metrics-linux-arm + asset_path: /buildd/scrutiny-collector-metrics-linux-arm-7 + asset_name: scrutiny-collector-metrics-linux-arm-7 asset_content_type: application/octet-stream - name: Release Asset - Web - freebsd-amd64 From 4fd650a1508d5b649b61ebb32693a64c0ef8c4b6 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sat, 17 Oct 2020 11:08:25 -0600 Subject: [PATCH 04/10] adding a vagrantfile for testing. Adding 32bit version of binary for freebsd. --- Makefile | 26 +++++++++++++++++++++++++- docker/Vagrantfile | 16 ++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 docker/Vagrantfile diff --git a/Makefile b/Makefile index 89393b2..e63f4f0 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ BINARY=\ .PHONY: all $(BINARY) -all: $(BINARY) windows/amd64 freebsd/amd64 +all: $(BINARY) windows/amd64 freebsd/amd64 freebsd/386 $(BINARY): OS = $(word 1,$(subst /, ,$*)) $(BINARY): ARCH = $(word 2,$(subst /, ,$*)) @@ -60,5 +60,29 @@ freebsd/amd64: file "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)" || true ldd "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)" || true +freebsd/amd64: OS = freebsd +freebsd/amd64: ARCH = 386 +freebsd/amd64: GOOS = freebsd +freebsd/amd64: GOARCH = 386 +freebsd/amd64: CGO_ENABLED = 1 +freebsd/amd64: + mkdir -p /build + env + @echo "building web binary (OS = $(OS), ARCH = $(ARCH))" + go build -ldflags "-extldflags=-static -X main.goos=$(OS) -X main.goarch=$(ARCH)" -o /build/scrutiny-web-$(OS)-$(ARCH) -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go + + chmod +x "/build/scrutiny-web-$(OS)-$(ARCH)" + file "/build/scrutiny-web-$(OS)-$(ARCH)" || true + ldd "/build/scrutiny-web-$(OS)-$(ARCH)" || true + + @echo "building collector binary (OS = $(OS), ARCH = $(ARCH))" + go build -ldflags "-extldflags=-static -X main.goos=$(OS) -X main.goarch=$(ARCH)" -o /build/scrutiny-collector-metrics-$(OS)-$(ARCH) -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go + + chmod +x "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)" + file "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)" || true + ldd "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)" || true + + + # clean: # rm scrutiny-collector-metrics-* scrutiny-web-* diff --git a/docker/Vagrantfile b/docker/Vagrantfile new file mode 100644 index 0000000..4efaf98 --- /dev/null +++ b/docker/Vagrantfile @@ -0,0 +1,16 @@ +Vagrant.configure("2") do |config| + config.vm.guest = :freebsd + config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true + config.vm.box = "freebsd/FreeBSD-11.0-CURRENT" + config.ssh.shell = "sh" + config.vm.base_mac = "080027D14C66" + + config.vm.provider :virtualbox do |vb| + vb.customize ["modifyvm", :id, "--memory", "1024"] + vb.customize ["modifyvm", :id, "--cpus", "1"] + vb.customize ["modifyvm", :id, "--hwvirtex", "on"] + vb.customize ["modifyvm", :id, "--audio", "none"] + vb.customize ["modifyvm", :id, "--nictype1", "virtio"] + vb.customize ["modifyvm", :id, "--nictype2", "virtio"] + end +end From 5be3407489bac91a242326bdbc8c02f96520acdb Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sat, 17 Oct 2020 11:15:55 -0600 Subject: [PATCH 05/10] 386 --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index e63f4f0..2ae1d3f 100644 --- a/Makefile +++ b/Makefile @@ -60,12 +60,12 @@ freebsd/amd64: file "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)" || true ldd "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)" || true -freebsd/amd64: OS = freebsd -freebsd/amd64: ARCH = 386 -freebsd/amd64: GOOS = freebsd -freebsd/amd64: GOARCH = 386 -freebsd/amd64: CGO_ENABLED = 1 -freebsd/amd64: +freebsd/386: OS = freebsd +freebsd/386: ARCH = 386 +freebsd/386: GOOS = freebsd +freebsd/386: GOARCH = 386 +freebsd/386: CGO_ENABLED = 1 +freebsd/386: mkdir -p /build env @echo "building web binary (OS = $(OS), ARCH = $(ARCH))" From d6c1d4aa047bb394718b5c3bab037ec62bfc6058 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sat, 17 Oct 2020 11:20:13 -0600 Subject: [PATCH 06/10] use Make + XGO to build static binaries. attempt #3 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2ae1d3f..95f3923 100644 --- a/Makefile +++ b/Makefile @@ -67,7 +67,7 @@ freebsd/386: GOARCH = 386 freebsd/386: CGO_ENABLED = 1 freebsd/386: mkdir -p /build - env + env @echo "building web binary (OS = $(OS), ARCH = $(ARCH))" go build -ldflags "-extldflags=-static -X main.goos=$(OS) -X main.goarch=$(ARCH)" -o /build/scrutiny-web-$(OS)-$(ARCH) -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go From c89381b39e84af570a1f4d00d8aff5a1f81d051b Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sat, 17 Oct 2020 11:33:01 -0600 Subject: [PATCH 07/10] set GOOS and GOARCH correctly when not using xgo. --- Makefile | 61 ++++++++++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/Makefile b/Makefile index 95f3923..97a9236 100644 --- a/Makefile +++ b/Makefile @@ -29,8 +29,8 @@ $(BINARY): build/scrutiny-web-%: file "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)" || true ldd "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)" || true -windows/amd64: OS = windows -windows/amd64: ARCH = amd64 +windows/amd64: export OS = windows +windows/amd64: export ARCH = amd64 windows/amd64: @echo "building web binary (OS = $(OS), ARCH = $(ARCH))" xgo -v --targets="$(OS)/$(ARCH)" -ldflags "-extldflags=-static -X main.goos=$(OS) -X main.goarch=$(ARCH)" -out scrutiny-web -tags "static netgo sqlite_omit_load_extension" ./webapp/backend/cmd/scrutiny/ @@ -38,49 +38,44 @@ windows/amd64: @echo "building collector binary (OS = $(OS), ARCH = $(ARCH))" xgo -v --targets="$(OS)/$(ARCH)" -ldflags "-extldflags=-static -X main.goos=$(OS) -X main.goarch=$(ARCH)" -out scrutiny-collector-metrics -tags "static netgo" ./collector/cmd/collector-metrics/ -freebsd/amd64: OS = freebsd -freebsd/amd64: ARCH = amd64 -freebsd/amd64: GOOS = freebsd -freebsd/amd64: GOARCH = amd64 -freebsd/amd64: CGO_ENABLED = 1 +freebsd/amd64: export GOOS = freebsd +freebsd/amd64: export GOARCH = amd64 freebsd/amd64: mkdir -p /build - @echo "building web binary (OS = $(OS), ARCH = $(ARCH))" - go build -ldflags "-extldflags=-static -X main.goos=$(OS) -X main.goarch=$(ARCH)" -o /build/scrutiny-web-$(OS)-$(ARCH) -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go + @echo "building web binary (OS = $(GOOS), ARCH = $(GOARCH))" + go build -ldflags "-extldflags=-static -X main.goos=$(GOOS) -X main.goarch=$(GOARCH)" -o /build/scrutiny-web-$(GOOS)-$(GOARCH) -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go - chmod +x "/build/scrutiny-web-$(OS)-$(ARCH)" - file "/build/scrutiny-web-$(OS)-$(ARCH)" || true - ldd "/build/scrutiny-web-$(OS)-$(ARCH)" || true + chmod +x "/build/scrutiny-web-$(GOOS)-$(GOARCH)" + file "/build/scrutiny-web-$(GOOS)-$(GOARCH)" || true + ldd "/build/scrutiny-web-$(GOOS)-$(GOARCH)" || true - @echo "building collector binary (OS = $(OS), ARCH = $(ARCH))" - go build -ldflags "-extldflags=-static -X main.goos=$(OS) -X main.goarch=$(ARCH)" -o /build/scrutiny-collector-metrics-$(OS)-$(ARCH) -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go + @echo "building collector binary (OS = $(GOOS), ARCH = $(GOARCH))" + go build -ldflags "-extldflags=-static -X main.goos=$(GOOS) -X main.goarch=$(GOARCH)" -o /build/scrutiny-collector-metrics-$(GOOS)-$(GOARCH) -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go - chmod +x "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)" - file "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)" || true - ldd "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)" || true + chmod +x "/build/scrutiny-collector-metrics-$(GOOS)-$(GOARCH)" + file "/build/scrutiny-collector-metrics-$(GOOS)-$(GOARCH)" || true + ldd "/build/scrutiny-collector-metrics-$(GOOS)-$(GOARCH)" || true -freebsd/386: OS = freebsd -freebsd/386: ARCH = 386 -freebsd/386: GOOS = freebsd -freebsd/386: GOARCH = 386 -freebsd/386: CGO_ENABLED = 1 +freebsd/386: export GOOS = freebsd +freebsd/386: export GOARCH = 386 freebsd/386: mkdir -p /build - env - @echo "building web binary (OS = $(OS), ARCH = $(ARCH))" - go build -ldflags "-extldflags=-static -X main.goos=$(OS) -X main.goarch=$(ARCH)" -o /build/scrutiny-web-$(OS)-$(ARCH) -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go - chmod +x "/build/scrutiny-web-$(OS)-$(ARCH)" - file "/build/scrutiny-web-$(OS)-$(ARCH)" || true - ldd "/build/scrutiny-web-$(OS)-$(ARCH)" || true + @echo "building web binary (OS = $(GOOS), ARCH = $(GOARCH))" + go build -ldflags "-extldflags=-static -X main.goos=$(GOOS) -X main.goarch=$(GOARCH)" -o /build/scrutiny-web-$(GOOS)-$(GOARCH) -tags "static netgo sqlite_omit_load_extension" webapp/backend/cmd/scrutiny/scrutiny.go - @echo "building collector binary (OS = $(OS), ARCH = $(ARCH))" - go build -ldflags "-extldflags=-static -X main.goos=$(OS) -X main.goarch=$(ARCH)" -o /build/scrutiny-collector-metrics-$(OS)-$(ARCH) -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go + chmod +x "/build/scrutiny-web-$(GOOS)-$(GOARCH)" + file "/build/scrutiny-web-$(GOOS)-$(GOARCH)" || true + ldd "/build/scrutiny-web-$(GOOS)-$(GOARCH)" || true + + @echo "building collector binary (OS = $(GOOS), ARCH = $(GOARCH))" + go build -ldflags "-extldflags=-static -X main.goos=$(GOOS) -X main.goarch=$(GOARCH)" -o /build/scrutiny-collector-metrics-$(GOOS)-$(GOARCH) -tags "static netgo" collector/cmd/collector-metrics/collector-metrics.go + + chmod +x "/build/scrutiny-collector-metrics-$(GOOS)-$(GOARCH)" + file "/build/scrutiny-collector-metrics-$(GOOS)-$(GOARCH)" || true + ldd "/build/scrutiny-collector-metrics-$(GOOS)-$(GOARCH)" || true - chmod +x "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)" - file "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)" || true - ldd "/build/scrutiny-collector-metrics-$(OS)-$(ARCH)" || true From 7293f2e48bfe271d009bfef11feb9f2019448841 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sat, 17 Oct 2020 12:44:46 -0600 Subject: [PATCH 08/10] disable freebsd builds. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 97a9236..928d9a5 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ BINARY=\ .PHONY: all $(BINARY) -all: $(BINARY) windows/amd64 freebsd/amd64 freebsd/386 +all: $(BINARY) windows/amd64 $(BINARY): OS = $(word 1,$(subst /, ,$*)) $(BINARY): ARCH = $(word 2,$(subst /, ,$*)) From edfa75739a7183a6b9a056904392cb1c0cd6fc4d Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sun, 18 Oct 2020 10:24:32 -0600 Subject: [PATCH 09/10] remove freebsd from build. --- .github/workflows/build.yaml | 4 ++-- .github/workflows/release.yaml | 40 +++++++++++++++++----------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 05a52ed..ffedd6e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -44,8 +44,8 @@ jobs: /build/scrutiny-collector-metrics-linux-arm-7 /build/scrutiny-web-windows-4.0-amd64.exe /build/scrutiny-collector-metrics-windows-4.0-amd64.exe - /build/scrutiny-web-freebsd-amd64 - /build/scrutiny-collector-metrics-freebsd-amd64 +# /build/scrutiny-web-freebsd-amd64 +# /build/scrutiny-collector-metrics-freebsd-amd64 - uses: codecov/codecov-action@v1 with: file: ${{ env.PROJECT_PATH }}/coverage.txt diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 639f8c8..0058c52 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -176,23 +176,23 @@ jobs: asset_name: scrutiny-collector-metrics-linux-arm-7 asset_content_type: application/octet-stream - - name: Release Asset - Web - freebsd-amd64 - id: upload-release-asset7 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ${{ env.PROJECT_PATH }}/scrutiny-web-freebsd-amd64 - asset_name: scrutiny-web-freebsd-amd64 - asset_content_type: application/octet-stream - - name: Release Asset - Collector - freebsd-amd64 - id: upload-release-asset8 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-freebsd-amd64 - asset_name: scrutiny-collector-metrics-freebsd-amd64 - asset_content_type: application/octet-stream +# - name: Release Asset - Web - freebsd-amd64 +# id: upload-release-asset7 +# uses: actions/upload-release-asset@v1 +# env: +# GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }} +# with: +# upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps +# asset_path: ${{ env.PROJECT_PATH }}/scrutiny-web-freebsd-amd64 +# asset_name: scrutiny-web-freebsd-amd64 +# asset_content_type: application/octet-stream +# - name: Release Asset - Collector - freebsd-amd64 +# id: upload-release-asset8 +# uses: actions/upload-release-asset@v1 +# env: +# GITHUB_TOKEN: ${{ secrets.SCRUTINY_GITHUB_TOKEN }} +# with: +# upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps +# asset_path: ${{ env.PROJECT_PATH }}/scrutiny-collector-metrics-freebsd-amd64 +# asset_name: scrutiny-collector-metrics-freebsd-amd64 +# asset_content_type: application/octet-stream From e2e0045dddedb7fb0ca9d6298865229ffa60f7e4 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sun, 18 Oct 2020 10:27:31 -0600 Subject: [PATCH 10/10] dont fail CI if codecov fails. --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ffedd6e..62fa365 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -50,4 +50,4 @@ jobs: with: file: ${{ env.PROJECT_PATH }}/coverage.txt flags: unittests - fail_ci_if_error: true + fail_ci_if_error: false