[CI] Ensure JS packages (either from vendor/ or npm versions) can be installed/used inside an Encore App
#5886
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: Symfony UX | |
| on: | |
| push: | |
| paths-ignore: | |
| - 'src/*/doc/**' | |
| - 'src/**/*.md' | |
| - 'ux.symfony.com/**' | |
| pull_request: | |
| paths-ignore: | |
| - 'src/*/doc/**' | |
| - 'src/**/*.md' | |
| - 'ux.symfony.com/**' | |
| jobs: | |
| coding-style-js: | |
| name: JavaScript Coding Style | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: corepack enable | |
| - uses: actions/setup-node@v4 | |
| with: | |
| cache: 'yarn' | |
| - run: yarn --immutable | |
| - run: yarn ci | |
| js-dist-current: | |
| name: Check for UnBuilt JS Dist Files | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: corepack enable | |
| - uses: actions/setup-node@v4 | |
| with: | |
| cache: 'yarn' | |
| cache-dependency-path: | | |
| yarn.lock | |
| **/package.json | |
| - run: yarn --immutable && yarn build | |
| - name: Check if JS dist files are current | |
| run: | | |
| if [[ -n $(git status --porcelain) ]]; then | |
| echo "The Git workspace is unclean! Changes detected:" | |
| git status --porcelain | |
| git diff | |
| exit 1 | |
| else | |
| echo "The Git workspace is clean. No changes detected." | |
| fi | |
| tests-php-components: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| components: ${{ steps.components.outputs.components }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - id: components | |
| run: | | |
| components=$(find src/ -mindepth 2 -type f -name composer.json -not -path "*/vendor/*" -printf '%h\n' | jq -R -s -c 'split("\n")[:-1] | map(. | sub("^src/";"")) | sort') | |
| echo "$components" | |
| echo "components=$components" >> $GITHUB_OUTPUT | |
| tests-php: | |
| runs-on: ubuntu-latest | |
| needs: tests-php-components | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php-version: ['8.1', '8.3', '8.4'] | |
| minimum-stability: ['stable', 'dev'] | |
| include: | |
| - php-version: '8.1' | |
| dependency-version: 'lowest' | |
| - php-version: '8.3' | |
| dependency-version: 'highest' | |
| - php-version: '8.4' | |
| dependency-version: 'highest' | |
| component: ${{ fromJson(needs.tests-php-components.outputs.components )}} | |
| exclude: | |
| - php-version: '8.1' | |
| minimum-stability: 'dev' | |
| - php-version: '8.3' | |
| minimum-stability: 'dev' | |
| - component: Map # does not support PHP 8.1 | |
| php-version: '8.1' | |
| - component: Map/src/Bridge/Google # does not support PHP 8.1 | |
| php-version: '8.1' | |
| - component: Map/src/Bridge/Leaflet # does not support PHP 8.1 | |
| php-version: '8.1' | |
| - component: Swup # has no tests | |
| - component: Turbo # has its own workflow (test-turbo.yml) | |
| - component: Typed # has no tests | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php-version }} | |
| - name: Install root packages | |
| uses: ramsey/composer-install@v3 | |
| with: | |
| working-directory: ${{ github.workspace }} | |
| dependency-versions: ${{ matrix.dependency-version }} | |
| - name: Build root packages | |
| run: php .github/build-packages.php | |
| working-directory: ${{ github.workspace }} | |
| - name: Configure ${{ matrix.minimum-stability }} stability | |
| if: ${{ matrix.minimum-stability }} | |
| run: composer config minimum-stability ${{ matrix.minimum-stability }} | |
| working-directory: "src/${{ matrix.component }}" | |
| - name: Install ${{ matrix.component }} packages | |
| uses: ramsey/composer-install@v3 | |
| with: | |
| working-directory: "src/${{ matrix.component }}" | |
| dependency-versions: ${{ matrix.dependency-version }} | |
| - name: ${{ matrix.component }} Tests | |
| working-directory: "src/${{ matrix.component }}" | |
| run: vendor/bin/simple-phpunit | |
| tests-js: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: corepack enable | |
| - uses: actions/setup-node@v4 | |
| with: | |
| cache: 'yarn' | |
| cache-dependency-path: | | |
| yarn.lock | |
| package.json | |
| src/**/package.json | |
| - run: yarn --immutable | |
| - run: yarn playwright install | |
| - run: yarn test | |
| test-app-encore-app: | |
| name: "Test Apps / Encore (${{ matrix.name}})" | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: Internal (from "vendor/") | |
| ux-packages-source: php-vendor | |
| - name: External (from "yarn add") | |
| ux-packages-source: js-packages | |
| steps: | |
| # Setup | |
| - uses: actions/checkout@v4 | |
| - run: corepack enable | |
| - uses: actions/setup-node@v4 | |
| with: | |
| cache: 'yarn' | |
| cache-dependency-path: | | |
| yarn.lock | |
| package.json | |
| src/**/package.json | |
| test_apps/encore-app/package.json | |
| - uses: shivammathur/setup-php@v2 | |
| - name: Install root dependencies | |
| uses: ramsey/composer-install@v3 | |
| with: | |
| working-directory: ${{ github.workspace }} | |
| - name: Build root packages | |
| run: php .github/build-packages.php | |
| working-directory: ${{ github.workspace }} | |
| - uses: ramsey/composer-install@v3 | |
| with: | |
| dependency-versions: 'highest' | |
| working-directory: test_apps/encore-app | |
| - if: matrix.ux-packages-source == 'js-packages' | |
| working-directory: test_apps/encore-app | |
| run: | | |
| PACKAGES_TO_INSTALL='' | |
| for PACKAGE in $(cd ../..; yarn workspaces list --no-private --json); do | |
| PACKAGE_DIR=../../$(echo $PACKAGE | jq -r '.location') | |
| PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL $PACKAGE_DIR" | |
| done | |
| echo "Installing packages: $PACKAGES_TO_INSTALL" | |
| yarn add --dev $PACKAGES_TO_INSTALL | |
| # Validations | |
| - name: Ensure UX packages are installed from "${{ matrix.ux-packages-source == 'php-vendor' && 'vendor/symfony/ux-...' || '../../../src/**/assets' }}" | |
| working-directory: test_apps/encore-app | |
| run: | | |
| for PACKAGE in $(cat package.json | jq -c '(.dependencies // {}) + (.devDependencies // {}) | to_entries[] | select(.key | startswith("@symfony/ux-")) | {name: .key, version: .value}'); do | |
| PACKAGE_NAME=$(echo $PACKAGE | jq -r '.name') | |
| PACKAGE_VERSION=$(echo $PACKAGE | jq -r '.version') | |
| echo -n "Checking $PACKAGE_NAME@$PACKAGE_VERSION..." | |
| if [[ $PACKAGE_VERSION == $EXPECTED_PATTERN* ]]; then | |
| echo " OK" | |
| else | |
| echo " KO" | |
| echo "The package version of $PACKAGE_NAME must starts with the pattern (e.g.: $EXPECTED_PATTERN), got $PACKAGE_VERSION instead." | |
| exit 1 | |
| fi | |
| done; | |
| env: | |
| EXPECTED_PATTERN: ${{ matrix.ux-packages-source == 'php-vendor' && 'file:vendor/symfony/*' || '../../src/*' }} | |
| - name: Run Encore | |
| working-directory: test_apps/encore-app | |
| run: | | |
| YARN_ENABLE_HARDENED_MODE=0 yarn || (echo "Unable to install Yarn dependencies" && exit 1) | |
| yarn encore dev || (echo "Unable to build Encore assets (dev)" && exit 1) | |
| yarn encore production || (echo "Unable to build Encore assets (production)" && exit 1) |