Skip to content

Bump golang from 1.20.5-alpine3.17 to 1.20.6-alpine3.17 #397

Bump golang from 1.20.5-alpine3.17 to 1.20.6-alpine3.17

Bump golang from 1.20.5-alpine3.17 to 1.20.6-alpine3.17 #397

Workflow file for this run

name: Go application CI/CD
on:
push:
branches:
- master
tags:
- "*"
pull_request:
branches:
- master
env:
GOLANGCI_LINT_VERSION: v1.51.1
TAG_NAME: "${GITHUB_REF##*/}"
jobs:
lint:
name: Lint code
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v4
with:
go-version: "^1.20"
- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/local/bin ${GOLANGCI_LINT_VERSION}
- name: Lint code
run: golangci-lint run
test:
name: Unit test code
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v4
with:
go-version: "^1.20"
- 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@v3
- name: Install Node 18
uses: actions/setup-node@v3
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."
lint-helm-chart:
name: Lint Helm chart
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- 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@v3
- 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@v3
- name: Install Compose
uses: ndeloof/install-compose-action@v0.0.1
with:
version: v2.15.1
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@v3
- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v4
with:
go-version: "^1.20"
- name: Build Linux binary
run: make build-linux
env:
VERSION: ${{ github.ref }}
- name: Upload Linux binary
uses: actions/upload-artifact@v3
with:
name: logstash-exporter-linux
path: out/main-linux
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@v3
- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v4
with:
go-version: "^1.20"
- name: Build Mac binary
run: make build-darwin
env:
VERSION: ${{ github.ref }}
- name: Upload Mac binary
uses: actions/upload-artifact@v3
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@v3
- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v4
with:
go-version: "^1.20"
- name: Build Windows binary
run: make build-windows
env:
VERSION: ${{ github.ref }}
- name: Upload Windows binary
uses: actions/upload-artifact@v3
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@v3
- 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@v3
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 }}
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@v3
- name: Download Docker image
uses: actions/download-artifact@v3
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/kind-action@v1.7.0
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-docker-image
- test-integration
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v3
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]
runs-on: ubuntu-20.04
needs:
- create-release
- build-linux
- build-darwin
- build-windows
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download binary
uses: actions/download-artifact@v3
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