<commit_before>name: Packages

on:
    push:
        paths:
            - "src/Sylius/Bundle/**"
            - "src/Sylius/Component/**"
    pull_request:
        paths:
            - "src/Sylius/Bundle/**"
            - "src/Sylius/Component/**"
    release:
        types: [created]
    schedule:
        -
            cron: "0 1 * * 6" # Run at 1am every Saturday

jobs:
    list:
        runs-on: ubuntu-latest
        
        name: "Create a list of packages"
        
        steps:
            -   
                uses: actions/checkout@v2
                
            -   
                name: "Provide the list"
                id: create-list
                run: echo "::set-output name=packages::$(find src/Sylius -mindepth 3 -maxdepth 3 -type f -name composer.json -exec dirname '{}' \; | sed -e 's/src\/Sylius\///g' | sort | jq  --raw-input . | jq --slurp . | jq -c .)"

        outputs:
            packages: "${{ steps.create-list.outputs.packages }}"

    test:
        needs: list
        
        runs-on: ubuntu-latest
        
        name: "${{ matrix.package }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}"
        
        strategy:
            fail-fast: false
            matrix:
                php: [7.3, 7.4]
                symfony: [4.4.*]
                package: "${{ fromJson(needs.list.outputs.packages) }}"
        
        steps:
            -   
                uses: actions/checkout@v2

            -   
                name: Setup PHP
                uses: shivammathur/setup-php@v2
                with:
                    php-version: "${{ matrix.php }}"
                    coverage: none

            -   
                name: Get Composer cache directory
                id: composer-cache
                run: echo "::set-output name=dir::$(composer config cache-files-dir)"

            -   
                name: Cache Composer
                uses: actions/cache@v2
                with:
                    path: ${{ steps.composer-cache.outputs.dir }}
                    key: ${{ runner.os }}-php-${{ matrix.php }}-package-${{ matrix.package }}-composer-${{ hashFiles(format('src/Sylius/{0}/composer.json', matrix.package)) }}
                    restore-keys: |
                        ${{ runner.os }}-php-${{ matrix.php }}-package-${{ matrix.package }}-composer-
                        ${{ runner.os }}-php-${{ matrix.php }}-package-

            -   
                name: Restrict Symfony version
                if: matrix.symfony != ''
                run: |
                    composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10"
                    composer config extra.symfony.require "${{ matrix.symfony }}"
                    
            -
                name: Validate composer.json
                run: composer validate --ansi --strict
                working-directory: "src/Sylius/${{ matrix.package }}"
                
            -<commit_msg>[CI] Fix requiring specific Symfony version in packages build<commit_after>name: Packages

on:
    push:
        paths:
            - "src/Sylius/Bundle/**"
            - "src/Sylius/Component/**"
    pull_request:
        paths:
            - "src/Sylius/Bundle/**"
            - "src/Sylius/Component/**"
    release:
        types: [created]
    schedule:
        -
            cron: "0 1 * * 6" # Run at 1am every Saturday

jobs:
    list:
        runs-on: ubuntu-latest
        
        name: "Create a list of packages"
        
        steps:
            -   
                uses: actions/checkout@v2
                
            -   
                name: "Provide the list"
                id: create-list
                run: echo "::set-output name=packages::$(find src/Sylius -mindepth 3 -maxdepth 3 -type f -name composer.json -exec dirname '{}' \; | sed -e 's/src\/Sylius\///g' | sort | jq  --raw-input . | jq --slurp . | jq -c .)"

        outputs:
            packages: "${{ steps.create-list.outputs.packages }}"

    test:
        needs: list
        
        runs-on: ubuntu-latest
        
        name: "${{ matrix.package }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}"
        
        strategy:
            fail-fast: false
            matrix:
                php: [7.3, 7.4]
                symfony: [4.4.*]
                package: "${{ fromJson(needs.list.outputs.packages) }}"
        
        steps:
            -   
                uses: actions/checkout@v2

            -   
                name: Setup PHP
                uses: shivammathur/setup-php@v2
                with:
                    php-version: "${{ matrix.php }}"
                    coverage: none

            -   
                name: Get Composer cache directory
                id: composer-cache
                run: echo "::set-output name=dir::$(composer config cache-files-dir)"

            -   
                name: Cache Composer
                uses: actions/cache@v2
                with:
                    path: ${{ steps.composer-cache.outputs.dir }}
                    key: ${{ runner.os }}-php-${{ matrix.php }}-package-${{ matrix.package }}-composer-${{ hashFiles(format('src/Sylius/{0}/composer.json', matrix.package)) }}
                    restore-keys: |
                        ${{ runner.os }}-php-${{ matrix.php }}-package-${{ matrix.package }}-composer-
                        ${{ runner.os }}-php-${{ matrix.php }}-package-

            -   
                name: Restrict Symfony version
                if: matrix.symfony != ''
                run: |
                    composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10"
                    composer config extra.symfony.require "${{ matrix.symfony }}"
                working-directory: "src/Sylius/${{ matrix.package }}"
                    
            -
                name: Validate composer.json
                run: composer validate --ansi --strict
                working-directory: "src/Sylius/${{ matrix.package }}"
                
            -
{'fraction_non_alphanumeric': 0.13143989431968295, 'fraction_numerical': 0.0066050198150594455, 'mean_word_length': 1.1455897980871412, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4202506', 'n_tokens_mistral': 1754, 'n_tokens_neox': 1639, 'n_words': 363}