From 95d1f55d5d2143575221d2549d4b0153afc3a682 Mon Sep 17 00:00:00 2001 From: yangw Date: Mon, 6 May 2024 14:45:02 +0800 Subject: [PATCH] ci: run e2e after operator ci check (#913) Signed-off-by: drivebyer --- .../workflows/{operator-ci.yaml => ci.yaml} | 81 +++++++++++++++++ .github/workflows/e2e-chainsaw.yml | 88 ------------------- 2 files changed, 81 insertions(+), 88 deletions(-) rename .github/workflows/{operator-ci.yaml => ci.yaml} (55%) delete mode 100644 .github/workflows/e2e-chainsaw.yml diff --git a/.github/workflows/operator-ci.yaml b/.github/workflows/ci.yaml similarity index 55% rename from .github/workflows/operator-ci.yaml rename to .github/workflows/ci.yaml index b97af383f..7d08cc38d 100644 --- a/.github/workflows/operator-ci.yaml +++ b/.github/workflows/ci.yaml @@ -22,6 +22,8 @@ jobs: gotest: name: Go Test runs-on: ubuntu-latest + needs: + - lint steps: - uses: actions/checkout@v4 - name: Set up Go @@ -118,3 +120,82 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 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] + name: ${{ matrix.testpath }} + runs-on: ubuntu-latest + strategy: + matrix: + testpath: + - ./tests/e2e-chainsaw/v1beta2/teardown/ + - ./tests/e2e-chainsaw/v1beta2/setup/ + - ./tests/e2e-chainsaw/v1beta2/hostnetwork/ + - ./tests/e2e-chainsaw/v1beta2/password/ + - ./tests/e2e-chainsaw/v1beta2/ha-setup/ + - ./tests/e2e-chainsaw/v1beta2/ha-failover/ + - ./tests/e2e-chainsaw/v1beta2/nodeport/ + - ./tests/e2e-chainsaw/v1beta2/pvc-name/ + - ./tests/e2e-chainsaw/v1beta2/keep-pvc/ + - ./tests/e2e-chainsaw/v1beta2/acl-user/ + - ./tests/e2e-chainsaw/v1beta2/scaling/ + - ./tests/e2e-chainsaw/v1beta2/ignore-annots/ + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build Dockerfile + run: docker build . --file Dockerfile --tag redis-operator:e2e + + - name: Install chainsaw + uses: kyverno/chainsaw/.github/actions/install@v0.0.9 + with: + release: v0.1.7 + + - name: Check install + run: chainsaw version + + - 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: Install Redis + # uses: shogo82148/actions-setup-redis@v1 + + - name: Create k8s Kind Cluster + uses: helm/kind-action@v1.10.0 + with: + config: tests/_config/kind-config.yaml + cluster_name: kind + + - name: Load Docker image into Kind + run: | + kubectl cluster-info --context kind-kind + kind load docker-image redis-operator:e2e --name kind + + - name: Install Redis Operator + run: | + make deploy IMG=redis-operator:e2e + + - name: Wait for Redis Operator to be ready + run: | + kubectl wait --for=condition=available --timeout=300s deployment/redis-operator-redis-operator -n redis-operator-system + + - name: Run chainsaw test + run: chainsaw test --test-dir ${{ matrix.testpath }} --config tests/_config/chainsaw-configuration.yaml diff --git a/.github/workflows/e2e-chainsaw.yml b/.github/workflows/e2e-chainsaw.yml deleted file mode 100644 index cb2b32586..000000000 --- a/.github/workflows/e2e-chainsaw.yml +++ /dev/null @@ -1,88 +0,0 @@ -name: E2E chainsaw tests - -on: - pull_request: - branches: - - master - push: - branches: - - master - -jobs: - - validate-yaml: - 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/ - - test: - needs: [validate-yaml] - name: ${{ matrix.testpath }} - runs-on: ubuntu-latest - strategy: - matrix: - testpath: - - ./tests/e2e-chainsaw/v1beta2/teardown/ - - ./tests/e2e-chainsaw/v1beta2/setup/ - - ./tests/e2e-chainsaw/v1beta2/hostnetwork/ - - ./tests/e2e-chainsaw/v1beta2/password/ - - ./tests/e2e-chainsaw/v1beta2/ha-setup/ - - ./tests/e2e-chainsaw/v1beta2/ha-failover/ - - ./tests/e2e-chainsaw/v1beta2/nodeport/ - - ./tests/e2e-chainsaw/v1beta2/pvc-name/ - - ./tests/e2e-chainsaw/v1beta2/keep-pvc/ - - ./tests/e2e-chainsaw/v1beta2/acl-user/ - - ./tests/e2e-chainsaw/v1beta2/scaling/ - - ./tests/e2e-chainsaw/v1beta2/ignore-annots/ - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Build Dockerfile - run: docker build . --file Dockerfile --tag redis-operator:e2e - - - name: Install chainsaw - uses: kyverno/chainsaw/.github/actions/install@v0.0.9 - with: - release: v0.1.7 - - - name: Check install - run: chainsaw version - - - 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: Install Redis - # uses: shogo82148/actions-setup-redis@v1 - - - name: Create k8s Kind Cluster - uses: helm/kind-action@v1.10.0 - with: - config: tests/_config/kind-config.yaml - cluster_name: kind - - - name: Load Docker image into Kind - run: | - kubectl cluster-info --context kind-kind - kind load docker-image redis-operator:e2e --name kind - - - name: Install Redis Operator - run: | - make deploy IMG=redis-operator:e2e - - - name: Wait for Redis Operator to be ready - run: | - kubectl wait --for=condition=available --timeout=300s deployment/redis-operator-redis-operator -n redis-operator-system - - - name: Run chainsaw test - run: chainsaw test --test-dir ${{ matrix.testpath }} --config tests/_config/chainsaw-configuration.yaml