Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 109 additions & 1 deletion .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,114 @@ concurrency:
cancel-in-progress: true

jobs:
validate-packages:
name: Validate packages definition
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Check all composer.json have label "symfony-ux"
if: always()
run: |
for file in $(find src/ -mindepth 2 -type f -name composer.json); do
if ! jq -e '.keywords | index("symfony-ux")' "$file" > /dev/null; then
echo "File $file does not have the keyword 'symfony-ux' in its composer.json";
exit 1;
fi
done

- name: Check all composer.json have license "MIT"
if: always()
run: |
for file in $(find src/ -mindepth 2 -type f -name composer.json); do
if ! jq -e '.license == "MIT"' "$file" > /dev/null; then
echo "File $file does not have the license 'MIT' in its composer.json";
exit 1;
fi
done

- name: Check all composer.json have minimum-stability "dev"
if: always()
run: |
for file in $(find src/ -mindepth 2 -type f -name composer.json); do
if ! jq -e '."minimum-stability" == "dev"' "$file" > /dev/null; then
echo "File $file does not have the minimum-stability 'dev' in its composer.json";
exit 1;
fi
done

- name: Check all composer.json have dependency to "php" >=8.1
if: always()
run: |
for file in $(find src/ -mindepth 2 -type f -name composer.json); do
if ! jq -e '.require.php | test(">=8.1")' "$file" > /dev/null; then
echo "File $file does not have the dependency 'php' >=8.1 in its composer.json";
exit 1;
fi
done

- name: Check all package.json have license "MIT"
if: always()
run: |
for file in $(find src/ -mindepth 2 -type f -name package.json -not -path "*/tests/*"); do
if ! jq -e '.license == "MIT"' "$file" > /dev/null; then
echo "File $file does not have the license 'MIT' in its package.json";
exit 1;
fi
done

- name: Check all package.json have keywords including "symfony-ux"
if: always()
run: |
for file in $(find src/ -mindepth 2 -type f -name package.json -not -path "*/tests/*"); do
if ! jq -e '.keywords | index("symfony-ux")' "$file" > /dev/null; then
echo "File $file does not have the keyword 'symfony-ux' in its package.json";
exit 1;
fi
done


- name: Check all package.json have type "module"
if: always()
run: |
for file in $(find src/ -mindepth 2 -type f -name package.json -not -path "*/tests/*"); do
if ! jq -e '.type == "module"' "$file" > /dev/null; then
echo "File $file does not have the type 'module' in its package.json";
exit 1;
fi
done

- name: Check all package.json have files '["dist"]'
if: always()
run: |
for file in $(find src/ -mindepth 2 -type f -name package.json -not -path "*/tests/*"); do
if ! jq -e '.files | index("dist")' "$file" > /dev/null; then
echo "File $file does not have the files 'dist' in its package.json";
exit 1;
fi
done

- name: Check all package.json peerDependencies are present in devDependencies and importmap to the exact same version
if: always()
run: |
for file in $(find src/ -mindepth 2 -type f -name package.json -not -path "*/tests/*"); do
peerDependencies=$(jq -r '.peerDependencies | keys[]' "$file")
for peerDependency in $peerDependencies; do
peerDependencyVersion=$(jq -r --arg dep "$peerDependency" '.peerDependencies[$dep]' "$file")
importmapVersion=$(jq -r ".symfony.importmap.\"$peerDependency\" | if type == \"string\" then . else .version end" "$file")

if [ "$importmapVersion" == null ]; then
echo "File $file does not have the peerDependency '$peerDependency' in its symfony.importmap, skipping version check";
continue
fi

if [ "$peerDependencyVersion" != "$importmapVersion" ]; then
echo "File $file has a mismatch for $peerDependency: peerDependency version is '$peerDependencyVersion' but symfony.importmap version is '$importmapVersion'";
exit 1;
fi
done
done

coding-style-js:
name: JavaScript Coding Style
runs-on: ubuntu-latest
Expand Down Expand Up @@ -68,7 +176,7 @@ jobs:

