Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(lint): reorganize workflows and add jobs to check readme diff #179

Merged
merged 12 commits into from
Jul 18, 2024
69 changes: 69 additions & 0 deletions .github/workflows/chart-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Lint Helm Chart

concurrency:
group: ci-${{ github.run_id }}
cancel-in-progress: true
tthvo marked this conversation as resolved.
Show resolved Hide resolved

on:
push:
branches:
- main
- v[0-9]+
- v[0-9]+.[0-9]+
- cryostat-v[0-9]+.[0-9]+

pull_request:
types:
- opened
- reopened
- synchronize
- labeled
- unlabeled
branches:
- main
- v[0-9]+
- v[0-9]+.[0-9]+
- cryostat-v[0-9]+.[0-9]+

jobs:
lint-chart:
runs-on: ubuntu-latest
env:
TARGET_BRANCH: ${{ github.event.pull_request.base.ref || github.ref_name }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.14.4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
check-latest: true
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.6.1
- name: Lint chart
run: ct lint --target-branch ${TARGET_BRANCH} --lint-conf lintconf.yaml --config ct.yaml --chart-yaml-schema chart_schema.yaml

check-readme-diff:
runs-on: ubuntu-latest
env:
README_GENERATOR_VERSION: 2.5.2
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check README diff
run: |
npx @bitnami/readme-generator-for-helm@$README_GENERATOR_VERSION \
--values charts/cryostat/values.yaml \
--readme charts/cryostat/README.md \
--schema charts/cryostat/values.schema.json

if ! git diff --exit-code; then
echo "README requires updating. To update, run:"
echo "npx @bitnami/readme-generator-for-helm@$README_GENERATOR_VERSION --values charts/cryostat/values.yaml --readme charts/cryostat/README.md --schema charts/cryostat/values.schema.json"
exit 1
fi
82 changes: 82 additions & 0 deletions .github/workflows/chart-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Test Helm Chart

concurrency:
group: ci-${{ github.run_id }}
cancel-in-progress: true

on:
push:
branches:
- main
- v[0-9]+
- v[0-9]+.[0-9]+
- cryostat-v[0-9]+.[0-9]+

pull_request:
types:
- opened
- reopened
- synchronize
- labeled
- unlabeled
branches:
- main
- v[0-9]+
- v[0-9]+.[0-9]+
- cryostat-v[0-9]+.[0-9]+

jobs:
helm-test:
runs-on: ubuntu-latest
env:
TARGET_BRANCH: ${{ github.event.pull_request.base.ref || github.ref_name }}
TEST_NAMESPACE: helm-test
steps:
- name: Fail if safe-to-test label NOT applied
if: ${{ github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'safe-to-test') }}
run: exit 1
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.14.4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
check-latest: true
- uses: helm/chart-testing-action@v2.6.1
- name: Set up Kind cluster
uses: helm/kind-action@v1
with:
cluster_name: ci-${{ github.run_id }}
- name: Install and test chart
run: |
# FIXME: Remove when chart-testing fixes the issue https://github.com/helm/chart-testing/issues/525

HELM_LOCATION="$(which helm)"
sudo mv $HELM_LOCATION "$(dirname $HELM_LOCATION)/.helm"
cat <(echo '#!/usr/bin/env bash') <(echo 'exec .helm "${@//--reuse-values/--reset-then-reuse-values}"') | sudo tee $HELM_LOCATION
sudo chmod +x $HELM_LOCATION

kubectl create ns $TEST_NAMESPACE
ct install --target-branch ${TARGET_BRANCH} --upgrade --namespace=$TEST_NAMESPACE --config ct.yaml --debug

helm-unittest:
runs-on: ubuntu-latest
steps:
- name: fail if safe-to-test label NOT applied
if: ${{ github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'safe-to-test') }}
run: exit 1
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.14.4
- name: Install unit test plugin
run: helm plugin install https://github.com/helm-unittest/helm-unittest.git --version v0.5.1
- name: Run Helm unit tests
run: helm unittest --debug ./charts/cryostat
83 changes: 0 additions & 83 deletions .github/workflows/ci.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .github/workflows/push-oci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Push Helm Chart to OCI Registry

concurrency:
group: ci-${{ github.run_id }}
cancel-in-progress: true

on:
push:
branches:
Expand Down
48 changes: 24 additions & 24 deletions .github/workflows/submodule.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: submodule
name: Update Submodule

on:
workflow_call:
Expand All @@ -19,26 +19,26 @@ jobs:
if: ${{ github.repository_owner == 'cryostatio' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: cryostatio/cryostatio.github.io
token: "${{ secrets.SUBMODULE_TOKEN }}"
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Update submodule to latest commit
run: |
git submodule update --init
git submodule update --remote
- name: Commit and push submodule
run: |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add --all
git_hash="$(git rev-parse --short :helm-charts)"
git commit -S -m "build(helm-charts): update submodule to $git_hash" || echo "No changes to commit"
git push
- uses: actions/checkout@v4
with:
repository: cryostatio/cryostatio.github.io
token: "${{ secrets.SUBMODULE_TOKEN }}"
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Update submodule to latest commit
run: |
git submodule update --init
git submodule update --remote
- name: Commit and push submodule
run: |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add --all
git_hash="$(git rev-parse --short :helm-charts)"
git commit -S -m "build(helm-charts): update submodule to $git_hash" || echo "No changes to commit"
git push
41 changes: 0 additions & 41 deletions .github/workflows/unittest.yml

This file was deleted.

Loading