ci: inline gofmt hook and remove helper scripts #78
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 ] | |
| jobs: | |
| lint-and-test: | |
| name: Lint / Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.23' | |
| cache: true | |
| - name: Install golangci-lint | |
| run: | | |
| curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.4.0 | |
| echo "$(go env GOPATH)/bin" >> $GITHUB_PATH | |
| - name: Check gofmt | |
| run: | | |
| echo "Checking gofmt..." | |
| files=$(gofmt -s -l .) | |
| if [ -n "$files" ]; then | |
| echo "The following files need gofmt -s (please run 'gofmt -s -w .' locally):" | |
| echo "$files" | |
| exit 1 | |
| fi | |
| - name: Run golangci-lint | |
| run: golangci-lint run --timeout=5m | |
| - name: Run unit tests | |
| run: | | |
| go test -v -mod vendor ./... | |
| - name: Run vendor package tests | |
| run: | | |
| # Run tests that live in the vendor directory. These validate fixes in the vendored client. | |
| go test -v ./vendor/... | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - goos: linux | |
| goarch: amd64 | |
| - goos: linux | |
| goarch: arm64 | |
| - goos: darwin | |
| goarch: amd64 | |
| - goos: darwin | |
| goarch: arm64 | |
| - goos: windows | |
| goarch: amd64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.23' | |
| - name: Build | |
| run: | | |
| go build -mod vendor -o ./bin/prometheus-plex-exporter ./cmd/prometheus-plex-exporter | |
| env: | |
| CGO_ENABLED: "0" | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: prometheus-plex-exporter-${{ matrix.goos }}-${{ matrix.goarch }} | |
| path: ./bin |