From 8c0148e604966f7405e9f4f4226410d7b41f3a51 Mon Sep 17 00:00:00 2001 From: sunba91-su Date: Mon, 8 Jun 2026 16:56:26 +0330 Subject: [PATCH 1/4] ci: add enhanced CI pipeline, release workflow, and proxy support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - CI: 4 jobs (lint/build/test+docker) with race detection, coverage artifact, and ghcr.io push on main - Release: on v* tag — vet+test, Docker push with semver+latest tags, auto-generated release notes via softprops/action-gh-release - Dockerfile: proxy ARGs for local builds behind filtered internet - docker-compose.yml: proxy args passthrough from .env - Makefile: proxy-forwarding docker-build target - .env.example: commented proxy vars Closes #9 --- .env.example | 4 +++ .github/workflows/ci.yml | 56 ++++++++++++++++++++++++++++++----- .github/workflows/release.yml | 50 +++++++++++++++++++++++++++++++ Dockerfile | 3 ++ Makefile | 6 +++- docker-compose.yml | 4 +++ 6 files changed, 115 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.env.example b/.env.example index a931650..390c9b0 100644 --- a/.env.example +++ b/.env.example @@ -3,3 +3,7 @@ ROCKETCHAT_BOT_USERNAME=geekbot ROCKETCHAT_BOT_PASSWORD=your-password ROCKETCHAT_MAIN_ADMIN=admin_username STANDUP_DB_PATH=/data/standup-bot.db + +# http_proxy=http://proxy:port +# https_proxy=http://proxy:port +# no_proxy=localhost,127.0.0.1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2af188d..377c769 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,9 +4,22 @@ on: push: branches: [main] pull_request: - branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: "1.22" + cache: true + - run: go vet ./... + build: runs-on: ubuntu-latest steps: @@ -15,9 +28,38 @@ jobs: with: go-version: "1.22" cache: true - - name: Vet - run: go vet ./... - - name: Build - run: go build ./... - - name: Test - run: go test ./... + - run: go build ./... + + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: "1.22" + cache: true + - run: go test ./... -count=1 -race -coverprofile=coverage.out + - uses: actions/upload-artifact@v4 + with: + name: coverage + path: coverage.out + + docker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Smoke test + run: docker build . + - name: Log in to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v6 + with: + push: ${{ github.ref == 'refs/heads/main' }} + tags: | + ghcr.io/sunba91-su/roket.chat-geekbot:latest + ghcr.io/sunba91-su/roket.chat-geekbot:${{ github.sha }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..32a46a9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,50 @@ +name: Release + +on: + push: + tags: + - "v*.*.*" + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: "1.22" + cache: true + + - name: Vet and test + run: | + go vet ./... + go test ./... -count=1 -race + + - name: Extract version from tag + id: meta + run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + + - name: Log in to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + push: true + tags: | + ghcr.io/sunba91-su/roket.chat-geekbot:${{ steps.meta.outputs.VERSION }} + ghcr.io/sunba91-su/roket.chat-geekbot:latest + + - name: Generate release notes + uses: softprops/action-gh-release@v2 + with: + generate_release_notes: true + name: v${{ steps.meta.outputs.VERSION }} diff --git a/Dockerfile b/Dockerfile index 4ad2bed..3c8e1dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,7 @@ FROM golang:1.22-alpine AS builder +ARG http_proxy +ARG https_proxy +ARG no_proxy RUN apk add --no-cache ca-certificates tzdata && \ adduser -D -u 1001 appuser WORKDIR /src diff --git a/Makefile b/Makefile index 22406c4..3e3b4be 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,11 @@ clean: rm -rf $(BIN_DIR)/ docker-build: - docker build -t $(APP_NAME) . + docker build \ + --build-arg http_proxy \ + --build-arg https_proxy \ + --build-arg no_proxy \ + -t $(APP_NAME) . docker-run: docker compose up -d --build diff --git a/docker-compose.yml b/docker-compose.yml index 08562ac..3b36b7f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,10 @@ services: build: context: . dockerfile: Dockerfile + args: + http_proxy: "${http_proxy:-}" + https_proxy: "${https_proxy:-}" + no_proxy: "${no_proxy:-}" container_name: geekbot restart: unless-stopped env_file: .env From 82794328557e92a642afaa34c3c367cce7f367cd Mon Sep 17 00:00:00 2001 From: sunba91-su Date: Mon, 8 Jun 2026 17:02:02 +0330 Subject: [PATCH 2/4] fix: remove -coverprofile flag from CI test step covdata tool conflicts with -race on Go 1.22 runner. Replace with -cover flag for inline coverage output. --- .github/workflows/ci.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 377c769..e84355f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,11 +38,7 @@ jobs: with: go-version: "1.22" cache: true - - run: go test ./... -count=1 -race -coverprofile=coverage.out - - uses: actions/upload-artifact@v4 - with: - name: coverage - path: coverage.out + - run: go test ./... -count=1 -race -cover docker: runs-on: ubuntu-latest From 5508035b5dc23793623871c8ff5980843791b8a2 Mon Sep 17 00:00:00 2001 From: sunba91-su Date: Mon, 8 Jun 2026 17:07:58 +0330 Subject: [PATCH 3/4] fix: bump builder image to golang:1.25-alpine go.mod requires go 1.25.3 but Dockerfile used 1.22-alpine, causing go mod download to fail with version mismatch. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3c8e1dc..63a206e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.22-alpine AS builder +FROM golang:1.25-alpine AS builder ARG http_proxy ARG https_proxy ARG no_proxy From 54dfb90e387f41f9ed5f78907fb3ec80f98cbe65 Mon Sep 17 00:00:00 2001 From: sunba91-su Date: Mon, 8 Jun 2026 17:12:03 +0330 Subject: [PATCH 4/4] fix: remove -cover flag from CI test step covdata tool conflicts with -race on Go 1.22 runner for packages without test files, causing CI to fail with exit code 1. Coverage tracking moved to issue #21. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e84355f..02f67cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: with: go-version: "1.22" cache: true - - run: go test ./... -count=1 -race -cover + - run: go test ./... -count=1 -race docker: runs-on: ubuntu-latest