Skip to content

Commit

Permalink
contribution files
Browse files Browse the repository at this point in the history
  • Loading branch information
dgafka committed Nov 4, 2024
1 parent 6a8707e commit 87ba3b5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/contribution-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,18 @@ jobs:
const prBody = context.payload.pull_request.body;
if (!prBody.includes("[X] I have read and agree to the contribution terms outlined in [CONTRIBUTING.md](https://github.com/ecotoneframework/ecotone-dev/blob/main/CONTRIBUTING.md)")) {
core.setFailed("Contributor has not agreed to the contribution terms. Please provide set X in the checkbox to agree to the terms. `[X] I have read and agree to the contribution terms outlined in [CONTRIBUTING.md](https://github.com/ecotoneframework/ecotone-dev/blob/main/CONTRIBUTING.md)`");
}
}
check-files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set Up PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2

- name: Check for Contribution Files
shell: bash
run: |
php bin/check-files.php
4 changes: 2 additions & 2 deletions bin/add-apache-licence.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

$finder = new \Symfony\Component\Finder\Finder();

$files = $finder->files()->in(__DIR__ . "/../packages")->name("*.php");
$files = $finder->files()->in(__DIR__ . "/../packages/*/src")->name("*.php");

function addLicenceToFile(string $file)
{
$lines = file($file);
foreach ($lines as $index => $line) {
if (preg_match('/^\s*(abstract class|final class|class|interface)\s+/', $line)) {
if (preg_match('/^\s*(abstract class|final class|class|interface|trait)\s+/', $line)) {
array_splice($lines, $index, 0, [
<<<LICENCE
/**
Expand Down
4 changes: 2 additions & 2 deletions bin/add-enterprise-licence.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

$finder = new \Symfony\Component\Finder\Finder();

$files = $finder->files()->in(__DIR__ . "/../packages")->name("*.php");
$files = $finder->files()->in(__DIR__ . "/../packages/*/src")->name("*.php");

function addLicenceToFile(string $file)
{
$lines = file($file);
foreach ($lines as $index => $line) {
if (preg_match('/^\s*(abstract class|final class|class|interface)\s+/', $line)) {
if (preg_match('/^\s*(abstract class|final class|class|interface|trait)\s+/', $line)) {
array_splice($lines, $index, 0, [
<<<LICENCE
/**
Expand Down
18 changes: 18 additions & 0 deletions bin/check-licence.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/*
* licence Apache-2.0
*/

require __DIR__ . "/../vendor/autoload.php";

$finder = new \Symfony\Component\Finder\Finder();

$files = $finder->files()->in(__DIR__ . "/../packages/*/src")->name("*.php");

foreach ($files as $file) {
$fileContent = file_get_contents($file->getRealPath());

if (! preg_match('/\*\s*(@licence|licence)\s+(Enterprise|Apache\-2\.0)\s*/', $fileContent, $matches)) {
throw new \RuntimeException("Missing licence in file: " . $file->getRealPath());
}
}

0 comments on commit 87ba3b5

Please sign in to comment.