Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 47e3709

Browse filesBrowse files
committed
Test metafiles for packages
1 parent bb1e1e5 commit 47e3709
Copy full SHA for 47e3709

File tree

2 files changed

+106
-0
lines changed
Filter options

2 files changed

+106
-0
lines changed

‎.github/get-modified-packages.php

Copy file name to clipboard
+43Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
/*
4+
* Given a list of all packages, find the package that have been modified.
5+
*/
6+
7+
if (3 > $_SERVER['argc']) {
8+
echo "Usage: app-packages modified-files\n";
9+
exit(1);
10+
}
11+
12+
$allPackages = json_decode($_SERVER['argv'][1], true, 512, \JSON_THROW_ON_ERROR);
13+
$modifiedFiles = json_decode($_SERVER['argv'][2], true, 512, \JSON_THROW_ON_ERROR);
14+
15+
function isComponentBridge(string $packageDir): bool {
16+
return 0 < preg_match('@Symfony/Component/.*/Bridge/@', $packageDir);
17+
}
18+
19+
$newPackage = [];
20+
$modifiedPackages = [];
21+
foreach ($modifiedFiles as $file) {
22+
foreach ($allPackages as $package) {
23+
if (0 === strpos($file, $package)) {
24+
$modifiedPackages[$package] = true;
25+
if ('LICENSE' === substr($file, -7)) {
26+
/*
27+
* There is never a reason to modify the LICENSE file, this diff
28+
* must be adding a new package
29+
*/
30+
$newPackage[$package] = true;
31+
}
32+
break;
33+
}
34+
}
35+
}
36+
37+
$output = [];
38+
foreach ($modifiedPackages as $directory => $bool) {
39+
$name = json_decode(file_get_contents($directory.'/composer.json'), true)['name'] ?? 'unknown';
40+
$output[] = ['name' => $name, 'directory' => $directory, 'new' => $newPackage[$directory] ?? false, 'component_bridge' => isComponentBridge($directory)];
41+
}
42+
43+
echo json_encode($output);

‎.github/workflows/package-tests.yml

Copy file name to clipboard
+63Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.