Skip to content

Handle Nil pointer error and update linter #1173

Handle Nil pointer error and update linter

Handle Nil pointer error and update linter #1173

Workflow file for this run

name: Hegel
on:
push:
branches:
- "*"
tags-ignore:
- "v*"
pull_request:
env:
REGISTRY: quay.io
IMAGE: quay.io/${{ github.repository }}
CGO_ENABLED: 0
GO_VERSION: "1.21"
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
- run: make lint
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
- name: Run tests
run: go test -coverprofile=coverage.txt ./...
- name: Upload codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
integration:
name: Test - Integration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 5
- uses: actions/setup-go@v5
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
- name: Run integration tests
run: make test-integration
- name: Upload codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
build:
name: Build
strategy:
matrix:
platform: [amd64, arm64]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
- name: Build linux/${{ matrix.platform }}
run: make build GOARCH=${{ matrix.platform }}
- name: Upload linux/${{ matrix.platform }} binary
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }}
retention-days: 1
path: hegel-linux-${{ matrix.platform }}
e2e:
name: Test - E2E
runs-on: ubuntu-latest
needs: [test, integration]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 5
- uses: actions/setup-go@v5
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
- name: Run end-to-end tests
run: make test-e2e
- name: Upload codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
package:
name: Package
runs-on: ubuntu-latest
needs: [lint, build, test, e2e]
steps:
- uses: actions/checkout@v4
# We need to specify a name for the download action else artifacts are downloaded with
# whatever name they were uploaded with. Its required because the Dockerfile expects
# the filenames to be formatted appropriately for the platform.
- name: Download all binaries
uses: actions/download-artifact@v4
with:
merge-multiple: true
# The upload/download actions do not preserve permissions so they need explicitly setting.
- name: Fix binary permissions
run: chmod +x hegel-linux-*
- name: Generate image tags
uses: docker/metadata-action@v5
id: meta
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
images: ${{ env.IMAGE }}
flavor: latest=false
tags: |
type=sha
- name: Login to quay.io
uses: docker/login-action@v3
if: ${{ startsWith(github.ref, 'refs/heads/main') || startsWith(github.ref, 'refs/heads/v') }}
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- uses: docker/setup-buildx-action@v3
- name: Build images and push
uses: docker/build-push-action@v6
with:
context: ./
cache-from: type=registry,ref=${{ env.IMAGE }}:latest
push: ${{ startsWith(github.ref, 'refs/heads/main') || startsWith(github.ref, 'refs/heads/v') }}
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64