Skip to content

Bump actions/checkout from 6.0.1 to 6.0.2 in the all group #4062

Bump actions/checkout from 6.0.1 to 6.0.2 in the all group

Bump actions/checkout from 6.0.1 to 6.0.2 in the all group #4062

Workflow file for this run

# yaml-language-server: $schema=https://www.schemastore.org/github-workflow.json
---
name: Test Samples (K3D)
on:
workflow_dispatch:
inputs:
version:
description: Radius version number to use (e.g. 0.1.0, 0.1.0-rc1, edge).
required: false
type: string
push:
branches:
- v*.*
- edge
paths:
- samples/**
- .github/workflows/**
pull_request:
types: [opened, synchronize, reopened]
branches:
- v*.*
- edge
schedule: # Run every day at 12 PM
- cron: 0 12 * * *
permissions: {}
env:
RUN_IDENTIFIER: samplestest-${{ github.run_id }}-${{ github.run_attempt }}
# ORAS (OCI Registry As Storage) CLI version
ORAS_VERSION: 1.1.0
# Dapr CLI version
DAPR_CLI_VER: 1.15.1
# Dapr runtime version
DAPR_RUNTIME_VER: 1.15.4
# Dapr dashboard version
DAPR_DASHBOARD_VER: 0.15.0
jobs:
test:
name: Sample tests
runs-on: ${{ matrix.os }}
timeout-minutes: 15
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- name: demo
os: ubuntu-24.04
runOnPullRequest: true
app: demo
env: default
path: ./samples/demo/app.bicep
deployArgs: --application demo -p image=sampleregistry:5000/samples/demo
exposeArgs: --application demo
uiTestFile: tests/demo/demo.app.spec.ts
port: 3000
container: demo
enableDapr: false
images: samples/demo
directories: samples/demo/
- name: dapr
os: ubuntu-24.04
runOnPullRequest: true
app: dapr
env: default
path: ./samples/dapr/dapr.bicep
deployArgs: -p frontendImage=sampleregistry:5000/samples/dapr-frontend -p backendImage=sampleregistry:5000/samples/dapr-backend
enableDapr: true
images: samples/dapr-frontend,samples/dapr-backend
directories: samples/dapr/ui/,samples/dapr/nodeapp/
- name: volumes
os: ubuntu-24.04
runOnPullRequest: true
app: myapp
env: default
path: ./samples/volumes/app.bicep
deployArgs: -p image=sampleregistry:5000/samples/volumes
enableDapr: false
images: samples/volumes
directories: samples/volumes/
steps:
# Setup the test assets and configuration
- name: Generate output variables
id: gen-id
run: |
RUN_IDENTIFIER=${{ env.RUN_IDENTIFIER }}-${{ matrix.name }}
if [[ "${{ github.event_name }}" == "pull_request" && "${{ matrix.runOnPullRequest }}" == "false" ]]; then
RUN_TEST=false
else
RUN_TEST=true
fi
# Set output variables to be used in the other jobs
echo "RUN_IDENTIFIER=${RUN_IDENTIFIER}" >> "${GITHUB_OUTPUT}"
echo "RUN_TEST=${RUN_TEST}" >> "${GITHUB_OUTPUT}"
- name: Generate Radius version variables
id: gen-radius-version
if: steps.gen-id.outputs.RUN_TEST == 'true'
run: |
RADIUS_VERSION=edge
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
RADIUS_VERSION=${{ github.event.inputs.version }}
elif [[ "${{ github.event_name }}" == "push" ]]; then
# Get the target branch of the push event
TARGET_BRANCH=${{ github.ref }}
if [[ "$TARGET_BRANCH" == "refs/heads/edge" ]]; then
RADIUS_VERSION=edge
elif [[ "$TARGET_BRANCH" =~ ^refs/heads/v[0-9]+\.[0-9]+$ ]]; then
# Example: refs/heads/v0.1 -> 0.1
RADIUS_VERSION=$(echo ${{ github.ref }} | cut -d '/' -f 3 | cut -d 'v' -f 2)
fi
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
# Get the target branch of the pull request
TARGET_BRANCH=${{ github.event.pull_request.base.ref }}
if [[ "$TARGET_BRANCH" == "edge" ]]; then
RADIUS_VERSION=edge
elif [[ "$TARGET_BRANCH" =~ ^refs/pull/v[0-9]+\.[0-9]+/merge$ ]]; then
# Example: refs/pull/v0.1/merge -> 0.1
RADIUS_VERSION=$(echo ${{ github.ref }} | cut -d '/' -f 3 | cut -d 'v' -f 2)
fi
elif [[ "${{ github.event_name }}" == "schedule" ]]; then
# Get the branch of the schedule event
TARGET_BRANCH=${{ github.ref }}
if [[ "$TARGET_BRANCH" == "refs/heads/edge" ]]; then
RADIUS_VERSION=edge
elif [[ "$TARGET_BRANCH" =~ ^refs/heads/v[0-9]+\.[0-9]+$ ]]; then
# Example: refs/heads/v0.1 -> 0.1
RADIUS_VERSION=$(echo ${{ github.ref }} | cut -d '/' -f 3 | cut -d 'v' -f 2)
else
echo "Invalid branch name: $TARGET_BRANCH"
exit 1
fi
else
echo "Invalid event name: ${{ github.event_name }}"
exit 1
fi
echo "RADIUS_VERSION=$RADIUS_VERSION" >> "${GITHUB_OUTPUT}"
- name: Checkout
if: steps.gen-id.outputs.RUN_TEST == 'true'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Ensure inputs.version is valid semver
if: steps.gen-id.outputs.RUN_TEST == 'true' && inputs.version != ''
run: |
python ./.github/scripts/validate_semver.py ${{ inputs.version }}
- name: Setup Node
if: steps.gen-id.outputs.RUN_TEST == 'true'
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: 20
- name: Download k3d
if: steps.gen-id.outputs.RUN_TEST == 'true'
run: wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
- name: Create k3d cluster
if: steps.gen-id.outputs.RUN_TEST == 'true'
# Map localhost port 80 on the external load balancer, and disable traefik and the internal load balancer.
run: k3d cluster create --agents 2 -p "80:80@loadbalancer" --k3s-arg "--disable=traefik@server:*" --k3s-arg "--disable=servicelb@server:*" --registry-create sampleregistry:51351
- name: Build images
if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.images != ''
run: |
# split images and directories into arrays
IFS=',' read -ra images <<< "${{ matrix.images }}"
IFS=',' read -ra directories <<< "${{ matrix.directories }}"
echo "Building images: $images"
echo "Directories: $directories"
for index in "${!images[@]}"; do
image=${images[$index]}
directory=${directories[$index]}
echo "Building image $image from directory $directory"
docker build -t "localhost:51351/$image:latest" "$directory"
docker push "localhost:51351/$image:latest"
done
# Create and install test environment
- uses: oras-project/setup-oras@22ce207df3b08e061f537244349aac6ae1d214f6 # v1.2.4
if: steps.gen-id.outputs.RUN_TEST == 'true'
with:
version: ${{ env.ORAS_VERSION }}
- name: Install Dapr CLI and control plane
if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.enableDapr == true
run: |
wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash -s ${{ env.DAPR_CLI_VER }}
dapr init -k --wait --timeout 600 --runtime-version ${{ env.DAPR_RUNTIME_VER }} --dashboard-version ${{ env.DAPR_DASHBOARD_VER }}
- name: Download rad CLI
if: steps.gen-id.outputs.RUN_TEST == 'true'
run: |
./.github/scripts/install-radius.sh ${{ steps.gen-radius-version.outputs.RADIUS_VERSION }}
- name: Initialize default environment
if: steps.gen-id.outputs.RUN_TEST == 'true'
run: |
rad install kubernetes --set rp.publicEndpointOverride=localhost
echo "*** Verify manifests are registered ***"
rm -f registermanifest_logs.txt
# Find the pod with container "ucp"
POD_NAME=$(
kubectl get pods -n radius-system \
-o jsonpath='{range .items[*]}{.metadata.name}{" "}{.spec.containers[*].name}{"\n"}{end}' \
| grep "ucp" \
| head -n1 \
| cut -d" " -f1
)
echo "Found ucp pod: $POD_NAME"
if [ -z "$POD_NAME" ]; then
echo "No pod with container 'ucp' found in namespace radius-system."
exit 1
fi
# Poll logs for up to iterations, 30 seconds each (upto 3 minutes total)
for i in {1..6}; do
kubectl logs "$POD_NAME" -n radius-system | tee registermanifest_logs.txt > /dev/null
# Exit on error
if grep -qi "Service initializer terminated with error" registermanifest_logs.txt; then
echo "Error found in ucp logs."
grep -i "Service initializer terminated with error" registermanifest_logs.txt
exit 1
fi
# Check for success
if grep -q "Successfully registered manifests" registermanifest_logs.txt; then
echo "Successfully registered manifests - message found."
break
fi
echo "Logs not ready, waiting 30 seconds..."
sleep 30
done
# Final check to ensure success message was found
if ! grep -q "Successfully registered manifests" registermanifest_logs.txt; then
echo "Manifests not registered after 3 minutes."
exit 1
fi
rad group create default
rad workspace create kubernetes default --group default
rad group switch default
rad env create default
rad env switch default
rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/rediscaches:${{ steps.gen-radius-version.outputs.RADIUS_VERSION }} --resource-type Applications.Datastores/redisCaches
rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/mongodatabases:${{ steps.gen-radius-version.outputs.RADIUS_VERSION }} --resource-type Applications.Datastores/mongoDatabases
rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/sqldatabases:${{ steps.gen-radius-version.outputs.RADIUS_VERSION }} --resource-type Applications.Datastores/sqlDatabases
rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/rabbitmqqueues:${{ steps.gen-radius-version.outputs.RADIUS_VERSION }} --resource-type Applications.Messaging/rabbitMQQueues
# Deploy application and run tests
# Retry the deployment step in case of transient failures
- name: Deploy app
if: steps.gen-id.outputs.RUN_TEST == 'true'
id: deploy-app
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
with:
timeout_minutes: 30
max_attempts: 3
retry_wait_seconds: 30
command: rad deploy ${{ matrix.path }} ${{ matrix.deployArgs }}
- name: Run Playwright Test
if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.uiTestFile != ''
id: run-playwright-test
run: |
if [[ "${{ matrix.container }}" != "" ]]; then
rad resource expose Applications.Core/containers ${{ matrix.container }} ${{ matrix.exposeArgs }} --port ${{ matrix.port }} &
export ENDPOINT="http://localhost:3000/"
else
endpoint="$(rad app status -a ${{ matrix.app }} | sed 's/ /\n/g' | grep http)"
echo "Endpoint: $endpoint"
export ENDPOINT=$endpoint
fi
cd playwright/
npm ci
npx playwright install --with-deps
npx playwright test ${{ matrix.uiTestFile }} --retries 3
- name: Upload Playwright Results
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: always() && (steps.run-playwright-test.outcome == 'success' || steps.run-playwright-test.outcome == 'failure')
with:
name: playwright-report-${{ matrix.name }}
path: playwright/playwright-report/
retention-days: 30
if-no-files-found: error
- name: Upload Playwright Videos
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: always() && steps.run-playwright-test.outcome == 'failure'
with:
name: playwright-video-${{ matrix.name }}
path: playwright/test-results/
retention-days: 30
if-no-files-found: error
# Handle failures
- name: Get Pod logs for failed tests
id: get-pod-logs
if: failure() && (steps.run-playwright-test.outcome == 'failure' || steps.deploy-app.outcome == 'failure')
run: |
# Create pod-logs directory
mkdir -p playwright/pod-logs/${{ matrix.name }}
# Get pod logs and save to file
namespace="${{ matrix.env }}-${{ matrix.app }}"
label="radapp.io/application=${{ matrix.app }}"
pod_names=($(kubectl get pods -l $label -n $namespace -o jsonpath='{.items[*].metadata.name}'))
for pod_name in "${pod_names[@]}"; do
kubectl logs $pod_name -n $namespace > playwright/pod-logs/${{ matrix.name }}/${pod_name}.txt
done
echo "Pod logs saved to playwright/pod-logs/${{ matrix.name }}/"
# Get kubernetes events and save to file
kubectl get events -n $namespace > playwright/pod-logs/${{ matrix.name }}/events.txt
- name: Upload Pod logs for failed tests
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: failure() && steps.get-pod-logs.outcome == 'success'
with:
name: ${{ matrix.name }}-pod-logs
path: playwright/pod-logs/${{ matrix.name }}
retention-days: 30
if-no-files-found: error
- name: Create GitHub issue on failure
if: failure() && github.event_name == 'schedule'
run: |
gh issue create --title "Samples deployment failed for ${{ matrix.name }}" --body "Test failed on ${{ github.repository }}. See [workflow logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for more details." --repo ${{ github.repository }} --label test-failure
env:
GH_TOKEN: ${{ github.token }}
# Cleanup
- name: Delete app
if: steps.gen-id.outputs.RUN_TEST == 'true' && steps.deploy-app.outcome == 'success'
run: |
if command -v rad &> /dev/null; then
rad app delete ${{ matrix.app }} -y
fi