From fce3a36523c274e66be1f620b903737c94344d9b Mon Sep 17 00:00:00 2001 From: Marcelo Toledo Date: Thu, 10 Jul 2025 21:46:52 -0300 Subject: [PATCH] Create go.yml Create go.yml Apply suggestion of Copilot --- .github/workflows/go.yml | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..fc9d24f --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,51 @@ +# This workflow will build a golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: Go Build & Test + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.24' + + - name: Cache Go modules + uses: actions/cache@v3 + with: + path: | + ~/.cache/go-build + $GOPATH/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Download dependencies + run: go mod tidy + + - name: Build server + run: go build -v -o server ./server.go + + - name: Build client + run: go build -v -o client ./client.go + + - name: Run tests (if available) + run: | + if ls *_test.go > /dev/null 2>&1 || find . -name '*_test.go' | grep .; then + echo "Running tests..." + go test -v ./... + else + echo "No tests found, skipping tests." + fi