v1: Add gc metrics #949
Workflow file for this run
This file contains 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: Go application CI/CD | |
on: | |
push: | |
branches: | |
- master | |
- v1 | |
tags: | |
- "*" | |
pull_request: | |
branches: | |
- master | |
- v1 | |
env: | |
TAG_NAME: "${GITHUB_REF##*/}" | |
jobs: | |
lint: | |
name: Lint code | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Golang with cache | |
uses: magnetikonline/action-golang-cache@v5 | |
with: | |
go-version: "^1.23" | |
- name: Lint code using golangci-lint | |
uses: golangci/golangci-lint-action@v6 | |
with: | |
version: latest | |
- name: Check go mod tidy | |
run: | | |
go mod tidy | |
git diff --exit-code -- go.mod go.sum | |
test: | |
name: Unit test code | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Golang with cache | |
uses: magnetikonline/action-golang-cache@v5 | |
with: | |
go-version: "^1.23" | |
- name: Test code | |
run: go test ./... -covermode=atomic -coverprofile=coverage.out | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
verify-helm-readme: | |
name: Verify that Helm README is up to date | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Node 18 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Install README generator | |
run: make install-helm-readme | |
- name: Generate README | |
run: make helm-readme | |
- name: Verify that there are no changes | |
run: git diff --exit-code || (echo "README.md is not up to date. Please use helm-readme and commit the changes." && exit 1) | |
- name: Print changes | |
run: git diff | |
if: failure() | |
verify-makefile-readme: | |
name: Verify that Makefile section of README is up to date | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Generate README | |
run: make update-readme-descriptions | |
- name: Verify that there are no changes | |
run: git diff --exit-code || (echo "README.md is not up to date. Please use makefile-readme and commit the changes." && exit 1) | |
- name: Print changes | |
run: git diff | |
if: failure() | |
lint-helm-chart: | |
name: Lint Helm chart | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: 3.11.0 | |
- name: Lint Helm chart | |
working-directory: ./chart | |
run: helm lint . | |
template-helm-chart: | |
name: Verify templating chart with default values | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: 3.11.2 | |
- name: Template Helm chart | |
working-directory: ./chart | |
run: helm template . > /dev/null | |
test-integration: | |
name: Test integration with Prometheus | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Compose | |
uses: ndeloof/[email protected] | |
with: | |
version: v2.24.5 | |
legacy: true | |
- name: Print compose version | |
run: docker-compose version | |
- name: Wait for compose | |
run: make wait-for-compose | |
- name: Run metrics integration test | |
run: make verify-metrics | |
- name: Generate metric names for README | |
run: ./scripts/add_metrics_to_readme.sh | |
- name: Verify that there are no changes | |
run: git diff --exit-code || echo "README.md is not up to date. Please use add_metrics_to_readme.sh and commit the changes." | |
- name: Shutdown compose | |
run: docker-compose down -v | |
build-linux: | |
name: Build Linux binary | |
runs-on: ubuntu-20.04 | |
needs: [lint, test] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Golang with cache | |
uses: magnetikonline/action-golang-cache@v5 | |
with: | |
go-version: "^1.23" | |
- name: Build Linux binary | |
run: make build-linux | |
env: | |
VERSION: ${{ github.ref }} | |
- name: Upload Linux binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: logstash-exporter-linux | |
path: out/main-linux | |
build-linux-arm: | |
name: Build Linux ARM binary | |
runs-on: ubuntu-20.04 | |
needs: [lint, test] | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Golang with cache | |
uses: magnetikonline/action-golang-cache@v5 | |
with: | |
go-version: "^1.23" | |
- name: Build Linux ARM binary | |
run: make build-linux-arm | |
env: | |
VERSION: ${{ github.ref }} | |
- name: Upload Linux ARM binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: logstash-exporter-linux-arm | |
path: out/main-linux-arm | |
build-darwin: | |
name: Build Mac binary | |
runs-on: ubuntu-20.04 | |
needs: [lint, test] | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Golang with cache | |
uses: magnetikonline/action-golang-cache@v5 | |
with: | |
go-version: "^1.23" | |
- name: Build Mac binary | |
run: make build-darwin | |
env: | |
VERSION: ${{ github.ref }} | |
- name: Upload Mac binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: logstash-exporter-darwin | |
path: out/main-darwin | |
build-windows: | |
name: Build Windows binary | |
runs-on: ubuntu-20.04 | |
needs: [lint, test] | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Golang with cache | |
uses: magnetikonline/action-golang-cache@v5 | |
with: | |
go-version: "^1.23" | |
- name: Build Windows binary | |
run: make build-windows | |
env: | |
VERSION: ${{ github.ref }} | |
- name: Upload Windows binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: logstash-exporter-windows | |
path: out/main-windows | |
build-linux-docker-image: | |
name: Build Linux Docker image | |
runs-on: ubuntu-20.04 | |
needs: [build-linux] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Build Docker image | |
run: make build-docker | |
- name: Package Docker image | |
run: docker save logstash-exporter:latest | gzip > logstash-exporter.tar.gz | |
- name: Upload Docker image as an artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: logstash-exporter-docker-image | |
path: logstash-exporter.tar.gz | |
retention-days: 1 | |
- name: Login to GitHub registry | |
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master' | |
run: echo ${{ secrets.GH_PAT }} | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin | |
- name: Login to Docker Hub | |
if: startsWith(github.ref, 'refs/tags/') | |
run: echo ${{ secrets.DOCKER_HUB_PAT }} | docker login -u ${{ github.repository_owner }} --password-stdin | |
- name: Tag Docker image with master | |
if: github.ref == 'refs/heads/master' | |
run: docker tag logstash-exporter:latest ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:master | |
- name: Tag Docker image with tag to Docker Hub | |
if: startsWith(github.ref, 'refs/tags/') | |
run: docker tag logstash-exporter:latest ${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ env.TAG_NAME }} | |
- name: Tag Docker image with tag to ghcr.io | |
if: startsWith(github.ref, 'refs/tags/') | |
run: docker tag logstash-exporter:latest ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ env.TAG_NAME }} | |
- name: Push Docker image to GitHub registry | |
if: github.ref == 'refs/heads/master' | |
run: docker push ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:master | |
- name: Push Docker image with tag to Docker Hub | |
if: startsWith(github.ref, 'refs/tags/') | |
run: docker push ${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ env.TAG_NAME }} | |
- name: Push Docker image with tag to ghcr.io | |
if: startsWith(github.ref, 'refs/tags/') | |
run: docker push ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ env.TAG_NAME }} | |
build-docker-linux-arm-image: | |
name: Build Linux ARM Docker image | |
runs-on: ubuntu-20.04 | |
needs: [build-linux] | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
if: startsWith(github.ref, 'refs/tags/') | |
run: echo ${{ secrets.DOCKER_HUB_PAT }} | docker login -u ${{ github.repository_owner }} --password-stdin | |
- name: Build Docker image | |
run: "VERSION=${{ env.TAG_NAME }} DOCKER_IMG=${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ env.TAG_NAME }} make build-docker-multi" | |
test-helm-integration: | |
name: Test integration with Helm chart | |
runs-on: ubuntu-20.04 | |
needs: | |
- verify-helm-readme | |
- lint-helm-chart | |
- template-helm-chart | |
- build-linux-docker-image | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download Docker image | |
uses: actions/download-artifact@v4 | |
with: | |
name: logstash-exporter-docker-image | |
path: .helm/files | |
- name: Load Docker image | |
run: docker load -i .helm/files/logstash-exporter.tar.gz | |
- name: Install Helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: 3.11.2 | |
- name: Include current chart versions | |
working-directory: .helm/logstash-integration-test-chart | |
run: helm dependency update | |
- name: Create k8s Kind Cluster | |
uses: helm/[email protected] | |
with: | |
cluster_name: kind-chart-testing | |
- name: Export Docker image to Kind cluster | |
run: kind load docker-image logstash-exporter:latest --name kind-chart-testing | |
- name: Install Helm chart | |
working-directory: .helm/logstash-integration-test-chart | |
run: helm install --atomic --wait --timeout 15m --debug logstash-integration-test-chart . | |
create-release: | |
name: Create GitHub release | |
runs-on: ubuntu-20.04 | |
permissions: | |
contents: write | |
packages: write | |
outputs: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
release_id: ${{ steps.create_release.outputs.id }} | |
needs: | |
- build-linux | |
- build-darwin | |
- build-windows | |
- build-linux-arm | |
- build-linux-docker-image | |
- build-docker-linux-arm-image | |
- test-integration | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Output tag information | |
run: | | |
echo "Tag name: ${{ env.TAG_NAME }}" | |
echo "Tag ref: ${{ github.ref }}" | |
- name: Generate release notes | |
run: ./scripts/create_release_notes.sh | |
- name: Create GitHub release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_PAT }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
body_path: "./release_notes.txt" | |
draft: false | |
prerelease: false | |
upload-binaries: | |
strategy: | |
matrix: | |
binary: [linux, darwin, windows, linux-arm] | |
runs-on: ubuntu-20.04 | |
needs: | |
- create-release | |
- build-linux | |
- build-darwin | |
- build-windows | |
- build-linux-arm | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- name: Download binary | |
uses: actions/download-artifact@v4 | |
with: | |
name: logstash-exporter-${{ matrix.binary }} | |
- name: Generate sha256 checksum | |
run: | | |
CHECKSUM_FILE="main-${{ matrix.binary }}.sha256" | |
sha256sum main-${{ matrix.binary }} | cut -d ' ' -f1 | tr -d $'\n' > "$CHECKSUM_FILE" | |
echo -n ' logstash-exporter-${{ matrix.binary }}' >> "$CHECKSUM_FILE" | |
- name: Upload binary to GitHub release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_PAT }} | |
with: | |
upload_url: ${{ needs.create-release.outputs.upload_url }} | |
asset_path: main-${{ matrix.binary }} | |
asset_name: logstash-exporter-${{ matrix.binary }} | |
asset_content_type: application/octet-stream | |
- name: Upload sha256 checksum to GitHub release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_PAT }} | |
with: | |
upload_url: ${{ needs.create-release.outputs.upload_url }} | |
asset_path: main-${{ matrix.binary }}.sha256 | |
asset_name: logstash-exporter-${{ matrix.binary }}.sha256 | |
asset_content_type: text/plain |