|
| 1 | +name: Package |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - src/** |
| 7 | + |
| 8 | +jobs: |
| 9 | + matrix: |
| 10 | + name: Find modified packages |
| 11 | + runs-on: Ubuntu-20.04 |
| 12 | + steps: |
| 13 | + - name: Checkout code |
| 14 | + uses: actions/checkout@v2 |
| 15 | + |
| 16 | + - name: Fetch branch from where the PR started |
| 17 | + run: git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* |
| 18 | + |
| 19 | + - name: Find packages |
| 20 | + id: find-packages |
| 21 | + run: echo "::set-output name=packages::$(php .github/get-modified-packages.php $(find src/Symfony -mindepth 2 -type f -name composer.json -printf '%h\n' | jq -R -s -c 'split("\n")[:-1]') $(git diff --name-only origin/${{ github.base_ref }} HEAD | grep src/ | jq -R -s -c 'split("\n")[:-1]'))" |
| 22 | + |
| 23 | + outputs: |
| 24 | + # Make the outputs accessible outside this job |
| 25 | + packages: ${{ steps.find-packages.outputs.packages }} |
| 26 | + |
| 27 | + meta-files: |
| 28 | + needs: matrix |
| 29 | + name: Meta files |
| 30 | + runs-on: Ubuntu-20.04 |
| 31 | + strategy: |
| 32 | + fail-fast: false |
| 33 | + matrix: |
| 34 | + package: ${{ fromJson(needs.matrix.outputs.packages) }} |
| 35 | + |
| 36 | + steps: |
| 37 | + - name: Checkout code |
| 38 | + uses: actions/checkout@v2 |
| 39 | + |
| 40 | + - name: Verify meta files exists |
| 41 | + run: | |
| 42 | + test -f ${{ matrix.package.directory }}/.gitattributes |
| 43 | + test -f ${{ matrix.package.directory }}/.gitignore |
| 44 | + test -f ${{ matrix.package.directory }}/CHANGELOG.md |
| 45 | + test -f ${{ matrix.package.directory }}/LICENSE |
| 46 | + test -f ${{ matrix.package.directory }}/phpunit.xml.dist |
| 47 | + test ! -f ${{ matrix.package.directory }}/phpunit.xml |
| 48 | + test -f ${{ matrix.package.directory }}/README.md |
| 49 | +
|
| 50 | + - name: License file is correct |
| 51 | + if: ${{ matrix.package.new }} |
| 52 | + run: | |
| 53 | + FIRST_LINE="Copyright (c) $(date +"%Y") Fabien Potencier" |
| 54 | + PACKAGE_FIRST_LINE=$(head -1 ${{ matrix.package.directory }}/LICENSE) |
| 55 | + [[ "$FIRST_LINE" == "$PACKAGE_FIRST_LINE" ]] |
| 56 | +
|
| 57 | + TEMPLATE=$(tail -n +2 LICENSE) |
| 58 | + PACKAGE_LICENSE=$(tail -n +2 ${{ matrix.package.directory }}/LICENSE) |
| 59 | + [[ "$TEMPLATE" == "$PACKAGE_LICENSE" ]] |
| 60 | +
|
| 61 | + - name: Package is in composer.json's replace |
| 62 | + if: ${{ matrix.package.new && !matrix.package.component_bridge }} |
| 63 | + run: cat composer.json | jq -e '.replace."${{ matrix.package.name }}"|test("self.version")' |
0 commit comments