Skip to content

Commit

Permalink
Update CI actions to run unittest and integration test on every pull …
Browse files Browse the repository at this point in the history
…request
  • Loading branch information
jlandowner committed Apr 14, 2024
1 parent b2413d5 commit 73a709e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 93 deletions.
112 changes: 19 additions & 93 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,114 +1,40 @@
name: CI

on:
push:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
ingress-nginx:
unittest:
runs-on: ubuntu-latest
name: Do snapshot ingress-nginx and create PR if snapshot changed
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
- name: Checkout code
uses: actions/checkout@v4

- name: Update Snapshot
uses: jlandowner/helm-chartsnap-action@v1
id: helm-chartsnap-action
- name: Setup Go
uses: actions/setup-go@v4
with:
chart: ingress-nginx
repo: https://kubernetes.github.io/ingress-nginx
values: example/remote/ingress-nginx.values.yaml
additional_args: "--namespace ingress-nginx --skip-tests"
update_snapshot: true
go-version-file: go.mod
- run: go version

cilium:
runs-on: ubuntu-latest
name: Do snapshot cilium and create PR if snapshot changed
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Update Snapshot
uses: jlandowner/helm-chartsnap-action@v1
id: helm-chartsnap-action
with:
chart: cilium
repo: https://helm.cilium.io
values: example/remote/cilium.values.yaml
additional_args: "--namespace kube-system"
update_snapshot: true

nginx-gateway-fabric:
runs-on: ubuntu-latest
name: Do snapshot nginx-gateway-fabric and create PR if snapshot changed
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Update Snapshot
uses: jlandowner/helm-chartsnap-action@v1
id: helm-chartsnap-action
with:
chart: oci://ghcr.io/nginxinc/charts/nginx-gateway-fabric
values: example/remote/nginx-gateway-fabric.values.yaml
additional_args: "--namespace nginx-gateway"
update_snapshot: true

local:
runs-on: ubuntu-latest
name: Do snapshot for local chart if snapshot changed
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Update Snapshot
uses: jlandowner/helm-chartsnap-action@v1
id: helm-chartsnap-action
with:
chart: example/app1
values: example/app1/test/
update_snapshot: true
- name: Unittest
run: |
make test GO=go
local-fail:
integ-test:
runs-on: ubuntu-latest
name: Do snapshot for local unmathced chart
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
- name: Checkout code
uses: actions/checkout@v4

- name: Update Snapshot
uses: jlandowner/helm-chartsnap-action@v1
id: helm-chartsnap-action
- name: Setup Go
uses: actions/setup-go@v4
with:
chart: example/app1
values: example/app1/testfail/
continue-on-error: true

- name: OK if snapshot is changed
if: steps.helm-chartsnap-action.outcome == 'failure'
shell: bash
run: |
echo "snapshot changed"
go-version-file: go.mod
- run: go version

- name: Fail if snapshot is not changed
if: steps.helm-chartsnap-action.outcome == 'success'
shell: bash
- name: Integration test
run: |
echo "snapshot not changed"; exit 1
make integ-test GO=go
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ HELM_PLUGIN_PATH := $(shell helm env | grep HELM_PLUGINS | cut -d= -f2)
integ-test: install-dev-bin
helm chartsnap --chart example/app1 -f example/app1/test/test_ingress_enabled.yaml --namespace default $(ARGS)
helm chartsnap --chart example/app1 -f example/app1/test/ --namespace default $(ARGS)
helm chartsnap --chart oci://ghcr.io/nginxinc/charts/nginx-gateway-fabric -f example/remote/nginx-gateway-fabric.values.yaml $(ARGS) -- --namespace nginx-gateway $(EXTRA_ARGS)
helm chartsnap --chart cilium -f example/remote/cilium.values.yaml $(ARGS) -- --namespace kube-system --repo https://helm.cilium.io $(EXTRA_ARGS)
helm chartsnap --chart ingress-nginx -f example/remote/ingress-nginx.values.yaml $(ARGS) -- --repo https://kubernetes.github.io/ingress-nginx --namespace ingress-nginx --skip-tests $(EXTRA_ARGS)

.PHONY: integ-test-fail
integ-test-fail: install-dev-bin
Expand Down

0 comments on commit 73a709e

Please sign in to comment.