Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#42] Converted to standalone Symfony Console CLI app #59

Merged
merged 36 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
1c6e233
Init.
tannguyen04 Feb 26, 2024
639be1d
test.
tannguyen04 Feb 26, 2024
578f1e2
Update test, lint.
tannguyen04 Feb 26, 2024
2c2ecb2
Add bin and set memory limit for composer lint.
tannguyen04 Feb 26, 2024
2eb9d0c
Remove memory limit set.
tannguyen04 Feb 26, 2024
6e8bc71
Debug failing.
tannguyen04 Feb 26, 2024
0d4bc58
Debug.
tannguyen04 Feb 26, 2024
bb29863
test
tannguyen04 Feb 26, 2024
02d4dc8
debug.
tannguyen04 Feb 27, 2024
8358d23
Merge branch 'main' into feature/convert-to-symfony-app
AlexSkrypnyk Feb 27, 2024
3294b75
Fixed namespaces.
AlexSkrypnyk Feb 27, 2024
547e6dd
Added GHA build step.
AlexSkrypnyk Feb 27, 2024
0fd4f2b
Init using symfony console/
tannguyen04 Mar 5, 2024
3602386
Update composer package.
tannguyen04 Mar 5, 2024
c95e02d
Add symfony/finder.
tannguyen04 Mar 5, 2024
f78e792
Update git command.
tannguyen04 Mar 5, 2024
bb3082f
Add no-pager option to git.
tannguyen04 Mar 5, 2024
d6b977f
Update git checkout command and git commit command.
tannguyen04 Mar 5, 2024
ea87f3e
test
tannguyen04 Mar 5, 2024
f442408
test
tannguyen04 Mar 5, 2024
15343c1
test
tannguyen04 Mar 5, 2024
a2acf5e
Update test.
tannguyen04 Mar 6, 2024
f80c9cc
Update test & lint.
tannguyen04 Mar 6, 2024
67e1b1c
Using symfony/finder 6 to work with php-8.1.
tannguyen04 Mar 6, 2024
696a8d1
Remove Artifact trait.
tannguyen04 Mar 6, 2024
c556166
Remove cover test related to ArtifactTrait.
tannguyen04 Mar 6, 2024
8690505
Test build phar.
tannguyen04 Mar 6, 2024
f9cbb42
Change build phar using 8.3
tannguyen04 Mar 6, 2024
d9d08eb
Require symfony file system to make phar build work.
tannguyen04 Mar 6, 2024
f777a7c
Using filesystem v6.
tannguyen04 Mar 6, 2024
5a50f8c
Update test build.
tannguyen04 Mar 6, 2024
f0c5ea2
Remove Robo text.
tannguyen04 Mar 6, 2024
18d64e9
test
tannguyen04 Mar 6, 2024
90fd452
Add monolog
tannguyen04 Mar 6, 2024
96d183f
Add debug mode.
tannguyen04 Mar 6, 2024
4722e36
Enable debug for gitwrapper.
tannguyen04 Mar 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
- run:
name: Deployment 1
command: |
vendor/bin/robo artifact \
./git-artifact \
[email protected]:drevops/git-artifact-destination.git \
--branch=mode--force-push--circleci--[branch] \
--mode=force-push \
Expand All @@ -117,7 +117,7 @@ jobs:
- run:
name: Deployment 2
command: |
vendor/bin/robo artifact \
./git-artifact \
[email protected]:drevops/git-artifact-destination.git \
--branch=mode--force-push--circleci--[branch] \
--mode=force-push \
Expand Down Expand Up @@ -166,7 +166,7 @@ jobs:
- run:
name: Deployment 1
command: |
vendor/bin/robo artifact \
./git-artifact \
[email protected]:drevops/git-artifact-destination.git \
--branch=mode--branch--circleci--[branch]--[timestamp:Y-m-d_H-i] \
--mode=branch \
Expand All @@ -183,7 +183,7 @@ jobs:
- run:
name: Deployment 2 - same branch
command: |
vendor/bin/robo artifact \
./git-artifact \
[email protected]:drevops/git-artifact-destination.git \
--branch=mode--branch--circleci--[branch]--[timestamp:Y-m-d_H-i] \
--mode=branch \
Expand All @@ -203,7 +203,7 @@ jobs:
- run:
name: Deployment 2 - new branch
command: |
vendor/bin/robo artifact \
./git-artifact \
[email protected]:drevops/git-artifact-destination.git \
--branch=mode--branch--circleci--[branch]--[timestamp:Y-m-d_H-i-s] \
--mode=branch \
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/box.json export-ignore
/tests export-ignore
/phpcs.xml export-ignore
/phpmd.xml export-ignore
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/release-php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Release PHP

on:
push:
tags:
- '*'

permissions:
contents: write

jobs:
release-php:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1

- name: Install dependencies
run: composer install

- name: Build PHAR
run: composer build

- name: Test PHAR
run: ./.build/git-artifact || exit 1

- name: Get tag name
id: get-version
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
./.build/git-artifact
48 changes: 41 additions & 7 deletions .github/workflows/test-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,41 @@ jobs:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

build-php:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1

- name: Install dependencies
run: composer install

- name: Check composer version
run: composer --version

- name: Build PHAR
run: composer build

- name: Test PHAR
run: ./.build/git-artifact --help || exit 1
#;> PHP_PHAR

# Demonstration of deployment in 'force-push' mode.
deploy-force-push:
needs: test-php
needs:
- test-php
- build-php

runs-on: ubuntu-latest

Expand Down Expand Up @@ -123,7 +155,7 @@ jobs:

