From db91a149484694d634311b73c54c61c133f05141 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 | 60 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 41 ++++++++++++++++++++++++ Earthfile | 15 ++++++++- chart/Chart.yaml | 2 +- 5 files changed, 149 insertions(+), 3 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..9049249 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,60 @@ +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 + - name: Upload logs + uses: actions/upload-artifact@v4 + with: + name: output + path: output + + 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..718ac5c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,41 @@ +name: Release + +on: + push: + tags: ["v*"] + +jobs: + build: + name: Build docker images + 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 --output --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 diff --git a/chart/Chart.yaml b/chart/Chart.yaml index ca93576..d8dd7f5 100644 --- a/chart/Chart.yaml +++ b/chart/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v2 -name: podseidon +name: podseidon-chart description: Integrated setup configuration for podseidon type: application version: 0.0.0