From b854164f5aabc133ce03ea63ab750030822ce5af 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 They are still not officially supported but this ensures we don't break the build accidentally. Caches are enabled by default in actions/setup-go@v4 so no need to manually cache. --- .github/workflows/commit.yml | 28 +++++++++++++++++++++------- cmd/litestream/main_windows.go | 2 +- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.github/workflows/commit.yml b/.github/workflows/commit.yml index 7cc4b74e..01504bf0 100644 --- a/.github/workflows/commit.yml +++ b/.github/workflows/commit.yml @@ -20,7 +20,6 @@ jobs: - uses: actions/setup-go@v4 with: go-version: ${{ env.GO_VERSION }} - cache: true - run: | go install golang.org/x/tools/cmd/goimports@latest @@ -29,21 +28,36 @@ jobs: - uses: pre-commit/action@v3.0.0 - build: - name: Build & Unit Test + build-windows: + name: Build Windows runs-on: ubuntu-latest steps: + - run: sudo apt-get install -y mingw-w64 + - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: go-version: ${{ env.GO_VERSION }} - - uses: actions/cache@v2 + - run: | + go build ./cmd/litestream/ + file ./litestream.exe + env: + CGO_ENABLED: "1" + GOOS: windows + GOARCH: amd64 + CC: x86_64-w64-mingw32-gcc + + build: + name: Build & Unit Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v4 with: - path: ~/go/pkg/mod - key: ${{ inputs.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: ${{ inputs.os }}-go- + go-version: ${{ env.GO_VERSION }} - run: go env 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