Simplify CI workflow to avoid artifact upload issues #7
This file contains hidden or 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: CI | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| workflow_dispatch: # Allow manual triggering | |
| schedule: | |
| - cron: '0 0 * * 0' # Run weekly on Sundays at midnight UTC | |
| jobs: | |
| build-and-test: | |
| name: Build and Test | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 # Add timeout to prevent hanging jobs | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Create empty go.sum if it doesn't exist | |
| run: touch go.sum | |
| - name: Set up Go | |
| uses: actions/setup-go@v3 | |
| with: | |
| go-version: 1.19 | |
| cache: true # Enable cache now that we have a go.sum file | |
| # We don't need go mod download since we don't have external dependencies | |
| - name: Build | |
| run: go build -v ./cmd/stremax | |
| - name: Run unit tests | |
| run: go test -v ./... | |
| - name: Run tests with race detection | |
| run: go test -race -v ./... | |
| - name: Run tests with coverage | |
| run: go test -coverprofile=coverage.out -covermode=atomic ./... | |
| - name: Display coverage | |
| run: go tool cover -func=coverage.out | |
| - name: Run example programs | |
| run: | | |
| chmod +x ./stremax | |
| ./stremax run -file ./examples/simple.sx | |
| ./stremax run -file ./examples/arithmetic.sx | |
| ./stremax run -file ./examples/strings.sx | |
| ./stremax run -file ./examples/conditionals.sx | |
| ./stremax run -file ./examples/boolean.sx | |
| ./stremax run -file ./examples/combined.sx | |
| - name: Run benchmarks | |
| run: go test -bench=. -benchmem ./... > benchmark-result.txt | |
| - name: Display benchmark results | |
| run: cat benchmark-result.txt | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Create empty go.sum if it doesn't exist | |
| run: touch go.sum | |
| - name: Set up Go | |
| uses: actions/setup-go@v3 | |
| with: | |
| go-version: 1.19 | |
| cache: true # Enable cache now that we have a go.sum file | |
| - name: Install golint | |
| run: go install golang.org/x/lint/golint@latest | |
| - name: Run gofmt | |
| run: | | |
| if [ "$(gofmt -l . | wc -l)" -gt 0 ]; then | |
| echo "The following files need formatting:" | |
| gofmt -l . | |
| echo "Please run 'gofmt -w .' to fix these issues" | |
| exit 1 | |
| fi | |
| - name: Run golint | |
| run: $(go env GOPATH)/bin/golint -set_exit_status ./... | |
| - name: Run go vet | |
| run: go vet ./... |