perf: restore producer throughput in compat produce config decode (#415) #96
Workflow file for this run
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: Build and publish xk6-kafka | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| permissions: {} | |
| jobs: | |
| build-binaries: | |
| name: Build ${{ matrix.name }} | |
| runs-on: ${{ matrix.os }} | |
| permissions: | |
| contents: read | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: linux-amd64 | |
| os: ubuntu-latest | |
| - name: linux-arm64 | |
| os: ubuntu-24.04-arm | |
| - name: darwin-amd64 | |
| os: macos-latest | |
| goarch: amd64 | |
| - name: darwin-arm64 | |
| os: macos-latest | |
| - name: windows-amd64 | |
| os: windows-latest | |
| defaults: | |
| run: | |
| shell: bash | |
| env: | |
| CGO_ENABLED: "1" | |
| steps: | |
| - name: Checkout 🛎️ | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Install Go 🧑💻 | |
| uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0 | |
| with: | |
| go-version: "1.26.1" | |
| cache: false | |
| - name: Install Windows MinGW-w64 toolchain 🧰 | |
| if: runner.os == 'Windows' | |
| uses: msys2/setup-msys2@cafece8e6baf9247cf9b1bf95097b0b983cc558d # v2.31.0 | |
| with: | |
| msystem: MINGW64 | |
| path-type: inherit | |
| update: true | |
| install: >- | |
| mingw-w64-x86_64-gcc | |
| - name: Install Linux native build prerequisites 🧰 | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y pkg-config librdkafka-dev | |
| - name: Install macOS native build prerequisites 🧰 | |
| if: runner.os == 'macOS' | |
| run: brew install pkg-config librdkafka | |
| - name: Install xk6 and build xk6-kafka 🏗️ | |
| if: runner.os != 'Windows' && matrix.goarch == '' | |
| run: | | |
| mkdir -p dist | |
| go install go.k6.io/xk6/cmd/xk6@latest | |
| BINARY="xk6-kafka_${GITHUB_REF_NAME}_$(go env GOOS)_$(go env GOARCH)" | |
| xk6 build --output "dist/${BINARY}" --with "github.com/mostafa/xk6-kafka/v2@${GITHUB_REF_NAME}=." | |
| tar cvzf "dist/${BINARY}.tar.gz" -C dist "${BINARY}" | |
| - name: Install xk6 and cross-build xk6-kafka 🏗️ | |
| if: matrix.goarch != '' | |
| run: | | |
| mkdir -p dist | |
| go install go.k6.io/xk6/cmd/xk6@latest | |
| xk6 build --skip-cleanup --output /dev/null --with "github.com/mostafa/xk6-kafka/v2@${GITHUB_REF_NAME}=." 2>&1 | tee /tmp/xk6.log || true | |
| BUILD_DIR=$(sed -n 's/.* leaving directory \(.*\) intact/\1/p' /tmp/xk6.log) | |
| BINARY="xk6-kafka_${GITHUB_REF_NAME}_$(go env GOOS)_${{ matrix.goarch }}" | |
| CGO_ENABLED=1 GOARCH=${{ matrix.goarch }} go build -C "${BUILD_DIR}" -trimpath -ldflags="-s -w" -o "$(pwd)/dist/${BINARY}" . | |
| tar cvzf "dist/${BINARY}.tar.gz" -C dist "${BINARY}" | |
| - name: Install xk6 and build xk6-kafka on Windows 🏗️ | |
| if: runner.os == 'Windows' | |
| shell: msys2 {0} | |
| env: | |
| CC: gcc | |
| CXX: g++ | |
| run: | | |
| mkdir -p dist | |
| go install go.k6.io/xk6/cmd/xk6@latest | |
| BINARY="xk6-kafka_${GITHUB_REF_NAME}_windows_amd64.exe" | |
| xk6 build --output "dist/${BINARY}" --with "github.com/mostafa/xk6-kafka/v2@${GITHUB_REF_NAME}=." | |
| tar cvzf "dist/${BINARY}.tar.gz" -C dist "${BINARY}" | |
| - name: Upload dist artifact 📤 | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: k6-dist-${{ matrix.name }} | |
| path: dist/*.tar.gz | |
| publish: | |
| name: Publish images and GitHub Release | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build-binaries | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout 🛎️ | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Install Go 🧑💻 | |
| uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0 | |
| with: | |
| go-version: "1.26.1" | |
| cache: false | |
| - name: Download all build artifacts ⬇️ | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| path: _artifacts | |
| pattern: k6-dist-* | |
| merge-multiple: true | |
| - name: Prepare dist directory 📂 | |
| run: | | |
| mkdir -p dist | |
| cp -v _artifacts/*.tar.gz dist/ | |
| for f in dist/*.tar.gz; do tar xzf "$f" -C dist; done | |
| ls -la dist | |
| - name: Generate CycloneDX SBOM artifacts 📃 | |
| run: | | |
| go install github.com/CycloneDX/cyclonedx-gomod/cmd/cyclonedx-gomod@latest | |
| cyclonedx-gomod mod -json -licenses -output "code-cyclonedx-xk6-kafka-${GITHUB_REF_NAME}.json" | |
| - name: Docker meta 📝 | |
| id: meta | |
| uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0 | |
| with: | |
| images: mostafamoradian/xk6-kafka | |
| tags: | | |
| type=semver,pattern={{version}} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 | |
| - name: Login to DockerHub 🔒 | |
| uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push Docker image 🛳️ | |
| uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 | |
| with: | |
| context: . | |
| push: true | |
| platforms: linux/amd64,linux/arm64 | |
| build-args: VERSION_TAG=${{ github.ref_name }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| - name: Install cosign ⬇️ | |
| uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0 | |
| - name: Sign the Docker image ✍️ | |
| run: echo "${STEPS_META_OUTPUTS_TAGS}" | xargs -I {} cosign sign -y docker.io/{} | |
| env: | |
| STEPS_META_OUTPUTS_TAGS: ${{ steps.meta.outputs.tags }} | |
| - name: Verify the Docker image signature ✅ | |
| run: | | |
| echo "${STEPS_META_OUTPUTS_TAGS}" | xargs -I {} cosign verify --certificate-identity ${IDENTITY} --certificate-oidc-issuer ${OIDC_ISSUER_URL} docker.io/{} | |
| env: | |
| IDENTITY: ${{ secrets.IDENTITY }} | |
| OIDC_ISSUER_URL: ${{ secrets.OIDC_ISSUER_URL }} | |
| STEPS_META_OUTPUTS_TAGS: ${{ steps.meta.outputs.tags }} | |
| - name: Scan Docker image with Syft and generate SBOM 🦉 | |
| uses: anchore/sbom-action@fbfd9c6c189226748411491745178e0c2017392d # v0.20.10 | |
| with: | |
| image: mostafamoradian/xk6-kafka:${{ steps.meta.outputs.version }} | |
| artifact-name: docker-image-cyclonedx-xk6-kafka-${{ github.ref_name }}.json | |
| output-file: docker-image-cyclonedx-xk6-kafka-${{ github.ref_name }}.json | |
| format: cyclonedx-json | |
| dependency-snapshot: true | |
| - name: Create release and upload binaries/SBOM files 💾 | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| files=( | |
| dist/*.tar.gz | |
| "code-cyclonedx-xk6-kafka-${GITHUB_REF_NAME}.json" | |
| "docker-image-cyclonedx-xk6-kafka-${GITHUB_REF_NAME}.json" | |
| ) | |
| if gh release view "${GITHUB_REF_NAME}" >/dev/null 2>&1; then | |
| gh release upload "${GITHUB_REF_NAME}" "${files[@]}" --clobber | |
| else | |
| gh release create "${GITHUB_REF_NAME}" "${files[@]}" \ | |
| --title "${GITHUB_REF_NAME}" \ | |
| --generate-notes | |
| fi |