mirror-forgejo-helm/.forgejo/workflows/build.yml
2024-05-29 08:25:13 +02:00

195 lines
6 KiB
YAML

name: build
on:
pull_request:
push:
branches:
- main
- maint/**
tags:
- v*
permissions:
contents: read
env:
HELM_VERSION: v3.15.1 # renovate: datasource=github-releases depName=helm packageName=helm/helm
HELM_UNITTEST_VERSION: v0.5.1 # renovate: datasource=github-releases depName=helm-unittest packageName=helm-unittest/helm-unittest
HELM_CHART_TESTING_VERSION: v3.11.0 # renovate: datasource=github-releases depName=chart-testing packageName=helm/chart-testing
KIND_VERSION: v0.23.0 # renovate: datasource=github-releases depName=kind packageName=kubernetes-sigs/kind
KUBECTL_VERSION: v1.30.1 # renovate: datasource=github-releases depName=kubectl packageName=kubernetes/kubernetes
jobs:
lint-node:
runs-on: docker
steps:
- run: cat /etc/os-release
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
show-progress: false
- uses: ./.forgejo/actions/setup
- uses: ./.forgejo/actions/setup-node
- run: pnpm prettier
- run: pnpm markdownlint .
- run: make readme
- run: git diff --exit-code --name-only README.md
lint-helm:
runs-on: docker
steps:
- run: cat /etc/os-release
- run: ps axf
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
show-progress: false
fetch-depth: 0
filter: blob:none # We don't need all blobs
- uses: ./.forgejo/actions/setup
- name: install chart-testing
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1
with:
version: ${{ env.HELM_CHART_TESTING_VERSION }}
- name: install helm
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
with:
version: ${{ env.HELM_VERSION }}
- name: install helm-unittest
run: helm plugin install --version ${{ env.HELM_UNITTEST_VERSION }} https://github.com/helm-unittest/helm-unittest
- run: helm dependency build
- run: yamllint -f colored .
- run: helm lint
- run: helm template --debug gitea-helm .
- run: make unittests
- run: ct lint --config tools/ct.yml --charts .
e2e:
runs-on: k8s
strategy:
matrix:
k8s:
# from https://hub.docker.com/r/kindest/node/tags
- v1.27.13 # renovate: kindest
- v1.28.9 # renovate: kindest
- v1.29.4 # renovate: kindest
steps:
- run: cat /etc/os-release
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
show-progress: false
fetch-depth: 0
filter: blob:none # We don't need all blobs
- uses: ./.forgejo/actions/setup
- name: install helm
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
with:
version: ${{ env.HELM_VERSION }}
- name: Install chart-testing
# TODO: pin to version when this is released: https://github.com/helm/chart-testing-action/pull/137
uses: helm/chart-testing-action@4f62db170e3aa295575ba779f7141287841da474 # main
with:
version: ${{ env.HELM_CHART_TESTING_VERSION }}
- uses: ./.forgejo/actions/setup-docker
- name: Create kind cluster
uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde # v1.10.0
with:
node_image: kindest/node:${{ matrix.k8s }}
kubectl_version: ${{ env.KUBECTL_VERSION }}
version: ${{ env.KIND_VERSION }}
- run: kubectl get no -o wide
- name: install chart
uses: https://github.com/nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
with:
timeout_minutes: 15
max_attempts: 3
retry_on: error
retry_wait_seconds: 60
polling_interval_seconds: 5
command: ct install --config tools/ct.yml --charts .
# # Catch-all required check for test matrix
test-success:
needs:
- lint-node
- lint-helm
- e2e
runs-on: docker
timeout-minutes: 1
if: always()
steps:
- name: Fail for failed or cancelled lint-node
if: |
needs.lint-node.result == 'failure' ||
needs.lint-node.result == 'cancelled'
run: exit 1
- name: Fail for failed or cancelled lint-helm
if: |
needs.lint-helm.result == 'failure' ||
needs.lint-helm.result == 'cancelled'
run: exit 1
- name: Fail for failed or cancelled e2e
if: |
needs.e2e.result == 'failure' ||
needs.e2e.result == 'cancelled'
run: exit 1
publish:
runs-on: docker
needs:
- test-success
if: ${{ github.ref_type == 'tag' }}
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
show-progress: false
fetch-depth: 0 # Important for changelog
filter: blob:none # We don't need all blobs
- uses: ./.forgejo/actions/setup
- uses: ./.forgejo/actions/setup-node
- name: install helm
uses: https://github.com/azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
with:
version: ${{ env.HELM_VERSION }}
- run: helm dependency build
- run: helm package --version "${GITHUB_REF_NAME#v}" -d tmp/ ./
- name: login to registries
run: |
echo ${CODEBERG_TOKEN} | helm registry login -u viceice --password-stdin codeberg.org/forgejo-contrib
echo ${FORGEJO_TOKEN} | helm registry login -u viceice --password-stdin code.forgejo.org/forgejo-contrib
env:
CODEBERG_TOKEN: ${{secrets.API_TOKEN}}
FORGEJO_TOKEN: ${{secrets.FORGEJO_API_TOKEN}}
- name: publish forgejo helm chart
run: |
helm push tmp/forgejo-${GITHUB_REF_NAME#v}.tgz oci://codeberg.org/forgejo-contrib
helm push tmp/forgejo-${GITHUB_REF_NAME#v}.tgz oci://code.forgejo.org/forgejo-contrib
- name: publish forgejo release
run: pnpm forgejo:release