- name: Deployment 1
run: |
vendor/bin/robo artifact \
./git-artifact \
[email protected]:drevops/git-artifact-destination.git \
--branch=mode--force-push--gha--[branch] \
--mode=force-push \
Expand All @@ -146,7 +178,7 @@ jobs:

- name: Deployment 2
run: |
vendor/bin/robo artifact \
./git-artifact \
[email protected]:drevops/git-artifact-destination.git \
--branch=mode--force-push--gha--[branch] \
--mode=force-push \
Expand All @@ -164,7 +196,9 @@ jobs:
# of the second push. This is because the mode is intended to create a new
# branch per artifact deployment.
deploy-branch:
needs: test-php
needs:
- test-php
- build-php

runs-on: ubuntu-latest

Expand Down Expand Up @@ -223,7 +257,7 @@ jobs:

- name: Deployment 1
run: |
vendor/bin/robo artifact \
./git-artifact \
[email protected]:drevops/git-artifact-destination.git \
--branch=mode--branch--gha--[branch]--[timestamp:Y-m-d_H-i] \
--mode=branch \
Expand All @@ -246,7 +280,7 @@ jobs:

- name: Deployment 2 - same branch
run: |
vendor/bin/robo artifact \
./git-artifact \
[email protected]:drevops/git-artifact-destination.git \
--branch=mode--branch--gha--[branch]--[timestamp:Y-m-d_H-i] \
--mode=branch \
Expand All @@ -257,7 +291,7 @@ jobs:

- name: Deployment 2 - new branch
run: |
vendor/bin/robo artifact \
./git-artifact \
[email protected]:drevops/git-artifact-destination.git \
--branch=mode--branch--gha--[branch]--[timestamp:Y-m-d_H-i-s] \
--mode=branch \
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/cobertura.xml
/composer.lock
/vendor
/vendor-bin
31 changes: 2 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,34 +90,8 @@ composer require drevops/git-artifact
```

## Usage

Use provided [`RoboFile.php`](RoboFile.php) or create a custom `RoboFile.php`
in your repository with the following content:

```php
<?php
use DrevOps\Robo\ArtifactTrait;

/**
* Class RoboFile.
*/
class RoboFile extends \Robo\Tasks
{

use ArtifactTrait {
ArtifactTrait::__construct as private __artifactConstruct;
}

public function __construct()
{
$this->__artifactConstruct();
}
}
```

### Run
```shell
vendor/bin/robo artifact [email protected]:yourorg/your-repo-destination.git
./git-artifact [email protected]:yourorg/your-repo-destination.git
```

This will create an artifact from current directory and will send it to the
Expand All @@ -133,8 +107,7 @@ See examples:
Call from CI configuration or deployment script:
```shell
export DEPLOY_BRANCH=<YOUR_CI_PROVIDER_BRANCH_VARIABLE>
vendor/bin/robo --load-from "${HOME}/.composer/vendor/drevops/git-artifact/RoboFile.php" artifact \
[email protected]:yourorg/your-repo-destination.git \
./git-artifact [email protected]:yourorg/your-repo-destination.git \
--branch="${DEPLOY_BRANCH}" \
--push
```
Expand Down
28 changes: 0 additions & 28 deletions RoboFile.php

This file was deleted.

13 changes: 13 additions & 0 deletions box.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"output": ".build/git-artifact",
"compression": "GZ",
"finder": [
{
"in": "./",
"exclude": [
"php-script",
"tests"
]
}
]
}
19 changes: 14 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "drevops/git-artifact",
"type": "robo-tasks",
"type": "package",
"description": "Build artifact from your codebase in CI and push it to a separate git repo.",
"license": "GPL-2.0-or-later",
"authors": [
Expand All @@ -16,9 +16,14 @@
},
"require": {
"php": ">=8.1",
"consolidation/robo": "^4"
"cpliakas/git-wrapper": "^3.1",
"symfony/console": "^6",
"symfony/finder": "^6",
"symfony/filesystem": "^6",
"monolog/monolog": "^3.5"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"escapestudios/symfony2-coding-standard": "^3",
"phpmd/phpmd": "^2.15",
Expand All @@ -29,16 +34,17 @@
},
"autoload": {
"psr-4": {
"DrevOps\\Robo\\": "src"
"DrevOps\\GitArtifact\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"DrevOps\\Robo\\Tests\\": "tests"
"DrevOps\\GitArtifact\\Tests\\": "tests"
}
},
"config": {
"allow-plugins": {
"bamarni/composer-bin-plugin": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
Expand All @@ -59,5 +65,8 @@
"box validate",
"box compile"
]
}
},
"bin": [
"git-artifact"
]
}
12 changes: 12 additions & 0 deletions git-artifact
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env php
<?php

foreach ([$GLOBALS['_composer_autoload_path'] ?? NULL, __DIR__ . '/../../autoload.php', __DIR__ . '/../vendor/autoload.php', __DIR__ . '/vendor/autoload.php'] as $file) {
if ($file && file_exists($file)) {
require_once $file;
unset($file);
break;
}
}

require __DIR__ . '/src/app.php';
1 change: 0 additions & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
@see https://github.com/squizlabs/PHP_CodeSniffer/issues/2916
-->
<file>src</file>
<file>RoboFile.php</file>
<file>tests</file>

<rule ref="Symfony.Commenting.License.Warning">
Expand Down
1 change: 0 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ parameters:
paths:
- src
- tests
- RoboFile.php

excludePaths:
- vendor/*
Expand Down
Loading