Skip to content

Fix process and path targeting in disk failure injector #227

Fix process and path targeting in disk failure injector

Fix process and path targeting in disk failure injector #227

Workflow file for this run

name: CI
on:
pull_request:
push:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.repository }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
env:
GOPATH: /home/runner/go
jobs:
lint-and-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
cache: true
- name: Get Datadog credentials
id: dd-sts
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push'
uses: DataDog/dd-sts-action@2e8187910199bd93129520183c093e19aa585c75 # v1.0.0
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() && (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push')
run: ./bin/tools/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@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Build ${{ matrix.target }}
run: make docker-build-${{ matrix.target }} SKIP_GENERATE=true
- name: Upload tarball
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
cache: true
- name: Get Datadog credentials
id: dd-sts
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push'
uses: DataDog/dd-sts-action@2e8187910199bd93129520183c093e19aa585c75 # v1.0.0
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@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
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: always()
run: |
mkdir -p /tmp/logs
minikube kubectl -- -n chaos-engineering logs -lapp=chaos-controller -c manager --tail=-1 > /tmp/logs/manager.txt 2>&1 || true
minikube kubectl -- -n chaos-engineering describe pods -lapp=chaos-controller > /tmp/logs/manager-describe.txt 2>&1 || true
minikube kubectl -- get pods -A -o wide > /tmp/logs/all-pods.txt 2>&1 || true
minikube kubectl -- describe pods -l chaos.datadoghq.com/disruption-name -A > /tmp/logs/chaos-pods-describe.txt 2>&1 || true
for pod in $(minikube kubectl -- get pods -A -l chaos.datadoghq.com/disruption-name -o jsonpath='{range .items[*]}{.metadata.namespace}/{.metadata.name}{"\n"}{end}' 2>/dev/null); do
ns="${pod%/*}"; name="${pod#*/}"
minikube kubectl -- -n "${ns}" logs "${name}" --all-containers=true --tail=-1 --prefix=true > "/tmp/logs/chaos-pod-${ns}-${name}.txt" 2>&1 || true
done
minikube kubectl -- get events -A --sort-by='.lastTimestamp' > /tmp/logs/events.txt 2>&1 || true
- name: Upload controller logs
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: e2e-controller-logs
path: /tmp/logs
- name: Upload e2e test report
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: report-e2e-test.xml
path: report-e2e-test.xml
validate-codegen:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- 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"