Skip to content

Commit

Permalink
Remove obsolete file and add composer.lock
Browse files Browse the repository at this point in the history
Deleted the obsolete 'beaver' file and added a new 'composer.lock' file to lock project dependencies. This ensures consistent builds and aids in dependency management.
  • Loading branch information
Spomky committed Sep 21, 2024
1 parent a01c2a4 commit c944a70
Show file tree
Hide file tree
Showing 12 changed files with 5,766 additions and 31 deletions.
21 changes: 21 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Contributing

First of all, **thank you** for contributing.

Bugs or feature requests can be posted online on the GitHub issues section of the project.

Few rules to ease code reviews and merges:

- You MUST follow the [PSR-12](http://www.php-fig.org/psr/psr-12/) coding standards.
- You MUST run the test suite.
- You MUST write (or update) unit tests when bugs are fixed or features are added.
- You SHOULD write documentation.

We use [Git-Flow](http://jeffkreeftmeijer.com/2010/why-arent-you-using-git-flow/) to automate our git branching
workflow.

To contribute use [Pull Requests](https://help.github.com/articles/using-pull-requests), please, write commit messages
that make sense, and rebase your branch before submitting your PR.

May be asked to squash your commits too. This is used to "clean" your Pull Request before merging it, avoiding commits
such as fix tests, fix 2, fix 3, etc.
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: Spomky
patreon: FlorentMorselli
17 changes: 17 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Target branch:
Resolves issue # <!-- #-prefixed issue number(s), if any -->

<!-- replace space with "x" in square brackets: [x] -->
- [ ] It is a Bug fix
- [ ] It is a New feature
- [ ] Breaks BC
- [ ] Includes Deprecations

<!--
Fill in this template according to the PR you're about to submit.
Replace this comment by a description of what your PR is solving.
Please consider the following requirement:
* Modification of existing tests should be avoided unless deemed necessary.
* You MUST never open a PR related to a security issue. Contact Spomky in private at https://gitter.im/Spomky/
-->
19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 2
updates:
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
day: "friday"
versioning-strategy: "widen"
open-pull-requests-limit: 20
allow:
- dependency-type: all
labels: [ "dependencies" ]

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
open-pull-requests-limit: 20
labels: [ "dependencies" ]
8 changes: 8 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
daysUntilStale: 30
daysUntilClose: 7
staleLabel: wontfix
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
closeComment: false
58 changes: 58 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: release

on:
push:
tags:
- '*'

jobs:
build:
runs-on: 'ubuntu-latest'

strategy:
fail-fast: false

matrix:
php: ['8.3']
arch: ['x86_64']
os: ['linux']

steps:
- name: 'Checkout Code'
uses: 'actions/checkout@v4'

- name: 'Setup PHP'
uses: 'shivammathur/setup-php@v2'
with:
php-version: '8.3'
extensions: intl, zip, zlib
coverage: none
ini-values: memory_limit=1G, phar.readonly=0

- name: 'Setup Composer Token'
run: |
if [ ! -z '${{ secrets.COMPOSER_TOKEN }}' ]; then
composer config github-oauth.github.com ${{ secrets.COMPOSER_TOKEN }}
fi
- name: 'Compile the application (Linux)'
run: |
vendor/bin/castor repack --os={{ matrix.os }} --app-name=beaver --app-version=${{ github.ref_name }}
vendor/bin/castor compile beaver.linux.phar --php-version=${{ matrix.php }} --arch={{ matrix.arch }} --os={{ matrix.os }}
- name: 'Move applications'
run: mv beaver.* ./bin/

- name: 'Install Project Dependencies'
run: composer install --no-interaction --no-ansi --no-progress

- name: 'Create Release'
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ github.ref_name }}
tag: ${{ github.ref_name }}
body: 'Next stable release.'
allowUpdates: true
artifacts: 'bin/*'
artifactContentType: application/x-php
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
/vendor/
/composer.lock
Empty file added bin/.gitignore
Empty file.
Binary file removed bin/beaver
Binary file not shown.
41 changes: 13 additions & 28 deletions castor.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,21 @@ function infect(int $minMsi = 0, int $minCoveredMsi = 0, bool $ci = false): void
$command[] = '-s';
}
$context = context();
$context->withEnvironment([
$context = $context->withEnvironment([
'XDEBUG_MODE' => 'coverage',
]);
run($command, context: $context);
}

#[AsTask(description: 'Run PHPUnit tests.')]
function test(bool $coverageHtml = false, bool $coverageText = false, null|string $group = null): void
#[AsTask(description: 'Run PHPUnit tests.', ignoreValidationErrors: true)]
function test(#[AsRawTokens] array $args = []): void
{
io()->title('Running tests');
$command = ['php', 'vendor/bin/phpunit', '--color'];
$command = ['php', 'vendor/bin/phpunit', ...$args];
$context = context();
$context->withEnvironment([
'XDEBUG_MODE' => 'off',
$context = $context->withEnvironment([
'XDEBUG_MODE' => 'coverage',
]);
if ($coverageHtml) {
$command[] = '--coverage-html=build/coverage';
$context->withEnvironment([
'XDEBUG_MODE' => 'coverage',
]);
}
if ($coverageText) {
$command[] = '--coverage-text';
$context->withEnvironment([
'XDEBUG_MODE' => 'coverage',
]);
}
if ($group !== null) {
$command[] = sprintf('--group=%s', $group);
}
run($command, context: $context);
}

Expand All @@ -71,7 +56,7 @@ function cs(bool $fix = false): void
io()->title('Running coding standards check');
$command = ['php', 'vendor/bin/ecs', 'check'];
$context = context();
$context->withEnvironment([
$context = $context->withEnvironment([
'XDEBUG_MODE' => 'off',
]);
if ($fix) {
Expand All @@ -90,7 +75,7 @@ function stan(bool $baseline = false): void
}
$command = ['php', 'vendor/bin/phpstan', ...$options];
$context = context();
$context->withEnvironment([
$context = $context->withEnvironment([
'XDEBUG_MODE' => 'off',
]);
run($command, context: $context);
Expand All @@ -102,7 +87,7 @@ function validate(): void
io()->title('Validating Composer configuration');
$command = ['composer', 'validate', '--strict'];
$context = context();
$context->withEnvironment([
$context = $context->withEnvironment([
'XDEBUG_MODE' => 'off',
]);
run($command, context: $context);
Expand All @@ -122,10 +107,10 @@ function checkLicenses(
$allowedExceptions = [];
$command = ['composer', 'licenses', '-f', 'json'];
$context = context();
$context->withEnvironment([
$context = $context->withEnvironment([
'XDEBUG_MODE' => 'off',
]);
$context->withQuiet();
$context = $context->withQuiet();
$result = run($command, context: $context);
if (! $result->isSuccessful()) {
io()->error('Cannot determine licenses');
Expand Down Expand Up @@ -180,7 +165,7 @@ function rector(bool $fix = false): void
$command[] = '--dry-run';
}
$context = context();
$context->withEnvironment([
$context = $context->withEnvironment([
'XDEBUG_MODE' => 'off',
]);
run($command, context: $context);
Expand All @@ -192,7 +177,7 @@ function deptrac(): void
io()->title('Running Rector');
$command = ['php', 'vendor/bin/deptrac', 'analyse', '--fail-on-uncovered', '--no-cache'];
$context = context();
$context->withEnvironment([
$context = $context->withEnvironment([
'XDEBUG_MODE' => 'off',
]);
run($command, context: $context);
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spomky/custom-beaver",
"description": "A st of commands to manage your PHP projects",
"description": "A set of commands to manage your PHP projects",
"authors": [
{
"name": "Florent Morselli",
Expand All @@ -13,7 +13,7 @@
"require": {
"php": ">=8.1",
"ext-zip": "*",
"jolicode/castor": "^0.18.3",
"jolicode/castor": "^0.18",
"ekino/phpstan-banned-code": "^2.1",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.3",
Expand Down
Loading

0 comments on commit c944a70

Please sign in to comment.