feat(deploy): Add QR code to PR comments #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test Components | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| permissions: | |
| contents: read | |
| jobs: | |
| test-qr-generation: | |
| name: Test QR Code Generation | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install qrencode | |
| run: sudo apt-get update && sudo apt-get install -y qrencode | |
| - name: Test QR code generation | |
| run: | | |
| URL="https://editor-pr123-regel-k4c.rig.prd1.gn2.quattro.rijksapps.nl" | |
| # Generate QR code as base64 | |
| QR_BASE64=$(qrencode -o - -t PNG -s 4 -m 1 "$URL" | base64 -w0) | |
| # Verify output is valid base64 PNG | |
| echo "Base64 length: ${#QR_BASE64}" | |
| if [ ${#QR_BASE64} -lt 100 ]; then | |
| echo "QR code generation failed - output too small" | |
| exit 1 | |
| fi | |
| # Verify it starts with PNG magic bytes (base64 encoded) | |
| if [[ ! "$QR_BASE64" =~ ^iVBOR ]]; then | |
| echo "QR code generation failed - not a valid PNG" | |
| exit 1 | |
| fi | |
| echo "QR code generated successfully" | |
| # Create test HTML | |
| echo "<img src='data:image/png;base64,${QR_BASE64}' width='100' height='100'>" > qr-test.html | |
| - name: Upload test artifact | |
| if: ${{ !env.ACT }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: qr-test | |
| path: qr-test.html | |
| test-input-validation: | |
| name: Test Input Validation | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Test valid inputs | |
| run: | | |
| # These should all pass validation | |
| for input in "my-project" "pr123" "my.service" "foo_bar" "CamelCase"; do | |
| if ! echo "$input" | grep -qE '^[a-zA-Z0-9._-]+$'; then | |
| echo "FAIL: '$input' should be valid" | |
| exit 1 | |
| fi | |
| echo "PASS: '$input' is valid" | |
| done | |
| - name: Test invalid inputs | |
| run: | | |
| # These should all fail validation | |
| for input in "has space" "has;semicolon" 'has"quote' "has\$dollar" "has/slash"; do | |
| if echo "$input" | grep -qE '^[a-zA-Z0-9._-]+$'; then | |
| echo "FAIL: '$input' should be invalid" | |
| exit 1 | |
| fi | |
| echo "PASS: '$input' is correctly rejected" | |
| done | |
| test-payload-construction: | |
| name: Test Payload Construction | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Test basic payload | |
| run: | | |
| DEPLOYMENT_NAME="pr123" | |
| COMPONENT="editor" | |
| IMAGE="ghcr.io/org/app:latest" | |
| PAYLOAD=$(jq -n \ | |
| --arg name "$DEPLOYMENT_NAME" \ | |
| --arg ref "$COMPONENT" \ | |
| --arg image "$IMAGE" \ | |
| '{ | |
| deploymentName: $name, | |
| components: [{ | |
| reference: $ref, | |
| image: $image | |
| }] | |
| }') | |
| echo "$PAYLOAD" | jq . | |
| # Verify structure | |
| if [ "$(echo "$PAYLOAD" | jq -r '.deploymentName')" != "pr123" ]; then | |
| echo "FAIL: deploymentName mismatch" | |
| exit 1 | |
| fi | |
| echo "PASS: Basic payload constructed correctly" | |
| - name: Test clone payload | |
| run: | | |
| DEPLOYMENT_NAME="pr123" | |
| COMPONENT="editor" | |
| IMAGE="ghcr.io/org/app:latest" | |
| CLONE_FROM="production" | |
| PAYLOAD=$(jq -n \ | |
| --arg name "$DEPLOYMENT_NAME" \ | |
| --arg ref "$COMPONENT" \ | |
| --arg image "$IMAGE" \ | |
| --arg clone "$CLONE_FROM" \ | |
| --argjson force true \ | |
| '{ | |
| deploymentName: $name, | |
| cloneFrom: $clone, | |
| forceClone: $force, | |
| components: [{ | |
| reference: $ref, | |
| image: $image | |
| }] | |
| }') | |
| echo "$PAYLOAD" | jq . | |
| # Verify clone fields | |
| if [ "$(echo "$PAYLOAD" | jq -r '.cloneFrom')" != "production" ]; then | |
| echo "FAIL: cloneFrom mismatch" | |
| exit 1 | |
| fi | |
| if [ "$(echo "$PAYLOAD" | jq -r '.forceClone')" != "true" ]; then | |
| echo "FAIL: forceClone mismatch" | |
| exit 1 | |
| fi | |
| echo "PASS: Clone payload constructed correctly" |