Skip to content

Merge pull request #370 from karmada-io/dependabot/go_modules/github.… #894

Merge pull request #370 from karmada-io/dependabot/go_modules/github.…

Merge pull request #370 from karmada-io/dependabot/go_modules/github.… #894

Workflow file for this run

# Reference: https://github.com/karmada-io/karmada/blob/master/.github/workflows/ci.yml
# We cut some unused job to make the workflow more suitable for ci of karmada dashboard
name: CI Workflow
on:
# Run this workflow every time a new commit pushed to upstream/fork repository.
# Run workflow on fork repository will help contributors find and resolve issues before sending a PR.
push:
# Exclude branches created by Dependabot to avoid triggering current workflow
# for PRs initiated by Dependabot.
branches-ignore:
- 'dependabot/**'
pull_request:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.actor }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read # for actions/checkout to fetch code
env:
DEBUG: false
jobs:
golangci:
name: lint
runs-on: ubuntu-22.04
steps:
- name: checkout code
uses: actions/checkout@v6
- name: install Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: verify license
run: hack/verify-license.sh
- name: lint
run: hack/verify-staticcheck.sh
build-frontend:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Use Node.js 20
uses: actions/setup-node@v6
with:
node-version: 20
- uses: pnpm/action-setup@v4
with:
# keep in sync with the packageManager version in `ui/package.json`
version: 9.1.2
- name: Build dashboard
run: |
echo "Start build"
pnpm --version
cd ui
pnpm install
pnpm turbo build
build-bin:
name: build-bin
runs-on: ubuntu-22.04
steps:
- name: checkout code
uses: actions/checkout@v6
with:
# Number of commits to fetch. 0 indicates all history for all branches and tags.
# We need to guess version via git tags.
fetch-depth: 0
- name: install Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: compile
run: make all
e2e-frontend:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
# Here support the latest three minor releases of Kubernetes, this can be considered to be roughly
# the same as the End of Life of the Kubernetes release: https://kubernetes.io/releases/
# Please remember to update the CI Schedule Workflow when we add a new version.
k8s: [ v1.31.0, v1.32.0, v1.33.0 ]
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed, if set to "true" but frees about 6 GB
tool-cache: false
# all of these default to true, but feel free to set to "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: false
swap-storage: false
- name: Checkout karmada repo
uses: actions/checkout@v6
with:
repository: karmada-io/karmada
path: karmada
- name: setup e2e test environment
run: |
cd karmada
export CLUSTER_VERSION=kindest/node:${{ matrix.k8s }}
hack/local-up-karmada.sh
echo "KUBECONFIG=/home/runner/.kube/karmada.config" >> $GITHUB_ENV
- name: Debug cluster status
if: ${{ env.DEBUG == 'true' }}
run: |
kubectl cluster-info || echo "Cluster info failed"
kubectl get nodes -o wide || echo "Get nodes failed"
kubectl get pods -A || echo "Get pods failed"
kind get clusters || echo "Kind get clusters failed"
- name: Checkout dashboard repo
uses: actions/checkout@v6
with:
path: karmada-dashboard
- name: Generate KARMADA_TOKEN for CI
run: |
kubectl --context=karmada-host apply -k karmada-dashboard/artifacts/overlays/nodeport-mode
kubectl --context=karmada-apiserver apply -f karmada-dashboard/artifacts/dashboard/karmada-dashboard-sa.yaml
TOKEN=$(kubectl --context=karmada-apiserver -n karmada-system get secret/karmada-dashboard-secret -o go-template="{{.data.token | base64decode}}")
echo "KARMADA_TOKEN=$TOKEN" >> $GITHUB_ENV
- name: Use Node.js 20
uses: actions/setup-node@v6
with:
node-version: 20
- uses: pnpm/action-setup@v4
with:
# keep in sync with the packageManager version in `ui/package.json`
version: 9.1.2
- name: Install dependencies
run: |
echo "Start build"
pnpm --version
cd karmada-dashboard/ui
pnpm install
pnpm turbo build
- name: Build API binary
run: |
cd karmada-dashboard
make build
- name: Start API server
run: |
cd karmada-dashboard
make run-api &
echo $! > .api.pid
sleep 5
- name: Wait for API server to be ready
run: |
echo "Waiting for API server to be ready..."
timeout 60s bash -c 'while ! nc -z localhost 8000; do echo "Waiting for API server port..."; sleep 5; done' || {
echo "API server failed to start within 60 seconds"
echo "=== API Server Debug ==="
if [ -f karmada-dashboard/.api.pid ]; then
API_PID=$(cat karmada-dashboard/.api.pid)
ps aux | grep $API_PID || echo "API process not found"
fi
ss -tuln | grep 8000 || echo "Port 8000 not listening"
exit 1
}
echo "API server is ready!"
- name: Install Playwright Browsers
run: |
cd karmada-dashboard/ui/apps/dashboard
pnpm exec playwright install --with-deps
- name: Debug environment before starting dashboard
if: ${{ env.DEBUG == 'true' }}
run: |
echo "KARMADA_TOKEN is set: ${{ env.KARMADA_TOKEN != '' }}"
echo "KUBECONFIG: $KUBECONFIG"
echo "Current directory: $(pwd)"
echo "Dashboard directory contents:"
ls -la karmada-dashboard/ || echo "No dashboard directory"
echo "Check if Makefile exists:"
ls -la karmada-dashboard/Makefile || echo "No Makefile found"
- name: Build frontend (for e2e)
working-directory: karmada-dashboard/ui/apps/dashboard
run: |
pnpm build
- name: Test API connectivity before running tests
run: |
echo "Testing API connectivity..."
curl -f http://localhost:8000/api/v1/cluster && echo "✓ Cluster API works" || echo "✗ Cluster API failed"
curl -f http://localhost:8000/api/v1/namespace && echo "✓ Namespace API works" || echo "✗ Namespace API failed"
echo "API tests completed"
- name: Debug working dir
if: ${{ env.DEBUG == 'true' }}
run: |
pwd
ls -al
- name: Run Playwright tests
working-directory: karmada-dashboard/ui/apps/dashboard
run: |
pnpm exec playwright test
- name: Cleanup processes
if: always()
run: |
echo "Cleaning up processes..."
if [ -f karmada-dashboard/.api.pid ]; then
API_PID=$(cat karmada-dashboard/.api.pid)
kill $API_PID 2>/dev/null || echo "API process already stopped"
fi
- uses: actions/upload-artifact@v6
if: ${{ !cancelled() }}
with:
name: playwright-report-${{ matrix.k8s }}
path: karmada-dashboard/ui/apps/dashboard/playwright-report/
retention-days: 30