Merge pull request #8 from zeuslawyer/zp-patches #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Go Build & Test | |
on: | |
# Run tests for pull requests to the main or develop branch | |
pull_request: | |
branches: [main, develop] | |
# Run tests on pushes to all branches | |
push: | |
branches: ["**"] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
# Setup Go environment (replace with your desired version) | |
- name: Set up Go 1.19 | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.19 | |
# Cache Go modules to improve performance | |
- name: Cache Go modules | |
uses: actions/cache@v3 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.mod') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
# Build the project | |
- name: Build Go project | |
run: go build -v ./... | |
# Run tests only if build is successful (fail-fast) | |
- name: Run tests | |
if: success() # Only run if previous step succeeded | |
run: go test -v ./... |