|
| 1 | +name: Run Plugin Integration Tests |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + workspace-path: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + outputs: |
| 10 | + success: |
| 11 | + description: Overall integration test result |
| 12 | + value: ${{ jobs.run.outputs.success }} |
| 13 | + failed-plugins: |
| 14 | + description: Newline-separated list of plugins that failed to load |
| 15 | + value: ${{ jobs.run.outputs.failed-plugins }} |
| 16 | + |
| 17 | +jobs: |
| 18 | + run: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + timeout-minutes: 25 |
| 21 | + permissions: |
| 22 | + contents: read |
| 23 | + packages: read |
| 24 | + outputs: |
| 25 | + success: ${{ steps.collect-results.outputs.success }} |
| 26 | + failed-plugins: ${{ steps.collect-results.outputs.failed-plugins }} |
| 27 | + steps: |
| 28 | + - name: Download integration test artifacts |
| 29 | + uses: actions/download-artifact@v4 |
| 30 | + with: |
| 31 | + name: integration-test-artifacts |
| 32 | + path: ./artifacts |
| 33 | + |
| 34 | + - name: Log in to GitHub Container Registry |
| 35 | + uses: docker/login-action@v3 |
| 36 | + with: |
| 37 | + registry: ghcr.io |
| 38 | + username: ${{ github.actor }} |
| 39 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 40 | + |
| 41 | + - name: Start RHDH with Layered Test Config |
| 42 | + env: |
| 43 | + WORKSPACE_PATH: ${{ inputs.workspace-path }} |
| 44 | + run: | |
| 45 | + set -euo pipefail |
| 46 | + ls -la ./artifacts/ || true |
| 47 | + |
| 48 | + if [ ! -f "./artifacts/dynamic-plugins.test.yaml" ]; then |
| 49 | + echo "Error: dynamic-plugins.test.yaml not found in artifacts" |
| 50 | + exit 1 |
| 51 | + fi |
| 52 | +
|
| 53 | + echo "dynamic-plugins.test.yaml contents:" |
| 54 | + sed -n '1,40p' ./artifacts/dynamic-plugins.test.yaml || true |
| 55 | + |
| 56 | + # Build Docker run command with conditional volume mounts |
| 57 | + ENV_ARGS=$( [ -f ./artifacts/test.env ] && echo "--env-file ./artifacts/test.env" || echo "" ) |
| 58 | + DOCKER_CMD="docker run -d --name rhdh -p 7007:7007 $ENV_ARGS" |
| 59 | + if [ -f "./artifacts/app-config.yaml" ]; then |
| 60 | + DOCKER_CMD="$DOCKER_CMD -v $(pwd)/artifacts/app-config.yaml:/opt/app-root/src/app-config.yaml" |
| 61 | + fi |
| 62 | + if [ -f "./artifacts/app-config.test.yaml" ]; then |
| 63 | + DOCKER_CMD="$DOCKER_CMD -v $(pwd)/artifacts/app-config.test.yaml:/opt/app-root/src/app-config.test.yaml" |
| 64 | + fi |
| 65 | + DOCKER_CMD="$DOCKER_CMD -v $(pwd)/artifacts/dynamic-plugins.test.yaml:/opt/app-root/src/dynamic-plugins.yaml" |
| 66 | + |
| 67 | + # Add Docker config and environment variables |
| 68 | + echo "Using docker auth file: $HOME/.docker/config.json" |
| 69 | + DOCKER_CMD="$DOCKER_CMD -v $HOME/.docker/config.json:/root/.docker/config.json:ro" |
| 70 | + DOCKER_CMD="$DOCKER_CMD -e REGISTRY_AUTH_FILE=/root/.docker/config.json" |
| 71 | + |
| 72 | + # Add image and command |
| 73 | + DOCKER_CMD="$DOCKER_CMD --entrypoint /bin/bash quay.io/rhdh-community/rhdh:1.6 -c '" |
| 74 | + DOCKER_CMD="$DOCKER_CMD set -ex; " |
| 75 | + DOCKER_CMD="$DOCKER_CMD PLUGINS_ROOT=/opt/app-root/src/dynamic-plugins-root; " |
| 76 | + DOCKER_CMD="$DOCKER_CMD GENERATED_CONFIG=\$PLUGINS_ROOT/app-config.dynamic-plugins.yaml; " |
| 77 | + DOCKER_CMD="$DOCKER_CMD INSTALL_SCRIPT=/opt/app-root/src/install-dynamic-plugins.sh; " |
| 78 | + DOCKER_CMD="$DOCKER_CMD mkdir -p \$PLUGINS_ROOT; " |
| 79 | + DOCKER_CMD="$DOCKER_CMD \$INSTALL_SCRIPT \$PLUGINS_ROOT; " |
| 80 | + DOCKER_CMD="$DOCKER_CMD exec node packages/backend" |
| 81 | + |
| 82 | + # Add config files to command (optional) |
| 83 | + [ -f "./artifacts/app-config.yaml" ] && DOCKER_CMD="$DOCKER_CMD --config /opt/app-root/src/app-config.yaml" |
| 84 | + [ -f "./artifacts/app-config.test.yaml" ] && DOCKER_CMD="$DOCKER_CMD --config /opt/app-root/src/app-config.test.yaml" |
| 85 | + DOCKER_CMD="$DOCKER_CMD --config /opt/app-root/src/dynamic-plugins.yaml" |
| 86 | + DOCKER_CMD="$DOCKER_CMD --config \$GENERATED_CONFIG'" |
| 87 | + |
| 88 | + echo "Running: $DOCKER_CMD" |
| 89 | + eval "$DOCKER_CMD" |
| 90 | +
|
| 91 | + - name: Wait for RHDH to be ready |
| 92 | + run: | |
| 93 | + set -e |
| 94 | + for i in $(seq 1 10); do |
| 95 | + if curl -fsS http://localhost:7007/health >/dev/null; then |
| 96 | + echo "RHDH is ready"; exit 0; fi |
| 97 | + echo "Waiting for RHDH... (Attempt ${i}/10)" |
| 98 | + # Check if container is still running |
| 99 | + if ! docker ps | grep -q rhdh; then |
| 100 | + echo "Container stopped unexpectedly." |
| 101 | + exit 1 |
| 102 | + fi |
| 103 | + sleep 10 |
| 104 | + done |
| 105 | + echo "RHDH did not become ready in time." |
| 106 | + exit 1 |
| 107 | +
|
| 108 | + - name: Check plugin installation folder structure |
| 109 | + run: docker exec rhdh ls -l /opt/app-root/src/dynamic-plugins-root |
| 110 | + |
| 111 | + - name: Check contents of app-config.dynamic-plugins.yaml |
| 112 | + run: docker exec rhdh cat /opt/app-root/src/dynamic-plugins-root/app-config.dynamic-plugins.yaml |
| 113 | + |
| 114 | + - name: Basic health check |
| 115 | + run: | |
| 116 | + curl -fsS http://localhost:7007/health |
| 117 | +
|
| 118 | + - name: Verify plugin loading |
| 119 | + id: collect-results |
| 120 | + run: | |
| 121 | + set -e |
| 122 | + PLUGINS=$(grep -Eo '!([^[:space:]]+)' ./artifacts/dynamic-plugins.test.yaml | sed -e 's/^!//' -e 's/"$//' | sort -u) |
| 123 | + if [ -z "$PLUGINS" ]; then |
| 124 | + echo "No plugins found in dynamic-plugins.test.yaml" |
| 125 | + echo "success=false" >> "$GITHUB_OUTPUT" |
| 126 | + echo "failed-plugins<<EOF" >> "$GITHUB_OUTPUT" |
| 127 | + echo "(no-plugins)" >> "$GITHUB_OUTPUT" |
| 128 | + echo "EOF" >> "$GITHUB_OUTPUT" |
| 129 | + exit 0 |
| 130 | + fi |
| 131 | + LOGS=$(docker logs rhdh || true) |
| 132 | + failures=() |
| 133 | + echo "===== Checking logs for plugin loaded messages" |
| 134 | + for plugin in $PLUGINS; do |
| 135 | + echo "Asserting plugin loaded: $plugin" |
| 136 | + # Match either the unpack path or the canonical "loaded dynamic ... plugin '<pkg>' from" message |
| 137 | + if echo "$LOGS" | grep -qiE "loaded dynamic .* plugin .*${plugin}(-dynamic)?'" ; then |
| 138 | + echo "Plugin loaded: $plugin" |
| 139 | + else |
| 140 | + echo "Plugin NOT loaded: $plugin" |
| 141 | + failures+=("$plugin") |
| 142 | + fi |
| 143 | + done |
| 144 | + if echo "$LOGS" | grep -E "(InstallException|Error while adding OCI plugin|Failed to load dynamic plugin|dynamic plugin.*error)" >/dev/null; then |
| 145 | + echo "Detected dynamic plugin loading errors in logs" |
| 146 | + failures+=("(log-errors)") |
| 147 | + fi |
| 148 | + if [ ${#failures[@]} -eq 0 ]; then |
| 149 | + echo "success=true" >> "$GITHUB_OUTPUT" |
| 150 | + echo "failed-plugins<<EOF" >> "$GITHUB_OUTPUT" |
| 151 | + echo "" >> "$GITHUB_OUTPUT" |
| 152 | + echo "EOF" >> "$GITHUB_OUTPUT" |
| 153 | + else |
| 154 | + echo "success=false" >> "$GITHUB_OUTPUT" |
| 155 | + echo "failed-plugins<<EOF" >> "$GITHUB_OUTPUT" |
| 156 | + printf "%s\n" "${failures[@]}" >> "$GITHUB_OUTPUT" |
| 157 | + echo "EOF" >> "$GITHUB_OUTPUT" |
| 158 | + fi |
| 159 | +
|
| 160 | + - name: Fail if any plugin failed to load |
| 161 | + if: ${{ steps.collect-results.outputs.success != 'true' }} |
| 162 | + run: | |
| 163 | + echo "The following plugins failed to load to RHDH:" |
| 164 | + echo "${{ steps.collect-results.outputs.failed-plugins }}" |
| 165 | + exit 1 |
| 166 | +
|
| 167 | + - name: Container logs |
| 168 | + if: always() |
| 169 | + run: docker logs rhdh || true |
| 170 | + |
| 171 | + - name: Cleanup |
| 172 | + if: always() |
| 173 | + run: docker rm -f rhdh || true |
0 commit comments