feat(simple-message-app): redesign and refactor #1761
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: Edge App Checks | |
| on: | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - "edge-apps/**" | |
| pull_request: | |
| branches: | |
| - "**" | |
| paths: | |
| - "edge-apps/**" | |
| jobs: | |
| detect-changes: | |
| name: Detect Changed Edge Apps | |
| runs-on: ubuntu-latest | |
| outputs: | |
| changed-apps: ${{ steps.extract-changes.outputs.changed-apps }} | |
| apps-with-build-system: ${{ steps.build-system-check.outputs.apps-with-build-system }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get changed files | |
| id: changed-files | |
| uses: tj-actions/changed-files@v47 | |
| with: | |
| files: | | |
| edge-apps/** | |
| files_ignore: | | |
| edge-apps/**/node_modules/** | |
| edge-apps/**/dist/** | |
| edge-apps/**/.git/** | |
| edge-apps/**/*.log | |
| - name: Extract changed Edge Apps | |
| id: extract-changes | |
| run: | | |
| # Get list of changed files | |
| CHANGED_FILES="${{ steps.changed-files.outputs.all_changed_files }}" | |
| # Read CHANGED_FILES into an array | |
| read -ra FILES_ARRAY <<< "$CHANGED_FILES" | |
| # Function to add app to list if it has build system and isn't already included | |
| add_app_if_valid() { | |
| local app="$1" | |
| if [[ -n "$app" && "$app" != "helpers" && "$app" != ".bun-create" && "$app" != "blueprint" ]]; then | |
| if [[ -f "edge-apps/$app/package.json" ]]; then | |
| if [[ ! " $CHANGED_APPS " =~ $app ]]; then | |
| CHANGED_APPS="$CHANGED_APPS $app" | |
| fi | |
| fi | |
| fi | |
| } | |
| # Check if blueprint or edge-apps-library has changes and extract unique Edge App directories | |
| BLUEPRINT_CHANGED=false | |
| EDGE_APPS_LIBRARY_CHANGED=false | |
| CHANGED_APPS="" | |
| for file in "${FILES_ARRAY[@]}"; do | |
| if [[ "$file" == edge-apps/* ]]; then | |
| # Check for blueprint changes | |
| if [[ "$file" == edge-apps/blueprint/* ]]; then | |
| BLUEPRINT_CHANGED=true | |
| fi | |
| # Check for edge-apps-library changes | |
| if [[ "$file" == edge-apps/edge-apps-library/* ]]; then | |
| EDGE_APPS_LIBRARY_CHANGED=true | |
| fi | |
| # Extract the app name (first directory after edge-apps/) | |
| APP_NAME=$(echo "$file" | cut -d'/' -f2) | |
| add_app_if_valid "$APP_NAME" | |
| fi | |
| done | |
| # If blueprint or edge-apps-library changed, add all apps with build systems | |
| if [[ "$BLUEPRINT_CHANGED" == "true" || "$EDGE_APPS_LIBRARY_CHANGED" == "true" ]]; then | |
| if [[ "$BLUEPRINT_CHANGED" == "true" ]]; then | |
| echo "Blueprint changed, adding all apps with build systems..." | |
| fi | |
| if [[ "$EDGE_APPS_LIBRARY_CHANGED" == "true" ]]; then | |
| echo "edge-apps-library changed, adding all apps with build systems..." | |
| fi | |
| # Dynamically discover all Edge Apps with build systems | |
| for app_dir in edge-apps/*/; do | |
| if [[ -d "$app_dir" ]]; then | |
| app=$(basename "$app_dir") | |
| add_app_if_valid "$app" | |
| fi | |
| done | |
| fi | |
| # Remove leading space and set output | |
| CHANGED_APPS="${CHANGED_APPS# }" | |
| echo "changed-apps=$CHANGED_APPS" >> "$GITHUB_OUTPUT" | |
| echo "Changed Edge Apps: $CHANGED_APPS" | |
| - name: Check which apps have build systems | |
| id: build-system-check | |
| run: | | |
| CHANGED_APPS="${{ steps.extract-changes.outputs.changed-apps }}" | |
| APPS_WITH_BUILD_SYSTEM="" | |
| # Read CHANGED_APPS into an array | |
| read -ra APPS_ARRAY <<< "$CHANGED_APPS" | |
| for app in "${APPS_ARRAY[@]}"; do | |
| if [[ -f "edge-apps/$app/package.json" ]]; then | |
| APPS_WITH_BUILD_SYSTEM="$APPS_WITH_BUILD_SYSTEM $app" | |
| fi | |
| done | |
| # Remove leading space and convert to JSON array | |
| APPS_WITH_BUILD_SYSTEM="${APPS_WITH_BUILD_SYSTEM# }" | |
| if [[ -n "$APPS_WITH_BUILD_SYSTEM" ]]; then | |
| # Convert space-separated string to JSON array | |
| JSON_ARRAY=$(echo "$APPS_WITH_BUILD_SYSTEM" | tr ' ' '\n' | jq -R . | jq -s -c .) | |
| echo "apps-with-build-system=$JSON_ARRAY" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "apps-with-build-system=[]" >> "$GITHUB_OUTPUT" | |
| fi | |
| echo "Apps with build system: $APPS_WITH_BUILD_SYSTEM" | |
| run-checks: | |
| name: Run Checks for ${{ matrix.app }} | |
| runs-on: ubuntu-latest | |
| needs: detect-changes | |
| strategy: | |
| matrix: | |
| app: ${{ fromJSON(needs.detect-changes.outputs.apps-with-build-system) }} | |
| fail-fast: false | |
| if: needs.detect-changes.outputs.apps-with-build-system != '[]' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: 1.2.2 | |
| - name: Build edge-apps-library if needed | |
| run: | | |
| if [[ -d "edge-apps/edge-apps-library" ]] && grep -q "edge-apps-library" "edge-apps/${{ matrix.app }}/package.json"; then | |
| echo "Building edge-apps-library dependency..." | |
| cd edge-apps/edge-apps-library | |
| bun install | |
| bun run build | |
| fi | |
| - name: Install dependencies | |
| working-directory: edge-apps/${{ matrix.app }} | |
| run: bun install | |
| - name: Run linting | |
| working-directory: edge-apps/${{ matrix.app }} | |
| run: bun run lint | |
| - name: Run formatting check | |
| working-directory: edge-apps/${{ matrix.app }} | |
| run: bun run format:check | |
| - name: Run unit tests | |
| working-directory: edge-apps/${{ matrix.app }} | |
| run: bun run test:unit | |
| - name: Build application | |
| working-directory: edge-apps/${{ matrix.app }} | |
| run: bun run build | |
| - name: Check for E2E tests | |
| id: check-e2e | |
| working-directory: edge-apps/${{ matrix.app }} | |
| run: | | |
| if grep -q '"test:e2e"' package.json; then | |
| echo "has-e2e=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "has-e2e=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Install E2E dependencies | |
| if: steps.check-e2e.outputs.has-e2e == 'true' | |
| working-directory: edge-apps/${{ matrix.app }} | |
| run: npx playwright install --with-deps | |
| - name: Run E2E tests | |
| if: steps.check-e2e.outputs.has-e2e == 'true' | |
| uses: nick-fields/retry@v3 | |
| with: | |
| timeout_minutes: 5 | |
| max_attempts: 5 | |
| retry_on: error | |
| command: cd edge-apps/${{ matrix.app }} && bun run test:e2e | |
| summary: | |
| name: Summary | |
| runs-on: ubuntu-latest | |
| needs: [detect-changes, run-checks] | |
| if: always() | |
| steps: | |
| - name: Check if any apps were processed | |
| run: | | |
| if [[ "${{ needs.detect-changes.outputs.changed-apps }}" == "" ]]; then | |
| echo "No Edge Apps were changed." | |
| elif [[ "${{ needs.detect-changes.outputs.apps-with-build-system }}" == "[]" ]]; then | |
| echo "Changed Edge Apps don't have build systems: ${{ needs.detect-changes.outputs.changed-apps }}" | |
| else | |
| echo "Processed Edge Apps with build systems: ${{ needs.detect-changes.outputs.apps-with-build-system }}" | |
| fi | |
| - name: Check for failures | |
| if: needs.run-checks.result == 'failure' | |
| run: | | |
| echo "Some Edge App checks failed. Please review the logs above." | |
| exit 1 |