# Build from source on FreeBSD.
name: build_freebsd
on: [push]
permissions: read-all
jobs:
  build_freebsd:
    runs-on: ubuntu-latest
    env:
      GOEXPERIMENT: "noboringcrypto"
      # Looks like CGO is required for FreeBSD building
      CGO_ENABLED: 1
    steps:
    - uses: actions/checkout@v4
    - name: Building from source
      id: build_freebsd
      uses: vmactions/freebsd-vm@v1
      with:
        envs: 'GOEXPERIMENT CGO_ENABLED'
        usesh: true
        mem: 4096
        # We're specifically building for OPNsense, which is most recently on FreeBSD 14.1
        release: "14.1"
        # Note that the test scripts require bash
        prepare: |
          pkg install -y sudo gmake bash git go golangci-lint curl wget fakeroot libffi rubygem-fpm 
          git config --global --add safe.directory /home/runner/work/cloudflared/cloudflared
        run: |
          gmake install-go 
          go mod download
          go mod tidy
          go install golang.org/x/tools/cmd/goimports@latest
          gmake cloudflared cleanup-go