Skip to content

Commit

Permalink
Merge pull request #307 from chatwork/fix_ci
Browse files Browse the repository at this point in the history
Fix ci
  • Loading branch information
cw-sakamoto authored Jun 12, 2024
2 parents eec4917 + 455eef0 commit 4a5edbe
Show file tree
Hide file tree
Showing 29 changed files with 106 additions and 43 deletions.
33 changes: 33 additions & 0 deletions .github/scripts/lint-chart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh
# Usage:
# lint-chart.sh [dir]
# Description:
# Check that the number of nindents matches the actual indents
#

err=$(for file in "${1}"/*.yaml; do
i="0"
while IFS= read -r line; do
i="$(expr "${i}" + 1)"
if echo "${line}" | grep nindent >/dev/null; then
indent=$(echo "${line}" | grep -o '^ \+' | awk '{print length($0)}')
args=$(echo "${line}"| grep -o 'nindent [0-9]\+' | grep -o '[0-9]\+')
# Check that the number of nindents matches the actual indents
if [ "${indent}" != "${args}" ]; then
printf "%s on line %d: indent mismatch:\n%s\n" "${file}" "${i}" "${line}"
fi
# nindent should use {{ instead of {{-
if ! (echo "$line" | grep '{{-') > /dev/null; then
printf "%s on line %d: \`{{-\` should be used for nindent:\n%s\n" "${file}" "${i}" "${line}"
fi
fi
done < "${file}"
done)


if [ -n "${err}" ]; then
echo "${err}" 1>&2
exit 255
else
echo "PASS ${1}"
fi
13 changes: 10 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Lint Helm Chart

on:
push:
branches:
- "!gh-pages"
branches-ignore:
- "gh-pages"

permissions:
contents: read
Expand All @@ -12,8 +12,15 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
id: github_context_step
continue-on-error: true
run: echo '${{ toJSON(github) }}'

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Helm
run: make ci:enable:helm
Expand All @@ -28,4 +35,4 @@ jobs:
run: make ci:diff:chart | xargs -I{} /bin/bash -c "cd ./{} && ../.github/scripts/check-version.sh || exit 255"

- name: Check lint
run: make ci:diff | xargs -I{} /bin/bash -c "cd ./{} && make lint || exit 255"
run: make ci:diff | xargs -I{} /bin/bash -c "cd ./{} && make lint || exit 255"
27 changes: 20 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,34 @@ name: Publish Helm Chart

on:
workflow_run:
workflows: ["Test Helm Chart"]
workflows:
- "Test Helm Chart"
types:
- completed
branches:
- "master"

permissions:
contents: write

jobs:
publish:
runs-on: ubuntu-latest
env:
if: |
${{ github.event.workflow_run.conclusion == 'success' }} &&
${{ github.ref_name == 'master' }}
env:
DOCKER_REGISTRY_USERNAME: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Dump GitHub context
id: github_context_step
continue-on-error: true
run: echo '${{ toJSON(github) }}'

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Helm
run: make ci:enable:helm
Expand All @@ -40,7 +49,11 @@ jobs:
- name: Commit and push
working-directory: .dist
run: |
git add .
# https://github.com/orgs/community/discussions/26560
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add .
git commit --allow-empty-message -m "$GITHUB_SHA"
git push origin gh-pages
Expand All @@ -59,7 +72,7 @@ jobs:
make ci:notify -e TITLE="Release chatwork/charts {}:${version} (gogo)" \
-e BODY="$(echo -e "changelog\n${changelog}")";
'
- name: Notification failed
if: failure()
run: |
Expand All @@ -68,4 +81,4 @@ jobs:
make ci:notify -e TITLE="CircleCI: Failed push chatwork/charts {}:${version} (devil)" \
-e BODY="$(git log -1 --pretty=format:"%h - %an : %s" ${CIRCLE_BRANCH})";
'
18 changes: 13 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,29 @@ name: Test Helm Chart

on:
workflow_run:
workflows: ["Lint Helm Chart"]
workflows:
- "Lint Helm Chart"
types:
- completed
branches:
- "!gh-pages"
branches-ignore:
- "gh-pages"

permissions:
contents: read

jobs:
lint:
test:
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
id: github_context_step
continue-on-error: true
run: echo '${{ toJSON(github) }}'

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup K8s
run: make ci:enable:k8s
Expand All @@ -31,4 +39,4 @@ jobs:
run: make ci:diff | xargs -I{} /bin/bash -c "cd ./{} && kubectl create namespace {} --dry-run -o yaml | kubectl apply -f - || exit 255"

- name: Test
run: RC=0; for target in `make ci:diff`;do cd ./$target; kubectl config set-context --current --namespace=$target; make install && make test && make uninstall || RC=255; cd ..; done; exit $RC
run: RC=0; for target in `make ci:diff`;do cd ./$target; kubectl config set-context --current --namespace=$target; make install && make test && make uninstall || RC=255; cd ..; done; exit $RC
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ KIND_VERSION = 0.20.0
KUBERNETES_VERSION = 1.28.0
KIND_NODE_HASH = b7a4cad12c197af3ba43202d3efe03246b3f0793f162afb40a33c923952d5b31
HELM_VERSION = 3.13.2
KUBEVAL_VERSION = 0.15.0
KUBEVAL_VERSION = 0.16.1

.PHONY: apply
apply:
Expand Down Expand Up @@ -44,9 +44,11 @@ ci\:enable\:helm:
.PHONY: ci\:enable\:kubeval
ci\:enable\:kubeval:
@mkdir -p .bin/
@mkdir -p /tmp/kubeval
@if [ ! -f "./.bin/kubeval" ]; then \
curl -sSL https://github.com/instrumenta/kubeval/releases/download/$(KUBEVAL_VERSION)/kubeval-linux-amd64.tar.gz | tar zxvf - -O linux-amd64/kubeval > ./.bin/kubeval; \
chmod +x ./.bin/kubeval; \
curl -sSL https://github.com/instrumenta/kubeval/releases/download/v${KUBEVAL_VERSION}/kubeval-linux-amd64.tar.gz | tar zxv -C /tmp/kubeval; \
ls -l /tmp/kubeval/ && mv /tmp/kubeval/kubeval ./.bin/kubeval; \
chmod +x ./.bin/kubeval; \
fi
@sudo mv ./.bin/kubeval /usr/local/bin/kubeval;

Expand Down
2 changes: 1 addition & 1 deletion akka/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lint: lint-default lint-local-akka-http lint-cluster-discovery-dns lint-cluster-
.PHONY: lint-default
lint-default:
@echo "=> Indent check default values.yaml"
../.circleci/lint-chart.sh $$PWD/templates
../.github/scripts/lint-chart.sh $$PWD/templates
@echo "=> Linting default values.yaml"
helm lint --strict
@echo "=> Validating default value.yaml"
Expand Down
2 changes: 1 addition & 1 deletion argoproj-crd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ lint: lint-default
.PHONY: lint-default
lint-default:
@echo "=> Indent check default values.yaml"
../.circleci/lint-chart.sh $$PWD/templates
../.github/scripts/lint-chart.sh $$PWD/templates
@echo "=> Linting default values.yaml"
helm lint --strict
@echo ""
Expand Down
2 changes: 1 addition & 1 deletion aws-ebs-csi-driver/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ lint: lint-default
.PHONY: lint-default
lint-default:
@echo "=> Indent check default values.yaml"
../.circleci/lint-chart.sh $$PWD/templates
../.github/scripts/lint-chart.sh $$PWD/templates
@echo "=> Linting default values.yaml"
helm lint --strict
@echo "=> Validating default value.yaml"
Expand Down
2 changes: 1 addition & 1 deletion aws-secret-operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lint: lint-default
.PHONY: lint-default
lint-default:
@echo "=> Indent check default values.yaml"
../.circleci/lint-chart.sh $$PWD/templates
../.github/scripts/lint-chart.sh $$PWD/templates
@echo "=> Linting default values.yaml"
helm lint --strict
@echo "=> Validating default value.yaml"
Expand Down
2 changes: 1 addition & 1 deletion burrow/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ lint: lint-default
.PHONY: lint-default
lint-default:
@echo "=> Indent check default values.yaml"
../.circleci/lint-chart.sh $$PWD/templates
../.github/scripts/lint-chart.sh $$PWD/templates
@echo "=> Linting default values.yaml"
helm lint --strict
@echo "=> Validating default value.yaml"
Expand Down
2 changes: 1 addition & 1 deletion docker-registry/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ lint: lint-default
.PHONY: lint-default
lint-default:
@echo "=> Indent check default values.yaml"
../.circleci/lint-chart.sh $$PWD/templates
../.github/scripts/lint-chart.sh $$PWD/templates
@echo "=> Linting default values.yaml"
helm lint --strict
@echo "=> Validating default value.yaml"
Expand Down
2 changes: 1 addition & 1 deletion dynamodb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lint: lint-default
.PHONY: lint-default
lint-default:
@echo "=> Indent check default values.yaml"
../.circleci/lint-chart.sh $$PWD/templates
../.github/scripts/lint-chart.sh $$PWD/templates
@echo "=> Linting default values.yaml"
helm lint --strict
@echo "=> Validating default value.yaml"
Expand Down
2 changes: 1 addition & 1 deletion elasticmq/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lint: lint-default
.PHONY: lint-default
lint-default:
@echo "=> Indent check default values.yaml"
../.circleci/lint-chart.sh $$PWD/templates
../.github/scripts/lint-chart.sh $$PWD/templates
@echo "=> Linting default values.yaml"
helm lint --strict
@echo "=> Validating default value.yaml"
Expand Down
2 changes: 1 addition & 1 deletion elasticsearch/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lint: lint-default
.PHONY: lint-default
lint-default:
@echo "=> Indent check default values.yaml"
../.circleci/lint-chart.sh $$PWD/templates
../.github/scripts/lint-chart.sh $$PWD/templates
@echo "=> Linting default values.yaml"
helm lint --strict
@echo "=> Validating default value.yaml"
Expand Down
4 changes: 2 additions & 2 deletions envoy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lint: lint-default lint-xds
.PHONY: lint-default
lint-default:
@echo "=> Indent check default values.yaml"
../.circleci/lint-chart.sh $$PWD/templates
../.github/scripts/lint-chart.sh $$PWD/templates
@echo "=> Linting default values.yaml"
helm lint --strict
@echo "=> Validating default value.yaml"
Expand All @@ -21,7 +21,7 @@ lint-default:
.PHONY: lint-xds
lint-xds:
@echo "=> Indent check default values.yaml"
../.circleci/lint-chart.sh $$PWD/templates
../.github/scripts/lint-chart.sh $$PWD/templates
@echo "=> Linting default values.yaml"
helm lint -f example/xds.yaml --strict
@echo "=> Validating default value.yaml"
Expand Down
2 changes: 1 addition & 1 deletion example/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lint: lint-default
.PHONY: lint-default
lint-default:
@echo "=> Indent check default values.yaml"
../.circleci/lint-chart.sh $$PWD/templates
../.github/scripts/lint-chart.sh $$PWD/templates
@echo "=> Linting default values.yaml"
helm lint --strict
@echo "=> Validating default value.yaml"
Expand Down
2 changes: 1 addition & 1 deletion fluent-bit/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lint: lint-default
.PHONY: lint-default
lint-default:
@echo "=> Indent check default values.yaml"
../.circleci/lint-chart.sh $$PWD/templates
../.github/scripts/lint-chart.sh $$PWD/templates
@echo "=> Linting default values.yaml"
helm lint --strict
@echo "=> Validating default value.yaml"
Expand Down
2 changes: 1 addition & 1 deletion fluentd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lint: lint-daemonset lint-statefulset lint-use-udp lint-use-udp
.PHONY: lint-default
lint-default:
@echo "=> Indent check default values.yaml"
../.circleci/lint-chart.sh $$PWD/templates
../.github/scripts/lint-chart.sh $$PWD/templates
@echo "=> Linting default values.yaml"
helm lint --strict
@echo "=> Validating default value.yaml"
Expand Down
2 changes: 1 addition & 1 deletion gcp-credentials/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lint: lint-default
.PHONY: lint-default
lint-default:
@echo "=> Indent check default values.yaml"
../.circleci/lint-chart.sh $$PWD/templates
../.github/scripts/lint-chart.sh $$PWD/templates
@echo "=> Linting default values.yaml"
helm lint --strict
@echo "=> Validating default value.yaml"
Expand Down
2 changes: 1 addition & 1 deletion kube-schedule-scaler/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lint: lint-default
.PHONY: lint-default
lint-default:
@echo "=> Indent check default values.yaml"
../.circleci/lint-chart.sh $$PWD/templates
../.github/scripts/lint-chart.sh $$PWD/templates
@echo "=> Linting default values.yaml"
helm lint --strict
@echo "=> Validating default value.yaml"
Expand Down
2 changes: 1 addition & 1 deletion mailcatcher/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lint: lint-default
.PHONY: lint-default
lint-default:
@echo "=> Indent check default values.yaml"
../.circleci/lint-chart.sh $$PWD/templates
../.github/scripts/lint-chart.sh $$PWD/templates
@echo "=> Linting default values.yaml"
helm lint --strict
@echo "=> Validating default value.yaml"
Expand Down
2 changes: 1 addition & 1 deletion mysql/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lint: lint-default
.PHONY: lint-default
lint-default:
@echo "=> Indent check default values.yaml"
../.circleci/lint-chart.sh $$PWD/templates
../.github/scripts/lint-chart.sh $$PWD/templates
@echo "=> Linting default values.yaml"
helm lint --strict
@echo "=> Validating default value.yaml"
Expand Down
2 changes: 1 addition & 1 deletion newrelic-php-agent/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lint: lint-default
.PHONY: lint-default
lint-default:
@echo "=> Indent check default values.yaml"
../.circleci/lint-chart.sh $$PWD/templates
../.github/scripts/lint-chart.sh $$PWD/templates
@echo "=> Linting default values.yaml"
helm lint --strict
@echo "=> Validating default value.yaml"
Expand Down
2 changes: 1 addition & 1 deletion php/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lint: lint-default
.PHONY: lint-default
lint-default:
@echo "=> Indent check default values.yaml"
../.circleci/lint-chart.sh $$PWD/templates
../.github/scripts/lint-chart.sh $$PWD/templates
@echo "=> Linting default values.yaml"
helm lint --strict
@echo "=> Validating default value.yaml"
Expand Down
2 changes: 1 addition & 1 deletion postfix/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ lint: lint-daemonset lint-daemonset-mailcatcher lint-deployment lint-deployment-
.PHONY: lint-daemonset
lint-daemonset:
@echo "=> Indent check default values.yaml"
../.circleci/lint-chart.sh $$PWD/templates
../.github/scripts/lint-chart.sh $$PWD/templates
@echo "=> Linting default values.yaml"
helm lint --strict
@echo "=> Validating default value.yaml"
Expand Down
2 changes: 1 addition & 1 deletion raw/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lint: lint-default
.PHONY: lint-default
lint-default:
@echo "=> Indent check default values.yaml"
../.circleci/lint-chart.sh $$PWD/templates
../.github/scripts/lint-chart.sh $$PWD/templates
@echo "=> Linting default values.yaml"
helm lint --strict
@echo "=> Validating default value.yaml"
Expand Down
Loading

0 comments on commit 4a5edbe

Please sign in to comment.