# TODO: Only Turbo has PHPStan configuration, let's improve this later :)
PACKAGES=Turbo
#PACKAGES=$(find src/ -mindepth 2 -type f -name composer.json -not -path "*/vendor/*" -printf '%h\n' | sed 's/^src\///' | sort | tr '\n' ' ')
#PACKAGES=$(find src/ -mindepth 2 -type f -name composer.json -printf '%h\n' | sed 's/^src\///' | sort | tr '\n' ' ')
echo "Packages: $PACKAGES"
echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV

Expand Down
45 changes: 4 additions & 41 deletions bin/test_package.sh → bin/unit_test_package.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# This script is used to test an UX package.
# This script is used to unit test assets from an UX package.
# It also handle the case where a package has multiple versions of a peerDependency defined.

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
Expand All @@ -21,13 +21,6 @@ if [ ! -d "$location" ]; then
exit 1
fi

shift
case "$1" in
--unit) testType="unit" ;;
--browser) testType="browser" ;;
*) echo "Unknown test type: $2. Please use --unit or --browser."; exit 1 ;;
esac

shift
args=("$@")

Expand All @@ -38,15 +31,9 @@ if ! command -v jq &> /dev/null; then
fi

runTestSuite() {
if [ "$testType" == "unit" ]; then
echo -e "🧪 Running unit tests for $workspace...\n"
# Using "cd" instead of "pnpm --filter" prevent rendering issues in GitHub Actions that does not support nested groups
(cd "$location"; pnpm exec vitest --run "${args[@]}") || { all_tests_passed=false; }
elif [ "$testType" == "browser" ]; then
echo -e "🧪 Running browser tests for $workspace...\n"
# Using "cd" instead of "pnpm --filter" prevent rendering issues in GitHub Actions that does not support nested groups
(cd "$location"; pnpm exec playwright test "${args[@]}") || { all_tests_passed=false; }
fi
echo -e "🧪 Running unit tests for $workspace...\n"
# Using "cd" instead of "pnpm --filter" prevent rendering issues in GitHub Actions that does not support nested groups
(cd "$location"; pnpm exec vitest --run "${args[@]}") || { all_tests_passed=false; }
}

