Skip to content

Commit

Permalink
ci: add release and PR workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
SOF3 committed Nov 22, 2024
1 parent 31a0c7a commit 02a07de
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 1 deletion.
59 changes: 59 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CI

on:
pull_request:
push:
workflow_dispatch:

jobs:
test:
name: Run unit tests
runs-on: [ubuntu-22.04]
steps:
- uses: actions/checkout@v4
- uses: earthly/actions-setup@v1
with:
version: 'v0.8.0'
- name: Run unit tests
run: earthly +test
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
files: output/coverage.out

e2e:
name: Run e2e tests
runs-on: [ubuntu-22.04]
steps:
- uses: actions/checkout@v4
- uses: earthly/actions-setup@v1
with:
version: 'v0.8.0'
- name: Run e2e tests
run: earthly -P +e2e

lint:
name: golangci-lint
runs-on: [ubuntu-22.04]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.23.2'
- run: rm -r tools
- name: Run lint
uses: golangci/golangci-lint-action@v6
with:
args: --timeout=10m
only-new-issues: true

typos:
name: Check typos
runs-on: [ubuntu-22.04]
steps:
- uses: actions/checkout@v4
- uses: crate-ci/typos@master
with:
config: typos.toml
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Release

on:
push:
tags: ["v*"]

jobs:
build:
name: Run unit tests
runs-on: [ubuntu-22.04]
steps:
- uses: actions/checkout@v4
- uses: earthly/actions-setup@v1
with:
version: 'v0.8.0'
- name: Docker login for ghcr
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: Build Docker images
run: earthly --ci --push +build --output_tag=${{github.ref_name}}
chart:
name: Build helm chart
runs-on: [ubuntu-22.04]
steps:
- uses: actions/checkout@v4
- uses: earthly/actions-setup@v1
with:
version: 'v0.8.0'
- name: Docker login for ghcr
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: Build helm chart
run: |
earthly --ci --secret docker_config="$(cat ~/.docker/config.json)" \
+chart-push --chart_version=${{github.ref_name}} --app_version=${{github.ref_name}}
15 changes: 14 additions & 1 deletion Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,27 @@ chart:
RUN apk add --no-cache helm kubectl

ARG app_version='v0.0.0-dev'
ARG chart_version='0.0.0'

COPY chart chart
COPY +crd-gen/crds chart/crds
RUN helm package --app-version $app_version chart
RUN helm package --version="$chart_version" --app-version="$app_version" chart
RUN mv *.tgz chart.tgz

SAVE ARTIFACT chart.tgz AS LOCAL output/chart.tgz

chart-push:
FROM +golang-base

RUN apk add --no-cache helm

ARG registry='ghcr.io'
ARG path_prefix='kubewharf'

COPY +chart/chart.tgz chart.tgz
RUN --mount type=secret,target=/root/.docker/config.json,id=docker_config \
helm push chart.tgz oci://${registry}/${path_prefix}

build-kwok:
FROM +golang-base

Expand Down

0 comments on commit 02a07de

Please sign in to comment.