From 5e98940b89dc0fc3f3c18193c5aee101a0e98ca2 Mon Sep 17 00:00:00 2001 From: chankyin Date: Fri, 22 Nov 2024 16:09:24 +0800 Subject: [PATCH] ci: add release and PR workflows --- .github/dependabot.yml | 34 +++++++++++++++++++++- .github/workflows/ci.yml | 55 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 41 ++++++++++++++++++++++++++ Earthfile | 15 +++++++++- 4 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 9aa5f33..c8d2bdc 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,6 +1,38 @@ version: 2 updates: - package-ecosystem: gomod - directory: / + directory: /tools + schedule: + interval: weekly + - package-ecosystem: gomod + directory: /apis + schedule: + interval: weekly + - package-ecosystem: gomod + directory: /client + schedule: + interval: weekly + - package-ecosystem: gomod + directory: /util + schedule: + interval: weekly + - package-ecosystem: gomod + directory: /generator + schedule: + interval: weekly + - package-ecosystem: gomod + directory: /aggregator + schedule: + interval: weekly + - package-ecosystem: gomod + directory: /webhook + schedule: + interval: weekly + - package-ecosystem: gomod + directory: /tests + schedule: + interval: weekly + - package-ecosystem: gomod + directory: /allinone schedule: interval: weekly diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..832b32c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,55 @@ +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: ssh-agent 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: ssh-agent earthly -P +e2e + + lint: + name: golangci-lint + runs-on: [ubuntu-22.04] + steps: + - uses: actions/checkout@v4 + - uses: earthly/actions-setup@v1 + with: + version: 'v0.8.0' + - name: Run linters + run: ssh-agent earthly +lint + + typos: + name: Check typos + runs-on: [ubuntu-22.04] + steps: + - uses: actions/checkout@v4 + - uses: crate-ci/typos@master + with: + config: typos.toml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1c78b70 --- /dev/null +++ b/.github/workflows/release.yml @@ -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: ssh-agent 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: | + ssh-agent earthly --ci --secret docker_config="$(cat ~/.docker/config.json)" \ + +chart-push --chart_version=${{github.ref_name}} --app_version=${{github.ref_name}} diff --git a/Earthfile b/Earthfile index 9039a57..06c7793 100644 --- a/Earthfile +++ b/Earthfile @@ -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