Skip to content

ci: add GitHub Actions workflows (#10) #14

ci: add GitHub Actions workflows (#10)

ci: add GitHub Actions workflows (#10) #14

Workflow file for this run

name: Build and Test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Run Tests with Coverage
run: |
go test -v -coverprofile=coverage.out -covermode=atomic ./...
go tool cover -func=coverage.out > coverage.txt
go tool cover -html=coverage.out -o coverage.html
echo "::group::Coverage Report" >> $GITHUB_STEP_SUMMARY
cat coverage.txt >> $GITHUB_STEP_SUMMARY
echo "::endgroup::" >> $GITHUB_STEP_SUMMARY
- name: Upload Coverage Report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: |
coverage.out
coverage.txt
coverage.html
retention-days: 14
- name: Display Coverage Summary
run: cat coverage.txt
build:
name: Build Application
needs: test
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true && github.base_ref == 'main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Build with Dagger
uses: dagger/[email protected]
with:
version: "latest"
verb: run
workdir: dagger
args: go run main.go
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: build/
retention-days: 5