Skip to content

Commit

Permalink
Update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jantomgid committed Jul 11, 2024
1 parent e37cea9 commit 16f3e05
Showing 1 changed file with 75 additions and 12 deletions.
87 changes: 75 additions & 12 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
name: Go

on: [push, pull_request]
on:
push:
branches:
- master
- feat-*
- ci
tags:
- v*

env:
GO_VERSION: "1.22"
GHCR_REGISTRY_IMAGE: ghcr.io/${{ github.repository }}

jobs:
lint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go-version: ["1.21", "1.22"]
name: Lint ${{ matrix.go-version == '1.22' && '(latest)' || '(old)' }}

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
go-version: ${{ env.GO_VERSION }}
cache: true

- name: Install libolm
run: sudo apt-get install libolm-dev libolm3

- name: Install goimports
run: |
go install golang.org/x/tools/cmd/goimports@latest
Expand All @@ -34,5 +37,65 @@ jobs:
- name: Lint
run: pre-commit run -a

- name: Build
run: go build
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true

- name: Install libolm
run: sudo apt-get install libolm-dev libolm3 gobjc++-mingw-w64

- name: Set up gotestfmt
uses: GoTestTools/gotestfmt-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Run tests
run: |
go test -v -json ./... -cover | gotestfmt
build-docker:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to docker registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker metadata
uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.GHCR_REGISTRY_IMAGE }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=sha,format=long
type=raw,latest
- name: Docker Build and push
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.ci
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.GHCR_REGISTRY_IMAGE }}:latest
cache-to: type=inline

0 comments on commit 16f3e05

Please sign in to comment.