diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 503746c..714af45 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,31 +1,59 @@ -name: Release +name: CI on: push: - tags: - - 'v*' + pull_request: + branches: + - main + +env: + GO_VERSION: 1.22 + GORELEASER_VERSION: v1.25.1 jobs: - release: + lint: + name: Lint runs-on: ubuntu-latest steps: - - name: Checkout code + - name: Check out source code uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v6 with: - fetch-depth: 0 + version: latest + + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '1.22' - - name: Login to DockerHub - uses: docker/login-action@v3 + go-version: ${{ env.GO_VERSION }} + - name: Cache Go modules + uses: actions/cache@v4 with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_TOKEN }} - - name: Run goreleaser + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Install goreleaser uses: goreleaser/goreleaser-action@v5 with: - version: v1.25.1 - args: release --clean - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + version: ${{ env.GORELEASER_VERSION }} + install-only: true + - name: Build + run: goreleaser build --clean --snapshot + - name: Run tests + run: go test -v ./... + + release: + needs: [build, lint] + uses: ./.github/workflows/release.yml + if: startsWith(github.ref, 'refs/tags/v') \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..723228f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +name: Release + +on: + workflow_call: + +env: + GO_VERSION: 1.22 + GORELEASER_VERSION: v1.25.1 + +jobs: + release: + runs-on: ubuntu-latest + environment: release + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + - name: Run goreleaser + uses: goreleaser/goreleaser-action@v5 + with: + version: ${{ env.GORELEASER_VERSION }} + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/server/config.go b/server/config.go index a4e314e..8abc633 100644 --- a/server/config.go +++ b/server/config.go @@ -20,7 +20,7 @@ import ( "github.com/c2h5oh/datasize" "github.com/palantir/go-baseapp/baseapp" - "github.com/palantir/go-baseapp/baseapp/datadog" + "github.com/palantir/go-baseapp/appmetrics/emitter/datadog" "github.com/palantir/go-githubapp/githubapp" "github.com/pkg/errors" "gopkg.in/yaml.v2" diff --git a/server/server.go b/server/server.go index b310b05..91ec846 100644 --- a/server/server.go +++ b/server/server.go @@ -25,7 +25,7 @@ import ( "github.com/die-net/lrucache" "github.com/gregjones/httpcache" "github.com/palantir/go-baseapp/baseapp" - "github.com/palantir/go-baseapp/baseapp/datadog" + "github.com/palantir/go-baseapp/appmetrics/emitter/datadog" "github.com/palantir/go-githubapp/githubapp" "github.com/palantir/policy-bot/pull" "github.com/pkg/errors"