Skip to content

[tests] Update test cluster setup and configuration #9616

[tests] Update test cluster setup and configuration

[tests] Update test cluster setup and configuration #9616

# This is a basic workflow
name: CI
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [main]
pull_request:
branches: [main]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
node: [ 22 ]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v6
with:
fetch-depth: 1
# Set up Node
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
# Run install dependencies
- name: Install dependencies
run: npm ci
# Run tests without xvfb, if not running on ubuntu
- name: Build and Test (non-Linux)
if: (success() || failure()) && runner.os != 'Linux'
env:
NODE_OPTIONS: --max_old_space_size=16384
run: npm run test:coverage --silent
# Run tests directly running xvfb, if running on ubuntu
- name: Build and Test (Linux)
if: (success() || failure()) && runner.os == 'Linux'
env:
NODE_OPTIONS: --max_old_space_size=16384
run: xvfb-run npm run test:coverage --silent
# Install and start KinD cluster
- name: Start KinD cluster
if: (success() || failure()) && runner.os == 'Linux'
uses: helm/kind-action@v1.14.0
with:
version: v0.31.0
node_image: kindest/node:v1.34.0
# Configure cluster
- name: Install operators (deterministic, no OLM)
if: (success() || failure()) && runner.os == 'Linux'
run: |
set -euo pipefail
echo "Installing CloudNativePG (new version)..."
kubectl apply -f https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/release-1.28/releases/cnpg-1.28.1.yaml
echo "Installing Service Binding Operator..."
kubectl apply -f https://github.com/redhat-developer/service-binding-operator/releases/download/v1.3.0/service-binding-operator.yaml
echo "Waiting for operators..."
kubectl wait --for=condition=Available deployment \
-n cnpg-system \
--all \
--timeout=180s
kubectl wait --for=condition=Available deployment \
-n service-binding-operator \
--all \
--timeout=180s
echo "Extracting cluster URL..."
# echo CLUSTER_URL=$(kubectl cluster-info | sed -n -e "s/\x1B\[[0-9;]*[a-zA-Z]//g" -e '1s/.*running at \(.*\)$/\1/p') >> $GITHUB_ENV
CLUSTER_URL=$(kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}')
echo "CLUSTER_URL=$CLUSTER_URL" >> $GITHUB_ENV
# UI tests fail under linux
# Run UI tests
- name: Run UI Tests
env:
NODE_OPTIONS: --max_old_space_size=16384
if: runner.os == 'Linux'
run: |
# Patch vscode:prepublish to reinstall secretlint AFTER prune
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json'));
pkg.scripts['vscode:prepublish'] += ' && npm install @secretlint/node';
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));
"
xvfb-run --server-args="-screen 0 1920x1080x24" npm run public-ui-test
- name: Build and run integration tests
if: (success() || failure()) && runner.os == 'Linux'
env:
NODE_OPTIONS: --max_old_space_size=16384
run: xvfb-run npm run test-integration:coverage --silent
# Archiving integration tests artifacts
- name: Upload test artifacts
uses: actions/upload-artifact@v7
if: failure() && runner.os == 'Linux'
with:
name: artifacts-${{ matrix.os }}
path: |
/tmp/test-resources/settings/logs/**/*.log
/tmp/test-resources/screenshots/**/*.png
retention-days: 2
# Upload coverage to codecov.io
- name: Codecov
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 #v6.0.0
if: (success() || failure()) && runner.os == 'Linux'
with:
files: ./coverage/unit/coverage-final.json,./coverage/integration/coverage-final.json