From 22567468dffeac7e4e5ba53f590a41dd01b2c36d Mon Sep 17 00:00:00 2001 From: Toni Spets Date: Fri, 15 Dec 2023 22:29:17 +0200 Subject: [PATCH] Fix Windows builds and test they compile --- .github/workflows/commit.yml | 25 +++++++++++++++++++++++++ cmd/litestream/main_windows.go | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/commit.yml b/.github/workflows/commit.yml index 7cc4b74e..88f637aa 100644 --- a/.github/workflows/commit.yml +++ b/.github/workflows/commit.yml @@ -29,6 +29,31 @@ jobs: - uses: pre-commit/action@v3.0.0 + build-windows: + name: Windows Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} + + - uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ inputs.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: ${{ inputs.os }}-go- + + - run: sudo apt-get install -y mingw-w64 + + - run: | + GOARCH=386 CC=i686-w64-mingw32-gcc go build ./cmd/litestream/ + GOARCH=amd64 CC=x86_64-w64-mingw32-gcc go build ./cmd/litestream/ + env: + CGO_ENABLED: "1" + GOOS: windows + build: name: Build & Unit Test runs-on: ubuntu-latest diff --git a/cmd/litestream/main_windows.go b/cmd/litestream/main_windows.go index be7e7dd3..3cbbbd6c 100644 --- a/cmd/litestream/main_windows.go +++ b/cmd/litestream/main_windows.go @@ -69,7 +69,7 @@ func (s *windowsService) Execute(args []string, r <-chan svc.ChangeRequest, stat } // Execute replication command. - if err := c.Run(s.ctx); err != nil { + if err := c.Run(); err != nil { slog.Error("cannot replicate", "error", err) statusCh <- svc.Status{State: svc.StopPending} return true, 2