name: CI on: push: branches: [master] tags: ["v*"] pull_request: branches: [master] permissions: contents: read jobs: lint: name: Lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install Go run: | GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}') curl -sL "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar -C /usr/local -xzf - echo "/usr/local/go/bin" >> $GITHUB_PATH echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - name: Check formatting run: | go install mvdan.cc/gofumpt@latest output=$(gofumpt -l .) if [ -n "$output" ]; then echo "Files need formatting:" echo "$output" exit 1 fi - name: Run lint run: | go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest golangci-lint run ./... test: name: Test runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install Go run: | GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}') curl -sL "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar -C /usr/local -xzf - echo "/usr/local/go/bin" >> $GITHUB_PATH - name: Run unit tests run: go test -race -count=1 ./internal/... build: name: Build needs: [lint, test] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install Go run: | GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}') curl -sL "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar -C /usr/local -xzf - echo "/usr/local/go/bin" >> $GITHUB_PATH - name: Build run: make build - name: Verify binary run: ./bin/lolly --help