Skip to content

fix

fix #2

name: Test build of extensions in repository

Check failure on line 1 in .github/workflows/extensions-build-test.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/extensions-build-test.yaml

Invalid workflow file

(Line: 84, Col: 9): Unrecognized named-value: 'jobs'. Located at position 1 within expression: jobs.find-extensions.outputs.all_skipped != 'true'
on:
workflow_call:
inputs:
disable_exts_build:
required: false
type: string
default: ''
description: 'A comma-separated list of package subfolder names (under pkg/) to exclude from the build matrix.'
outputs:
build-job-status:
value: ${{ jobs.test-build.outputs.build-status }}
jobs:
find-extensions:
name: Find Extensions to Build
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
all_skipped: ${{ steps.set-matrix.outputs.ALL_SKIPPED }} # Pass through the skip signal
steps:
- name: Checkout Repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Find and Filter Subfolders
id: set-matrix
shell: bash
run: |
# 1. Define the extensions to ignore from the workflow input
# Converts the comma-separated string into a bash array for easy lookup
IFS=',' read -r -a DISABLED_PKGS <<< "${{ inputs.disable_exts_build }}"
# 2. Find all potential extensions (folders with package.json)
# find pkg/ -maxdepth 2 -type f -name "package.json" -printf '%h\n' | sed -E 's/pkg\/(.*)/\1/'
ALL_PKGS_STR=$(find pkg/ -maxdepth 2 -type f -name "package.json" -printf '%h\n' | sed -E 's/pkg\/(.*)/\1/')
# 3. Filter out disabled extensions
PKGS_TO_BUILD=()
while IFS= read -r PKG_NAME; do
# Check if the current package name is in the DISABLED_PKGS array
IS_DISABLED=false
for DISABLED in "${DISABLED_PKGS[@]}"; do
if [ "$PKG_NAME" == "$DISABLED" ]; then
echo "Skipping disabled package: $PKG_NAME"
IS_DISABLED=true
break
fi
done
# If not disabled, add it to the list to build
if ! $IS_DISABLED; then
PKGS_TO_BUILD+=("$PKG_NAME")
fi
done <<< "$ALL_PKGS_STR"
if [ ${#PKGS_TO_BUILD[@]} -eq 0 ]; then
# ... (Warning and setting ALL_SKIPPED=true logic)
echo "::warning::All packages were skipped or not found."
MATRIX="{\"folder\": []}"
echo "ALL_SKIPPED=true" >> $GITHUB_OUTPUT
else
# 1. Join the array elements with a comma
PKGS_CSV=$(IFS=,; echo "${PKGS_TO_BUILD[*]}")
# 2. Format the CSV string into a JSON array structure: ["item1", "item2"]
# The substitution replaces commas with '","' and wraps the whole string in '["..."]'
JSON_ARRAY=$(echo $PKGS_CSV | sed 's/,/","/g' | sed 's/^/["/' | sed 's/$/"]/')
# 3. Create the final matrix object
MATRIX="{\"folder\": ${JSON_ARRAY}}"
echo "ALL_SKIPPED=false" >> $GITHUB_OUTPUT
echo "Final packages CSV: $PKGS_CSV"
fi
echo "MATRIX=$MATRIX" >> $GITHUB_OUTPUT
echo "Final extensions to build: ${PKGS_TO_BUILD[*]}"
test-build:
if: ${{ jobs.find-extensions.outputs.all_skipped != 'true' }}
name: Test build ${{ matrix.folder }}
runs-on: ubuntu-latest
needs: find-extensions
outputs:
build-status: ${{ job.status }}
strategy:
fail-fast: false
matrix:
${{ fromJson(needs.find-extensions.outputs.matrix) }}
steps:
- name: Checkout Repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Install Node
uses: actions/setup-node@v5
with:
node-version-file: .nvmrc
cache: yarn
- name: Install Dependencies
shell: bash
run: yarn install
- name: "Build extension: ${{ matrix.folder }}"
run: yarn build-pkg ${{ matrix.folder }}