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: add helm docs test action #1058

Merged
merged 5 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
ci: add helm docs test action
Signed-off-by: drivebyer <yang.wu@daocloud.io>
  • Loading branch information
drivebyer committed Sep 11, 2024
commit 6004f4bfb00d614e51d1e5c48fd1094c1bb1e862
112 changes: 86 additions & 26 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,26 @@ env:
DOCKERFILE_PATH: "**/Dockerfile"

jobs:
gotest:
name: Go Test
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOLANG_VERSION }}
cache: false

- name: Run GolangCI-Lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.54.0

gotest:
needs:
- lint
name: Go Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
Expand All @@ -41,20 +56,77 @@ jobs:
fail_ci_if_error: false
verbose: true

lint:
helm_docs_test:
needs: [lint]
name: Helm Docs Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
- uses: actions/checkout@v3
with:
go-version: ${{ env.GOLANG_VERSION }}
cache: false
ref: ${{ github.event.pull_request.head.ref }}

- name: Run GolangCI-Lint
uses: golangci/golangci-lint-action@v6
- name: Render helm docs inside the README.md and push changes back to PR branch
uses: shaybentk/helm-docs-action@v0.0.1
with:
version: v1.54.0
working-dir: charts
git-push: "false"
fail-on-diff: "true"

validate_examples:
needs: [gotest]
name: Validate Examples
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install yamllint
run: sudo apt-get install -y yamllint

- name: Lint YAML files
run: yamllint --strict ./example

- name: Install kubectl
run: |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/

- name: Create k8s Kind Cluster
uses: helm/kind-action@v1.10.0
with:
cluster_name: kind

- name: Apply CRD
run: |
for crd in $(find ./config/crd/bases -type f -name '*.yaml'); do
kubectl create -f $crd
done

- name: Validate CRD Installation
run: |
CRDs=("redis" "redissentinels" "redisclusters" "redisreplications")
for crd in "${CRDs[@]}"; do
kubectl get crd $crd.redis.redis.opstreelabs.in || exit 1
done

- name: Validate CR
run: |
for example in $(find ./example -type f -name '*.yaml'); do
kubectl apply --dry-run=server -f $example
done

validate_yaml:
needs: [validate_examples]
name: Validate YAML
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install yamllint
run: sudo apt-get install -y yamllint
- name: Lint YAML files
run: yamllint --strict ./tests/

container_quality_dockerfile_lint:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -89,6 +161,7 @@ jobs:
run: |
mkdir -p ${{ github.workspace }}/compiled/${{ matrix.arch }}
zip ${{ github.workspace }}/compiled/${{ matrix.arch }}/${{ env.APPLICATION_NAME }}-${{ matrix.arch }}.zip ${{ github.workspace }}/${{ env.APPLICATION_NAME }}

build_scan_container_image:
needs: [container_quality_dockerfile_lint]
runs-on: ubuntu-latest
Expand Down Expand Up @@ -121,21 +194,8 @@ jobs:

GOSEC_OUTPUT: "junit-xml:/github/workspace/gosec-results.xml"

validate-yaml:
name: Validate YAML
runs-on: ubuntu-latest
needs:
- gotest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install yamllint
run: sudo apt-get install -y yamllint
- name: Lint YAML files
run: yamllint --strict ./tests/

e2e-test:
needs: [validate-yaml]
e2e_test:
needs: [validate_yaml]
name: ${{ matrix.testpath }}
runs-on: ubuntu-latest
strategy:
Expand Down
41 changes: 0 additions & 41 deletions .github/workflows/validate-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,3 @@ on:
- master

jobs:
validate-examples:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install yamllint
run: sudo apt-get install -y yamllint

- name: Lint YAML files
run: yamllint --strict ./example

- name: Install kubectl
run: |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/

- name: Create k8s Kind Cluster
uses: helm/kind-action@v1.10.0
with:
cluster_name: kind

- name: Apply CRD
run: |
for crd in $(find ./config/crd/bases -type f -name '*.yaml'); do
kubectl create -f $crd
done

- name: Validate CRD Installation
run: |
CRDs=("redis" "redissentinels" "redisclusters" "redisreplications")
for crd in "${CRDs[@]}"; do
kubectl get crd $crd.redis.redis.opstreelabs.in || exit 1
done

- name: Validate CR
run: |
for example in $(find ./example -type f -name '*.yaml'); do
kubectl apply --dry-run=server -f $example
done
Loading