From 16de03853559a91904e36132cfa04280da346641 Mon Sep 17 00:00:00 2001 From: Conor Mongey Date: Mon, 6 Sep 2021 14:39:51 +0100 Subject: [PATCH] Add GitHub Actions CI + release --- .circleci/config.yml | 40 ----------------------- .github/dependabot.yml | 17 ++++++++++ .github/workflows/ci.yml | 47 ++++++++++++++++++++++++++ .github/workflows/release.yml | 41 +++++++++++++++++++++++ .github/workflows/snapshot.yml | 40 +++++++++++++++++++++++ docker-compose.yaml | 60 ++++++++++++++++++++++++++++++++++ 6 files changed, 205 insertions(+), 40 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/snapshot.yml create mode 100644 docker-compose.yaml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index a5b9629..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,40 +0,0 @@ -version: 2 -jobs: - build: - working_directory: /go/src/github.com/Mongey/vault-plugin-secrets-kafka - docker: - - image: circleci/golang:1.11 - environment: - TEST_RESULTS: /tmp/test-results - - image: confluentinc/cp-zookeeper:latest - environment: - ZOOKEEPER_CLIENT_PORT: 2181 - ZOOKEEPER_TICK_TIME: 2000 - - image: mongey/kafka:5.0.1 - environment: - KAFKA_BROKER_ID: 1 - KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 - KAFKA_ZOOKEEPER_CONNECT: localhost:2181 - KAFKA_LOG_SEGMENT_BYTES: 1234 - steps: - - checkout - - run: go build - - store_artifacts: - path: /go/src/github.com/Mongey/vault-plugin-secrets-kafka/vault-plugin-secrets-kafka - destination: vault-plugin-secrets-kafka - - run: make test - - run: go get github.com/jstemmer/go-junit-report - - run: mkdir -p $TEST_RESULTS - - run: - name: Run Tests - command: | - trap "go-junit-report <${TEST_RESULTS}/go-test.out > ${TEST_RESULTS}/go-test-report.xml" EXIT - make testacc| tee ${TEST_RESULTS}/go-test.out - - store_test_results: - path: /tmp/test-results - -workflows: - version: 2 - build: - jobs: - - build diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..203cd3d --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,17 @@ +# See GitHub's docs for more information on this file: +# https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/configuration-options-for-dependency-updates +version: 2 +updates: + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + # Check for updates to GitHub Actions every weekday + interval: "daily" + + # Maintain dependencies for Go modules + - package-ecosystem: "gomod" + directory: "/" + schedule: + # Check for updates to Go modules every weekday + interval: "daily" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..56740d5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,47 @@ +name: CI + +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.17.x + - run: make test + + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: golangci-lint + uses: golangci/golangci-lint-action@v2 + with: + # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. + version: v1.29 + + acctest: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.17.x + - uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Bring up kafka + zk + run: docker-compose up -d + - name: "Run tests" + run: make testacc diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..5914ea1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,41 @@ +name: release + +on: + push: + tags: + - 'v*' + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.16.x + - name: Import GPG key + id: import_gpg + uses: crazy-max/ghaction-import-gpg@v3.1.0 + with: + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.PASSPHRASE }} + - uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + key: ${{ secrets.YOUR_PRIVATE_KEY }} + env: + GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml new file mode 100644 index 0000000..b5782cb --- /dev/null +++ b/.github/workflows/snapshot.yml @@ -0,0 +1,40 @@ +name: Build Snapshots + +on: + push: + branches: + - '**' + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.16.x + - name: Import GPG key + id: import_gpg + uses: crazy-max/ghaction-import-gpg@v3.1.0 + with: + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.PASSPHRASE }} + - uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --snapshot --rm-dist + key: ${{ secrets.YOUR_PRIVATE_KEY }} + env: + GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..ad9543a --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,60 @@ +--- +version: '3.2' +services: + zookeeper: + image: confluentinc/cp-zookeeper:latest + ports: + - "2181:2181" + environment: + ZOOKEEPER_CLIENT_PORT: 2181 + ZOOKEEPER_TICK_TIME: 2000 + extra_hosts: + - "moby:127.0.0.1" + + kafka1: + build: + context: . + dockerfile: Dockerfile.kafka + args: + broker_id: 1 + zookeeper_connect: zookeeper:2181 + listener_host: kafka1 + listener_port: 9092 + ports: + - "9092:9092" + depends_on: + - zookeeper + extra_hosts: + - "moby:127.0.0.1" + + kafka2: + build: + context: . + dockerfile: Dockerfile.kafka + args: + broker_id: 2 + zookeeper_connect: zookeeper:2181 + listener_host: kafka2 + listener_port: 9093 + ports: + - "9093:9092" + depends_on: + - zookeeper + extra_hosts: + - "moby:127.0.0.1" + + kafka3: + build: + context: . + dockerfile: Dockerfile.kafka + args: + broker_id: 3 + zookeeper_connect: zookeeper:2181 + listener_host: kafka3 + listener_port: 9094 + ports: + - "9094:9092" + depends_on: + - zookeeper + extra_hosts: + - "moby:127.0.0.1"