processWorkspace() {
Expand All @@ -69,30 +56,6 @@ processWorkspace() {

echo -e "⏳ Processing workspace $workspace at location $location...\n"

# TODO: Refactor the `test_package.sh` script to its simple form: only run unit tests for a given UX package,
# The rest will be moved to `pnpm` scripts or other CI checks
if [ "$testType" == "browser" ]; then
runTestSuite
fi

echo "⚙️ Checking '$package_json_path' for peerDependencies and importmap dependencies to have the same version"
deps=$(jq -r '.peerDependencies | keys[]' "$package_json_path")
for library in $deps; do
version=$(jq -r ".peerDependencies.\"$library\"" "$package_json_path")
importmap_version=$(jq -r ".symfony.importmap.\"$library\" | if type == \"string\" then . else .version end" "$package_json_path")

if [ "$importmap_version" == null ]; then
echo " ⚠ No importmap version found for $library in $package_json_path, skipping..."
continue
fi

if [ "$version" != "$importmap_version" ]; then
echo " ⚠ Version mismatch for $library: $version (peerDependencies) vs $importmap_version (importmap)"
echo " ⚠ You need to match the version of the \"peerDependency\" with the version in the \"importmap\""
exit 1
fi
done

echo "⚙️ Checking '$package_json_path' for peerDependencies with multiple versions defined"
deps_with_multiple_versions=$(jq -r '.peerDependencies | to_entries[] | select(.value | contains("||")) | .key' "$package_json_path")

Expand Down
6 changes: 3 additions & 3 deletions src/Autocomplete/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"build": "tsx ../../../bin/build_package.ts .",
"watch": "tsx ../../../bin/build_package.ts . --watch",
"test": "pnpm run test:unit && pnpm run test:browser",
"test:unit": "../../../bin/test_package.sh . --unit",
"test:browser": "../../../bin/test_package.sh . --browser",
"test:browser:ui": "../../../bin/test_package.sh . --browser --ui",
"test:unit": "../../../bin/unit_test_package.sh .",
"test:browser": "playwright test",
"test:browser:ui": "playwright test --ui",
"check": "biome check",
"ci": "biome ci"
},
Expand Down
6 changes: 3 additions & 3 deletions src/Chartjs/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"build": "tsx ../../../bin/build_package.ts .",
"watch": "tsx ../../../bin/build_package.ts . --watch",
"test": "pnpm run test:unit && pnpm run test:browser",
"test:unit": "../../../bin/test_package.sh . --unit",
"test:browser": "../../../bin/test_package.sh . --browser",
"test:browser:ui": "../../../bin/test_package.sh . --browser --ui",
"test:unit": "../../../bin/unit_test_package.sh .",
"test:browser": "playwright test",
"test:browser:ui": "playwright test --ui",
"check": "biome check",
"ci": "biome ci"
},
Expand Down
6 changes: 3 additions & 3 deletions src/Cropperjs/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"build": "tsx ../../../bin/build_package.ts .",
"watch": "tsx ../../../bin/build_package.ts . --watch",
"test": "pnpm run test:unit && pnpm run test:browser",
"test:unit": "../../../bin/test_package.sh . --unit",
"test:browser": "../../../bin/test_package.sh . --browser",
"test:browser:ui": "../../../bin/test_package.sh . --browser --ui",
"test:unit": "../../../bin/unit_test_package.sh .",
"test:browser": "playwright test",
"test:browser:ui": "playwright test --ui",
"check": "biome check",
"ci": "biome ci"
},
Expand Down
6 changes: 3 additions & 3 deletions src/Dropzone/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"build": "tsx ../../../bin/build_package.ts .",
"watch": "tsx ../../../bin/build_package.ts . --watch",
"test": "pnpm run test:unit && pnpm run test:browser",
"test:unit": "../../../bin/test_package.sh . --unit",
"test:browser": "../../../bin/test_package.sh . --browser",
"test:browser:ui": "../../../bin/test_package.sh . --browser --ui",
"test:unit": "../../../bin/unit_test_package.sh .",
"test:browser": "playwright test",
"test:browser:ui": "playwright test --ui",
"check": "biome check",
"ci": "biome ci"
},
Expand Down
2 changes: 1 addition & 1 deletion src/LazyImage/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"build": "tsx ../../../bin/build_package.ts .",
"watch": "tsx ../../../bin/build_package.ts . --watch",
"test": "pnpm run test:unit",
"test:unit": "../../../bin/test_package.sh . --unit",
"test:unit": "../../../bin/unit_test_package.sh .",
"check": "biome check",
"ci": "biome ci"
},
Expand Down
6 changes: 3 additions & 3 deletions src/LiveComponent/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"build": "tsx ../../../bin/build_package.ts .",
"watch": "tsx ../../../bin/build_package.ts . --watch",
"test": "pnpm run test:unit && pnpm run test:browser",
"test:unit": "../../../bin/test_package.sh . --unit",
"test:browser": "../../../bin/test_package.sh . --browser",
"test:browser:ui": "../../../bin/test_package.sh . --browser --ui",
"test:unit": "../../../bin/unit_test_package.sh .",
"test:browser": "playwright test",
"test:browser:ui": "playwright test --ui",
"check": "biome check",
"ci": "biome ci"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Map/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"build": "tsx ../../../bin/build_package.ts .",
"watch": "tsx ../../../bin/build_package.ts . --watch",
"test": "pnpm run test:unit",
"test:unit": "../../../bin/test_package.sh . --unit",
"test:unit": "../../../bin/unit_test_package.sh .",
"check": "biome check",
"ci": "biome ci"
},
Expand Down
4 changes: 2 additions & 2 deletions src/Map/src/Bridge/Google/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"build": "tsx ../../../../../../bin/build_package.ts .",
"watch": "tsx ../../../../../../bin/build_package.ts . --watch",
"test": "pnpm run test:browser",
"test:browser": "../../../../../../bin/test_package.sh . --browser",
"test:browser:ui": "../../../../../../bin/test_package.sh . --browser --ui",
"test:browser": "playwright test",
"test:browser:ui": "playwright test --ui",
"check": "biome check",
"ci": "biome ci"
},
Expand Down
4 changes: 2 additions & 2 deletions src/Map/src/Bridge/Leaflet/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"build": "tsx ../../../../../../bin/build_package.ts .",
"watch": "tsx ../../../../../../bin/build_package.ts . --watch",
"test": "pnpm run test:browser",
"test:browser": "../../../../../../bin/test_package.sh . --browser",
"test:browser:ui": "../../../../../../bin/test_package.sh . --browser --ui",
"test:browser": "playwright test",
"test:browser:ui": "playwright test --ui",
"check": "biome check",
"ci": "biome ci"
},
Expand Down
6 changes: 3 additions & 3 deletions src/Notify/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"build": "tsx ../../../bin/build_package.ts .",
"watch": "tsx ../../../bin/build_package.ts . --watch",
"test": "pnpm run test:unit && pnpm run test:browser",
"test:unit": "../../../bin/test_package.sh . --unit",
"test:browser": "../../../bin/test_package.sh . --browser",
"test:browser:ui": "../../../bin/test_package.sh . --browser --ui",
"test:unit": "../../../bin/unit_test_package.sh .",
"test:browser": "playwright test",
"test:browser:ui": "playwright test --ui",
"check": "biome check",
"ci": "biome ci"
},
Expand Down
6 changes: 3 additions & 3 deletions src/React/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"build": "tsx ../../../bin/build_package.ts .",
"watch": "tsx ../../../bin/build_package.ts . --watch",
"test": "pnpm run test:unit && pnpm run test:browser",
"test:unit": "../../../bin/test_package.sh . --unit",
"test:browser": "../../../bin/test_package.sh . --browser",
"test:browser:ui": "../../../bin/test_package.sh . --browser --ui",
"test:unit": "../../../bin/unit_test_package.sh .",
"test:browser": "playwright test",
"test:browser:ui": "playwright test --ui",
"check": "biome check",
"ci": "biome ci"
},
Expand Down
2 changes: 1 addition & 1 deletion src/StimulusBundle/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"build": "tsx ../../../bin/build_package.ts .",
"watch": "tsx ../../../bin/build_package.ts . --watch",
"test": "pnpm run test:unit && pnpm run test:browser",
"test:unit": "../../../bin/test_package.sh . --unit",
"test:unit": "../../../bin/unit_test_package.sh .",
"check": "biome check",
"ci": "biome ci"
},
Expand Down
6 changes: 3 additions & 3 deletions src/Svelte/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"build": "tsx ../../../bin/build_package.ts .",
"watch": "tsx ../../../bin/build_package.ts . --watch",
"test": "pnpm run test:unit && pnpm run test:browser",
"test:unit": "../../../bin/test_package.sh . --unit",
"test:browser": "../../../bin/test_package.sh . --browser",
"test:browser:ui": "../../../bin/test_package.sh . --browser --ui",
"test:unit": "../../../bin/unit_test_package.sh .",
"test:browser": "playwright test",
"test:browser:ui": "playwright test --ui",
"check": "biome check",
"ci": "biome ci"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Swup/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"build": "tsx ../../../bin/build_package.ts .",
"watch": "tsx ../../../bin/build_package.ts . --watch",
"test": "pnpm run test:unit",
"test:unit": "../../../bin/test_package.sh . --unit",
"test:unit": "../../../bin/unit_test_package.sh .",
"check": "biome check",
"ci": "biome ci"
},
Expand Down
3 changes: 3 additions & 0 deletions src/Swup/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"homepage": "https://symfony.com/contributors"
}
],
"require": {
"php": ">=8.1"
},
"autoload": {
"psr-4": {
"Symfony\\UX\\Swup\\": "src/"
Expand Down
2 changes: 1 addition & 1 deletion src/TogglePassword/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"build": "tsx ../../../bin/build_package.ts .",
"watch": "tsx ../../../bin/build_package.ts . --watch",
"test": "pnpm run test:unit",
"test:unit": "../../../bin/test_package.sh . --unit",
"test:unit": "../../../bin/unit_test_package.sh .",
"check": "biome check",
"ci": "biome ci"
},
Expand Down
Loading
Loading