Skip to content

Zenithar/chaos controller/kubernetes 1 35 support #45

Zenithar/chaos controller/kubernetes 1 35 support

Zenithar/chaos controller/kubernetes 1 35 support #45

Workflow file for this run

name: CI
on:
pull_request:
push:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
GOPATH: /home/runner/go
jobs:
lint-and-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version-file: go.mod
cache: true
- name: Install lint tools
run: make install-golangci-lint install-controller-gen
- name: Format
run: |
make fmt
git diff --exit-code
- name: Vet
run: make vet
- name: Lint
run: make lint
test:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version-file: go.mod
cache: true
- name: Get Datadog credentials
id: dd-sts
uses: DataDog/dd-sts-action@main
with:
policy: chaos-controller
- name: Install tools
run: make -j4 install-controller-gen install-yamlfmt install-kubebuilder install-datadog-ci
- name: Run unit tests
run: make test GINKGO_PROCS=2
env:
DATADOG_API_KEY: ${{ steps.dd-sts.outputs.api_key }}
- name: Upload code coverage
if: success()
run: datadog-ci coverage upload --format go-coverprofile --flags "type:unit-tests" cover.profile
env:
DATADOG_API_KEY: ${{ steps.dd-sts.outputs.api_key }}
- name: Upload test report
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: report-test.xml
path: report-test.xml
docker-build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [injector, manager, handler]
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Build ${{ matrix.target }}
run: make docker-build-${{ matrix.target }} SKIP_GENERATE=true
- name: Upload tarball
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: docker-${{ matrix.target }}
path: bin/${{ matrix.target }}/${{ matrix.target }}.tar.gz
retention-days: 1
e2e-test:
runs-on: ubuntu-latest
needs: docker-build
timeout-minutes: 45
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version-file: go.mod
cache: true
- name: Get Datadog credentials
id: dd-sts
uses: DataDog/dd-sts-action@main
with:
policy: chaos-controller
- name: Install tools
run: make -j6 install-controller-gen install-yamlfmt install-helm install-kubebuilder install-datadog-ci
- name: Download docker tarballs
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
pattern: docker-*
merge-multiple: false
- name: Move tarballs into place
run: |
for target in injector manager handler; do
mkdir -p bin/${target}
mv docker-${target}/${target}.tar.gz bin/${target}/
done
- name: Install Minikube
run: make ci-install-minikube MINIKUBE_CPUS=max MINIKUBE_MEMORY=max
- name: Install cert-manager
run: make lima-install-cert-manager KUBECTL="minikube kubectl --"
- name: Load images into Minikube
run: make minikube-load-all
- name: Run e2e tests
env:
DATADOG_API_KEY: ${{ steps.dd-sts.outputs.api_key }}
run: |
for attempt in 1 2 3; do
echo "=== Attempt ${attempt}/3 ==="
if make e2e-test KUBECTL="minikube kubectl --" E2E_TEST_CLUSTER_NAME="minikube" E2E_TEST_KUBECTL_CONTEXT="minikube"; then
exit 0
fi
echo "Attempt ${attempt} failed"
done
echo "All 3 attempts failed"
exit 1
- name: Save controller logs
if: failure()
run: |
mkdir -p /tmp/logs
minikube kubectl -- -n chaos-engineering logs -lapp=chaos-controller -c manager --tail=-1 > /tmp/logs/e2e.txt 2>&1 || true
- name: Upload controller logs
if: failure()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: e2e-controller-logs
path: /tmp/logs
- name: Upload e2e test report
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: report-e2e-test.xml
path: report-e2e-test.xml
validate-codegen:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version-file: go.mod
cache: true
- name: Install tools
run: make -j6 install-controller-gen install-yamlfmt install-mockery install-protobuf PROTOC_OS=linux
- name: Validate go dependencies
run: |
make godeps
git diff --exit-code
- name: Validate manifests
run: |
make manifests
git diff --exit-code
- name: Validate mocks
run: |
make generate-mocks
git diff --exit-code
- name: Validate disruptionlistener protobuf
run: |
make generate-disruptionlistener-protobuf
git diff --exit-code ':!go.*'
- name: Validate chaosdogfood protobuf
run: |
make generate-chaosdogfood-protobuf
git diff --exit-code ':!go.*'
python-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Install Python dependencies
run: pip install -r tasks/requirements.txt
- name: Check third-party licenses
run: |
inv license-check
git diff --exit-code
- name: Check license headers
run: |
inv header-check
git diff --exit-code
doc-spellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Install markdown-spellcheck
run: npm install -g markdown-spellcheck
- name: Spellcheck
run: mdspell --report --en-us --ignore-numbers --ignore-acronyms $(find . -name vendor -prune -o -name '*.md' -print) || echo "please run 'make spellcheck' for local testing"