From d4dbac9ff3c0cb319bce6d028d7ad5893236d3af Mon Sep 17 00:00:00 2001 From: Danyal Prout Date: Thu, 30 May 2024 09:44:37 -0500 Subject: [PATCH 1/4] Add CI --- .github/workflows/pr.yml | 37 +++++++++++++++++++++++++++++++++++++ Makefile | 6 +++++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/pr.yml diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..3da399f --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,37 @@ +name: Pull Request + +on: + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + arch: [ linux/amd64, linux/arm64 ] + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '>=1.21.0' + - name: Go Format + run: make fmt && git diff --exit-code + - name: Go Vet + run: make vet + - name: Go Tidy + run: go mod tidy && git diff --exit-code + - name: Go Mod + run: go mod download + - name: Go Mod Verify + run: go mod verify + - name: Go Build + run: make build + - name: Go Build + run: make test + + + + + diff --git a/Makefile b/Makefile index d2a9528..6cbd8bc 100644 --- a/Makefile +++ b/Makefile @@ -26,11 +26,15 @@ integration: RUN_INTEGRATION_TESTS=true go test -v ./... .PHONY: integration +vet: + go vet ./... +.PHONY: vet + fmt: gofmt -s -w . .PHONY: fmt -check: fmt clean build build-docker lint test integration +check: fmt vet clean build build-docker lint test integration .PHONY: check lint: From 3eef4b1ce4102a9218080f115a5f604610abf8e9 Mon Sep 17 00:00:00 2001 From: Danyal Prout Date: Thu, 30 May 2024 09:47:45 -0500 Subject: [PATCH 2/4] Run go mod tidy --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 2cb133e..7e86467 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,7 @@ require ( github.com/go-chi/chi/v5 v5.0.12 github.com/minio/minio-go/v7 v7.0.66 github.com/prometheus/client_golang v1.19.0 + github.com/rs/zerolog v1.32.0 github.com/stretchr/testify v1.9.0 github.com/urfave/cli/v2 v2.27.1 ) @@ -77,7 +78,6 @@ require ( github.com/rivo/uniseg v0.4.3 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/rs/xid v1.5.0 // indirect - github.com/rs/zerolog v1.32.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/shirou/gopsutil v3.21.11+incompatible // indirect github.com/sirupsen/logrus v1.9.3 // indirect From 74ccbaab4a268bbe500ada6a8a85868c9564356c Mon Sep 17 00:00:00 2001 From: Danyal Prout Date: Thu, 30 May 2024 10:30:59 -0500 Subject: [PATCH 3/4] Build docker on prs --- .github/workflows/pr.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 3da399f..019f357 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -16,6 +16,8 @@ jobs: uses: actions/setup-go@v5 with: go-version: '>=1.21.0' + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Go Format run: make fmt && git diff --exit-code - name: Go Vet @@ -26,12 +28,9 @@ jobs: run: go mod download - name: Go Mod Verify run: go mod verify - - name: Go Build - run: make build - - name: Go Build + - name: Go Test run: make test - - - - - + - name: Build Docker + uses: docker/build-push-action@v5 + with: + push: false From 3abf57b681d5ef05ecb171002706f8ea0595261f Mon Sep 17 00:00:00 2001 From: Danyal Prout Date: Thu, 30 May 2024 10:37:33 -0500 Subject: [PATCH 4/4] Push image on merge to master --- .github/workflows/docker.yml | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..6652c09 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,44 @@ +name: Tag Docker image + +on: + push: + branches: + - 'master' + tags: + - 'v*' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Log into the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata for the Docker image + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push the Docker image + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 \ No newline at end of file