diff --git a/.circleci/config.yml b/.circleci/config.yml index 41e90e1..d4b2201 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -62,8 +62,8 @@ jobs: - run: name: Demonstration of deployment in 'force-push' mode. command: | - vendor/bin/robo artefact \ - git@github.com:integratedexperts/robo-git-artefact-destination.git \ + vendor/bin/robo artifact \ + git@github.com:drevops/git-artifact-destination.git \ --mode=force-push \ --branch=mode-force-push \ --report=$HOME/report-mode-force-push.txt \ @@ -73,8 +73,8 @@ jobs: - run: name: Demonstration of deployment in 'branch' mode. command: | - vendor/bin/robo artefact \ - git@github.com:integratedexperts/robo-git-artefact-destination.git \ + vendor/bin/robo artifact \ + git@github.com:drevops/git-artifact-destination.git \ --mode=branch \ --branch=mode-branch-[timestamp:Y-m-d_H-i-s] \ --report=$HOME/report-mode-branch.txt \ diff --git a/.gitignore b/.gitignore index 4bbca26..c9a01eb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ vendor -artefact +artifact composer.lock git_* +.phpunit.result.cache diff --git a/.phpunit.result.cache b/.phpunit.result.cache deleted file mode 100644 index ccf2481..0000000 --- a/.phpunit.result.cache +++ /dev/null @@ -1 +0,0 @@ -{"version":1,"defects":{"IntegratedExperts\\Robo\\Tests\\Integration\\BranchTest::testBuild":4,"IntegratedExperts\\Robo\\Tests\\Integration\\BranchTest::testBuildMoreCommitsSameBranch":4,"IntegratedExperts\\Robo\\Tests\\Integration\\BranchTest::testBuildMoreCommits":4,"IntegratedExperts\\Robo\\Tests\\Integration\\BranchTest::testCleanupAfterSuccess":4,"IntegratedExperts\\Robo\\Tests\\Integration\\BranchTest::testCleanupAfterFailure":4,"IntegratedExperts\\Robo\\Tests\\Integration\\BranchTest::testGitignore":4,"IntegratedExperts\\Robo\\Tests\\Integration\\BranchTest::testGitignoreCustom":4,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testBuild":4,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testBuildMoreCommits":4,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testIdempotence":4,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testSubRepos":4,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testCleanupAfterSuccess":4,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testCleanupAfterFailure":3,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testGitignore":4,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testGitignoreCustom":4,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testGitignoreCustomRemoveCommittedFiles":4,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testGitignoreCustomWhitelisting":4,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testBuildTag":4,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testBuildMultipleTags":4,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testBuildMultipleTagsDelimiter":4,"IntegratedExperts\\Robo\\Tests\\Integration\\GeneralTest::testInfo":4,"IntegratedExperts\\Robo\\Tests\\Integration\\GeneralTest::testShowChanges":4,"IntegratedExperts\\Robo\\Tests\\Integration\\GeneralTest::testNoCleanup":4,"IntegratedExperts\\Robo\\Tests\\Integration\\GeneralTest::testReport":4,"IntegratedExperts\\Robo\\Tests\\Integration\\GeneralTest::testDebug":4,"IntegratedExperts\\Robo\\Tests\\Integration\\GeneralTest::testDebugDisabled":4,"IntegratedExperts\\Robo\\Tests\\Integration\\TagTest::testDetachedTag":4},"times":{"IntegratedExperts\\Robo\\Tests\\Integration\\BranchTest::testBuild":1.482,"IntegratedExperts\\Robo\\Tests\\Integration\\BranchTest::testBuildMoreCommitsSameBranch":3.087,"IntegratedExperts\\Robo\\Tests\\Integration\\BranchTest::testBuildMoreCommits":3.061,"IntegratedExperts\\Robo\\Tests\\Integration\\BranchTest::testCleanupAfterSuccess":1.62,"IntegratedExperts\\Robo\\Tests\\Integration\\BranchTest::testCleanupAfterFailure":3.13,"IntegratedExperts\\Robo\\Tests\\Integration\\BranchTest::testGitignore":2.85,"IntegratedExperts\\Robo\\Tests\\Integration\\BranchTest::testGitignoreCustom":1.067,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testBuild":1.394,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testBuildMoreCommits":3.21,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testIdempotence":2.926,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testSubRepos":0.552,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testCleanupAfterSuccess":1.419,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testCleanupAfterFailure":0.808,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testGitignore":2.782,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testGitignoreCustom":1.021,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testGitignoreCustomRemoveCommittedFiles":0.429,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testGitignoreCustomWhitelisting":0.545,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testBuildTag":1.397,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testBuildMultipleTags":1.754,"IntegratedExperts\\Robo\\Tests\\Integration\\ForcePushTest::testBuildMultipleTagsDelimiter":1.7,"IntegratedExperts\\Robo\\Tests\\Integration\\GeneralTest::testPresence":0.376,"IntegratedExperts\\Robo\\Tests\\Integration\\GeneralTest::testHelp":0.285,"IntegratedExperts\\Robo\\Tests\\Integration\\GeneralTest::testCompulsoryParameter":0.319,"IntegratedExperts\\Robo\\Tests\\Integration\\GeneralTest::testInfo":1.083,"IntegratedExperts\\Robo\\Tests\\Integration\\GeneralTest::testShowChanges":0.888,"IntegratedExperts\\Robo\\Tests\\Integration\\GeneralTest::testNoCleanup":0.897,"IntegratedExperts\\Robo\\Tests\\Integration\\GeneralTest::testReport":0.891,"IntegratedExperts\\Robo\\Tests\\Integration\\GeneralTest::testDebug":0.996,"IntegratedExperts\\Robo\\Tests\\Integration\\GeneralTest::testDebugDisabled":1.009,"IntegratedExperts\\Robo\\Tests\\Integration\\TagTest::testDetachedTag":1.765,"IntegratedExperts\\Robo\\Tests\\Integration\\TokenTest::testTokenProcess with data set #0":0.098,"IntegratedExperts\\Robo\\Tests\\Integration\\TokenTest::testTokenProcess with data set #1":0.134,"IntegratedExperts\\Robo\\Tests\\Integration\\TokenTest::testTokenProcess with data set #2":0.125,"IntegratedExperts\\Robo\\Tests\\Integration\\TokenTest::testTokenProcess with data set #3":0.173,"IntegratedExperts\\Robo\\Tests\\Integration\\TokenTest::testTokenProcess with data set #4":0.154,"IntegratedExperts\\Robo\\Tests\\Integration\\TokenTest::testTokenProcess with data set #5":0.099,"IntegratedExperts\\Robo\\Tests\\Integration\\TokenTest::testTokenProcess with data set #6":0.121,"IntegratedExperts\\Robo\\Tests\\Integration\\TokenTest::testTokenProcess with data set #7":0.112,"IntegratedExperts\\Robo\\Tests\\Integration\\TokenTest::testTokenProcess with data set #8":0.114,"IntegratedExperts\\Robo\\Tests\\Integration\\TokenTest::testTokenProcess with data set #9":0.118,"IntegratedExperts\\Robo\\Tests\\Integration\\TokenTest::testHasToken with data set #0":0.117,"IntegratedExperts\\Robo\\Tests\\Integration\\TokenTest::testHasToken with data set #1":0.121,"IntegratedExperts\\Robo\\Tests\\Integration\\TokenTest::testHasToken with data set #2":0.117,"IntegratedExperts\\Robo\\Tests\\Integration\\TokenTest::testHasToken with data set #3":0.234,"IntegratedExperts\\Robo\\Tests\\Integration\\TokenTest::testHasToken with data set #4":0.118,"IntegratedExperts\\Robo\\Tests\\Integration\\TokenTest::testHasToken with data set #5":0.102,"IntegratedExperts\\Robo\\Tests\\Unit\\ExcludeTest::testExcludeExists":0.112,"IntegratedExperts\\Robo\\Tests\\Unit\\ExcludeTest::testExcludeEmpty with data set #0":0.107,"IntegratedExperts\\Robo\\Tests\\Unit\\ExcludeTest::testExcludeEmpty with data set #1":0.102,"IntegratedExperts\\Robo\\Tests\\Unit\\ExcludeTest::testExcludeEmpty with data set #2":0.116,"IntegratedExperts\\Robo\\Tests\\Unit\\ExcludeTest::testExcludeEmpty with data set #3":0.114,"IntegratedExperts\\Robo\\Tests\\Unit\\ExcludeTest::testExcludeEmpty with data set #4":0.132,"IntegratedExperts\\Robo\\Tests\\Unit\\ExcludeTest::testExcludeEmpty with data set #5":0.14,"IntegratedExperts\\Robo\\Tests\\Unit\\ExcludeTest::testExcludeEmpty with data set #6":0.113,"IntegratedExperts\\Robo\\Tests\\Unit\\ExcludeTest::testExcludeEmpty with data set #7":0.121,"IntegratedExperts\\Robo\\Tests\\Unit\\ExcludeTest::testExcludeEmpty with data set #8":0.113,"IntegratedExperts\\Robo\\Tests\\Unit\\ExcludeTest::testExcludeEmpty with data set #9":0.118,"IntegratedExperts\\Robo\\Tests\\Unit\\ExcludeTest::testExcludeEmpty with data set #10":0.109,"IntegratedExperts\\Robo\\Tests\\Unit\\ExcludeTest::testExcludeEmpty with data set #11":0.114,"IntegratedExperts\\Robo\\Tests\\Unit\\ExcludeTest::testExcludeEmpty with data set #12":0.114,"IntegratedExperts\\Robo\\Tests\\Unit\\ExcludeTest::testExcludeEmpty with data set #13":0.111}} \ No newline at end of file diff --git a/README.md b/README.md index 9983a1e..9ff4dcf 100644 --- a/README.md +++ b/README.md @@ -1,54 +1,65 @@ # Package and push files to remote repositories -Robo task to push git artefact to remote repository +Robo task to push git artifact to remote repository -[![CircleCI](https://circleci.com/gh/integratedexperts/robo-git-artefact.svg?style=shield&circle-token=04cc2cab69b05f60a48e474f966a5bce8a71b1aa)](https://circleci.com/gh/integratedexperts/robo-git-artefact) -[![Latest Stable Version](https://poser.pugx.org/integratedexperts/robo-git-artefact/version)](https://packagist.org/packages/integratedexperts/robo-git-artefact) -[![Total Downloads](https://poser.pugx.org/integratedexperts/robo-git-artefact/downloads)](https://packagist.org/packages/integratedexperts/robo-git-artefact) -[![License](https://poser.pugx.org/integratedexperts/robo-git-artefact/license)](https://packagist.org/packages/integratedexperts/robo-git-artefact) +[![CircleCI](https://circleci.com/gh/drevops/git-artifact.svg?style=shield&circle-token=04cc2cab69b05f60a48e474f966a5bce8a71b1aa)](https://circleci.com/gh/drevops/git-artifact) +[![Latest Stable Version](https://poser.pugx.org/drevops/git-artifact/version)](https://packagist.org/packages/drevops/git-artifact) +[![Total Downloads](https://poser.pugx.org/drevops/git-artifact/downloads)](https://packagist.org/packages/drevops/git-artifact) +[![License](https://poser.pugx.org/drevops/git-artifact/license)](https://packagist.org/packages/drevops/git-artifact) ## What is it? Build artifact from your codebase in CI and push it to a separate git repo. ## Why? -Some hosting providers, like Acquia, have limitation on the languages or frameworks required to build applications (for example, running `composer install` is not possible due to read-only file system). This means that a website has to be developed in a different (source) repository, built as artefact locally or in CI, and sent to the hosting provider's version control system (destination repository). +Some hosting providers, like Acquia, have limitation on the languages or +frameworks required to build applications (for example, running +`composer install` is not possible due to read-only file system). This means +that a website has to be developed in a different (source) repository, built as +artifact locally or in CI, and sent to the hosting provider's version control +system (destination repository). -This package allows to do so in a transaparent way: files that needs to be present in the destination repository are controlled by a `.gitignore.deployment` file; any files that are ignored by this file will not be present in the destination repository. +This package allows doing so in a transparent way: files that need to be present +in the destination repository are controlled by a `.gitignore.deployment` file; +any files that are ignored by this file will not be present in the destination +repository. -Since destination repository requires a commit to add changes introduced by the artefact files (CSS, JS, etc.), there are 2 modes to make this commit: "force-push" and "branch". +Since destination repository requires a commit to add changes introduced by the +artifact files (CSS, JS, etc.), there are 2 modes to make this commit: +"force-push" and "branch". -See example of deployed artefact in [Artefact branches](https://github.com/integratedexperts/robo-git-artefact-destination/branches). +See example of deployed artifact in [Artefact branches](https://github.com/drevops/git-artifact-destination/branches). ## Modes ### Force-push mode (default) -Push packaged artefact to the same branch, preserving the history from the source repository, but overwriting history in destination repository on each push. +Push packaged artifact to the same branch, preserving the history from the +source repository, but overwriting history in destination repository on each +push. -``` ---mode=force-push -``` + --mode=force-push ![diagram of force-push mode](https://user-images.githubusercontent.com/378794/33816665-a7b0e4a8-de8e-11e7-88f2-80baefb3d73f.png) ### Branch mode -Push packaged artefact to the new branch on each deployment, preserving history from the source repository, but requiring to trigger a deployment of newly created branch after each deployment. +Push packaged artifact to the new branch on each deployment, preserving history +from the source repository, but requiring to trigger a deployment of newly +created branch after each deployment. -``` ---mode=branch -``` + --mode=branch ![diagram of branch mode](https://user-images.githubusercontent.com/378794/33816666-a87b3910-de8e-11e7-82cd-51e007ece063.png) ## Installation -``` -composer require --dev -n --ansi --prefer-source --ignore-platform-reqs integratedexperts/robo-git-artefact -``` + + composer require --dev -n --ansi --prefer-source --ignore-platform-reqs drevops/git-artifact + ## Usage -Use provided [`RoboFile.php`](RoboFile.php) or crearte a custom `RoboFile.php` in your repository with the following content: +Use provided [`RoboFile.php`](RoboFile.php) or crearte a custom `RoboFile.php` +in your repository with the following content: ```php __artefactConstruct(); + $this->__artifactConstruct(); } } ``` ### Run -``` -vendor/bin/robo artefact git@myserver.com/repository.git -``` -This will create an artefact from current directory and will send it to the specified remote repository into the same branch as a current one. + + vendor/bin/robo artifact git@myserver.com/repository.git + +This will create an artifact from current directory and will send it to the +specified remote repository into the same branch as a current one. ### Run in CI Fill-in these variables trough UI or in deployment script. -``` -# Remote repository to push artefact to. -DEPLOY_REMOTE="${DEPLOY_REMOTE:-}" -# Remote repository branch. Can be a specific branch or a token. -DEPLOY_BRANCH="${DEPLOY_BRANCH:-[branch]}" -# Source of the code to be used for artefact building. -DEPLOY_SRC="${DEPLOY_SRC:-}" -# The root directory where the deployment script should run from. Defaults to -# the current directory. -DEPLOY_ROOT="${DEPLOY_ROOT:-$(pwd)}" -# Deployment report file name. -DEPLOY_REPORT="${DEPLOY_REPORT:-${DEPLOY_ROOT}/deployment_report.txt}" -# Email address of the user who will be committing to a remote repository. -DEPLOY_USER_NAME="${DEPLOY_USER_NAME:-"Deployer Robot"}" -# Name of the user who will be committing to a remote repository. -DEPLOY_USER_EMAIL="${DEPLOY_USER_EMAIL:-deployer@example.com}" -``` + + # Remote repository to push artifact to. + DEPLOY_REMOTE="${DEPLOY_REMOTE:-}" + # Remote repository branch. Can be a specific branch or a token. + DEPLOY_BRANCH="${DEPLOY_BRANCH:-[branch]}" + # Source of the code to be used for artifact building. + DEPLOY_SRC="${DEPLOY_SRC:-}" + # The root directory where the deployment script should run from. Defaults to + # the current directory. + DEPLOY_ROOT="${DEPLOY_ROOT:-$(pwd)}" + # Deployment report file name. + DEPLOY_REPORT="${DEPLOY_REPORT:-${DEPLOY_ROOT}/deployment_report.txt}" + # Email address of the user who will be committing to a remote repository. + DEPLOY_USER_NAME="${DEPLOY_USER_NAME:-"Deployer Robot"}" + # Name of the user who will be committing to a remote repository. + DEPLOY_USER_EMAIL="${DEPLOY_USER_EMAIL:-deployer@example.com}" Call from CI configuration or deployment script: -``` -"${HOME}/.composer/vendor/bin/robo" --ansi \ - --load-from "${HOME}/.composer/vendor/integratedexperts/robo-git-artefact/RoboFile.php" artefact "${DEPLOY_REMOTE}" \ - --root="${DEPLOY_ROOT}" \ - --src="${DEPLOY_SRC}" \ - --branch="${DEPLOY_BRANCH}" \ - --gitignore="${DEPLOY_SRC}"/.gitignore.deployment \ - --report="${DEPLOY_REPORT}" \ - --push -``` - -See extended and fully-configured example in Drupal-Dev project https://github.com/integratedexperts/drupal-dev/blob/8.x/scripts/deploy.sh + + "${HOME}/.composer/vendor/bin/robo" --ansi \ + --load-from "${HOME}/.composer/vendor/drevops/git-artifact/RoboFile.php" artifact "${DEPLOY_REMOTE}" \ + --root="${DEPLOY_ROOT}" \ + --src="${DEPLOY_SRC}" \ + --branch="${DEPLOY_BRANCH}" \ + --gitignore="${DEPLOY_SRC}"/.gitignore.deployment \ + --report="${DEPLOY_REPORT}" \ + --push + +See extended and fully-configured [example in the DrevOps project](https://github.com/drevops/drevops/blob/9.x/scripts/drevops/deploy-code.sh). ## Options -``` -Usage: - artefact [options] [--] - -Arguments: - remote Path to the remote git repository. - -Options: - --branch[=BRANCH] Destination branch with optional tokens. [default: "[branch]"] - --gitignore=GITIGNORE Path to gitignore file to replace current .gitignore. - --message[=MESSAGE] Commit message with optional tokens. [default: "Deployment commit"] - --mode[=MODE] Mode of artefact build: branch, force-push or diff. Defaults to force-push. [default: "force-push"] - --now=NOW Internal value used to set internal time. - --push Push artefact to the remote repository. Defaults to FALSE. - --report=REPORT Path to the report file. - --root=ROOT Path to the root for file path resolution. If not specified, current directory is used. - --show-changes Show changes made to the repo by the build in the output. - --src=SRC Directory where source repository is located. If not specified, root directory is used. - -h, --help Display this help message - -q, --quiet Do not output any message - -V, --version Display this application version - --ansi Force ANSI output - --no-ansi Disable ANSI output - -n, --no-interaction Do not ask any interactive question - --simulate Run in simulated mode (show what would have happened). - --progress-delay=PROGRESS-DELAY Number of seconds before progress bar is displayed in long-running task collections. Default: 2s. [default: 2] - -D, --define=DEFINE Define a configuration item value. (multiple values allowed) - -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug - -Help: - Push artefact of current repository to remote git repository. -``` + + Usage: + artifact [options] [--] + + Arguments: + remote Path to the remote git repository. + + Options: + --branch[=BRANCH] Destination branch with optional tokens. [default: "[branch]"] + --gitignore=GITIGNORE Path to gitignore file to replace current .gitignore. + --message[=MESSAGE] Commit message with optional tokens. [default: "Deployment commit"] + --mode[=MODE] Mode of artifact build: branch, force-push or diff. Defaults to force-push. [default: "force-push"] + --no-cleanup Do not cleanup after run. + --now=NOW Internal value used to set internal time. + --push Push artifact to the remote repository. Defaults to FALSE. + --report=REPORT Path to the report file. + --root=ROOT Path to the root for file path resolution. If not specified, current directory is used. + --show-changes Show changes made to the repo by the build in the output. + --src=SRC Directory where source repository is located. If not specified, root directory is used. + -h, --help Display this help message + -q, --quiet Do not output any message + -V, --version Display this application version + --ansi Force ANSI output + --no-ansi Disable ANSI output + -n, --no-interaction Do not ask any interactive question + --simulate Run in simulated mode (show what would have happened). + --progress-delay=PROGRESS-DELAY Number of seconds before progress bar is displayed in long-running task collections. Default: 2s. [default: 2] + -D, --define=DEFINE Define a configuration item value. (multiple values allowed) + -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug + + Help: + Push artifact of current repository to remote git repository. + ### Adding dependencies -`--gitignore` option allows to specify the path to the _artefact gitignore_ file that replaces existing _.gitignore_ (if any) during the build. Any files no longer ignored by the replaced _artefact gitignore_ are added into the _deployment commit_. If there are no no-longer-excluded files, the _deployment commit_ is still created, to make sure that the deployment timestamp is captured. +`--gitignore` option allows to specify the path to the _artifact gitignore_ file that replaces existing _.gitignore_ (if any) during the build. Any files no longer ignored by the replaced _artifact gitignore_ are added into the _deployment commit_. If there are no no-longer-excluded files, the _deployment commit_ is still created, to make sure that the deployment timestamp is captured. ### Token support Both `--branch` and `--message` option values support token replacement. Tokens are pre-defined strings surrounded by `[` and `]` and may contain optional formatter (for flexibility). For example, `[timestamp:Y-m-d]` is replaced with current timestamp in format `Y-m-d` (token formatter), which is PHP `date()` expected format. @@ -155,17 +166,17 @@ Available tokens: ## Examples ### Push branch to the same remote -``` -robo artefact git@myserver.com/repository.git --push -``` + + robo artifact git@myserver.com/repository.git --push + In this example, all commits in the repository will be pushed to the same branch as current one with all processed files (assets etc.) captured in the additional deployment commit. `--push` flag enables actual pushing into remote repository. ### Push release branches created from tags -``` -robo artefact git@myserver.com/repository.git --mode=branch --branch=release/[tags:-] --push -``` -In this example, if the latest commit was tagged with tag `1.2.0`, the artefact will be pushed to the branch `release/1.2.0`. If there latest commit is tagged with multiple tags - they will be glued to gether with delimiter `-`, which would reult in the branch name `release/1.2.0-secondtag`. + + robo artifact git@myserver.com/repository.git --mode=branch --branch=release/[tags:-] --push + +In this example, if the latest commit was tagged with tag `1.2.0`, the artifact will be pushed to the branch `release/1.2.0`. If there latest commit is tagged with multiple tags - they will be glued to gether with delimiter `-`, which would reult in the branch name `release/1.2.0-secondtag`. ## Contributing 1. Fork this repo. diff --git a/RoboFile.php b/RoboFile.php index 11c6429..ac3f643 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -5,7 +5,7 @@ * @see http://robo.li/ */ -use IntegratedExperts\Robo\ArtefactTrait; +use DrevOps\Robo\ArtefactTrait; /** * Class RoboFile. @@ -14,11 +14,11 @@ class RoboFile extends \Robo\Tasks { use ArtefactTrait { - ArtefactTrait::__construct as private __artefactConstruct; + ArtefactTrait::__construct as private __artifactConstruct; } public function __construct() { - $this->__artefactConstruct(); + $this->__artifactConstruct(); } } diff --git a/composer.json b/composer.json index f1d37c9..51717c6 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { - "name": "integratedexperts/robo-git-artefact", - "description": "Robo task to push git artefact to remote repository", + "name": "drevops/git-artifact", + "description": "Build artifact from your codebase in CI and push it to a separate git repo.", "type": "robo-tasks", "license": "GPL-2.0-or-later", "authors": [ @@ -28,12 +28,12 @@ }, "autoload": { "psr-4": { - "IntegratedExperts\\Robo\\": "src" + "DrevOps\\Robo\\": "src" } }, "autoload-dev": { "psr-4": { - "IntegratedExperts\\Robo\\Tests\\": "tests" + "DrevOps\\Robo\\Tests\\": "tests" } }, "config": { diff --git a/phpcs.xml b/phpcs.xml index 46b8711..85cc0b9 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,6 +1,6 @@ - - The coding standard for behat-relativity. + + Custom coding standard. diff --git a/phpunit.xml b/phpunit.xml index a424df2..d83dfe1 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,7 +1,7 @@ - + ./tests/ diff --git a/src/ArtefactTrait.php b/src/ArtefactTrait.php index 8b4b117..362236d 100644 --- a/src/ArtefactTrait.php +++ b/src/ArtefactTrait.php @@ -1,6 +1,6 @@ __artefactFsConstruct(); + $this->__artifactFsConstruct(); } /** - * Push artefact of current repository to remote git repository. + * Push artifact of current repository to remote git repository. * * @param string $remote * Path to the remote git repository. @@ -143,11 +143,11 @@ public function __construct() * @option $debug Print debug information. * @option $gitignore Path to gitignore file to replace current .gitignore. * @option $message Commit message with optional tokens. - * @option $mode Mode of artefact build: branch, force-push or diff. + * @option $mode Mode of artifact build: branch, force-push or diff. * Defaults to force-push. * @option $now Internal value used to set internal time. * @option $no-cleanup Do not cleanup after run. - * @option $push Push artefact to the remote repository. Defaults to FALSE. + * @option $push Push artifact to the remote repository. Defaults to FALSE. * @option $report Path to the report file. * @option $root Path to the root for file path resolution. If not * specified, current directory is used. @@ -156,7 +156,7 @@ public function __construct() * @option $src Directory where source repository is located. If not * specified, root directory is used. */ - public function artefact($remote, array $opts = [ + public function artifact($remote, array $opts = [ 'branch' => '[branch]', 'debug' => false, 'gitignore' => InputOption::VALUE_REQUIRED, @@ -212,11 +212,11 @@ public function artefact($remote, array $opts = [ } /** - * Prepare artefact to be then deployed. + * Prepare artifact to be then deployed. */ protected function prepareArtefact(): void { - $this->gitSwitchToBranch($this->src, $this->artefactBranch, true); + $this->gitSwitchToBranch($this->src, $this->artifactBranch, true); $this->removeSubRepos($this->src); $this->disableLocalExclude($this->src); @@ -245,7 +245,7 @@ protected function cleanup(): void { $this->restoreLocalExclude($this->src); $this->gitSwitchToBranch($this->src, $this->originalBranch); - $this->gitRemoveBranch($this->src, $this->artefactBranch); + $this->gitRemoveBranch($this->src, $this->artifactBranch); $this->gitRemoveRemote($this->src, $this->remoteName); } @@ -259,7 +259,7 @@ protected function doPush(): void } try { - $result = $this->gitPush($this->src, $this->artefactBranch, $this->remoteName, $this->dstBranch, $this->mode === self::modeForcePush()); + $result = $this->gitPush($this->src, $this->artifactBranch, $this->remoteName, $this->dstBranch, $this->mode === self::modeForcePush()); $this->result = $result->wasSuccessful(); } catch (\Exception $exception) { // Re-throw the message with additional context. @@ -297,7 +297,7 @@ protected function resolveOptions(array $options): void $this->originalBranch = $this->resolveOriginalBranch($this->src); $this->setDstBranch($options['branch']); - $this->artefactBranch = $this->dstBranch.'-artefact'; + $this->artifactBranch = $this->dstBranch.'-artifact'; $this->setMessage($options['message']); @@ -317,7 +317,7 @@ protected function resolveOptions(array $options): void } /** - * Show artefact build information. + * Show artifact build information. */ protected function showInfo(): void { @@ -335,7 +335,7 @@ protected function showInfo(): void } /** - * Dump artefact report to a file. + * Dump artifact report to a file. */ protected function dumpReport(): void { diff --git a/src/FilesystemTrait.php b/src/FilesystemTrait.php index 0bc83c3..0a806fc 100644 --- a/src/FilesystemTrait.php +++ b/src/FilesystemTrait.php @@ -1,6 +1,6 @@ fs = new Filesystem(); - $this->fixtureDir = sys_get_temp_dir().DIRECTORY_SEPARATOR.'robo_git_artefact'; + $this->fixtureDir = sys_get_temp_dir().DIRECTORY_SEPARATOR.'robo_git_artifact'; $this->fs->mkdir($this->fixtureDir); $this->commandTraitSetUp( diff --git a/tests/CommandTrait.php b/tests/CommandTrait.php index 1473b90..8e8bab2 100644 --- a/tests/CommandTrait.php +++ b/tests/CommandTrait.php @@ -1,6 +1,6 @@ now = time(); $this->currentBranch = 'master'; - $this->artefactBranch = 'master-artefact'; + $this->artifactBranch = 'master-artifact'; $this->remote = 'dst'; } /** - * Build the artefact and assert success. + * Build the artifact and assert success. * * @param string $args * Optional string of arguments to pass to the build. @@ -87,7 +87,7 @@ protected function assertBuildSuccess($args = '', $branch = 'testbranch', $commi } /** - * Build the artefact and assert failure. + * Build the artifact and assert failure. * * @param string $args * Optional string of arguments to pass to the build. @@ -111,7 +111,7 @@ protected function assertBuildFailure($args = '', $branch = 'testbranch', $commi } /** - * Run artefact build. + * Run artifact build. * * @param string $args * Additional arguments or options as a string. @@ -125,7 +125,7 @@ protected function runBuild($args = '', $expectFail = false) $args .= ' --mode='.$this->mode; } - $output = $this->runRoboCommandTimestamped(sprintf('artefact --src=%s %s %s', $this->src, $this->dst, $args), $expectFail); + $output = $this->runRoboCommandTimestamped(sprintf('artifact --src=%s %s %s', $this->src, $this->dst, $args), $expectFail); if ($this->isDebug()) { print str_pad('', 80, '+').PHP_EOL; @@ -137,7 +137,7 @@ protected function runBuild($args = '', $expectFail = false) } /** - * Run Robo command with current timestamp attached to artefact commands. + * Run Robo command with current timestamp attached to artifact commands. * * @param string $command * Command string to run. @@ -149,8 +149,8 @@ protected function runBuild($args = '', $expectFail = false) */ protected function runRoboCommandTimestamped($command, $expectFail = false) { - // Add --now option to all 'artefact' commands. - if (strpos($command, 'artefact') === 0) { + // Add --now option to all 'artifact' commands. + if (strpos($command, 'artifact') === 0) { $command .= ' --now='.$this->now; } diff --git a/tests/Integration/BranchTest.php b/tests/Integration/BranchTest.php index f8d6f36..03cbf78 100644 --- a/tests/Integration/BranchTest.php +++ b/tests/Integration/BranchTest.php @@ -1,6 +1,6 @@ gitCreateFixtureCommits(3, 2); $this->assertBuildFailure(); - // Make sure that broken artefact was not pushed. + // Make sure that broken artifact was not pushed. $this->assertFixtureCommits(2, $this->dst, 'testbranch', ['Deployment commit']); } diff --git a/tests/Integration/ForcePushTest.php b/tests/Integration/ForcePushTest.php index da58a18..1676da1 100644 --- a/tests/Integration/ForcePushTest.php +++ b/tests/Integration/ForcePushTest.php @@ -1,6 +1,6 @@ runRoboCommand('list'); - $this->assertStringContainsString('artefact', implode(PHP_EOL, $output)); + $this->assertStringContainsString('artifact', implode(PHP_EOL, $output)); } public function testHelp() { - $output = $this->runRoboCommand('--help artefact'); - $this->assertStringContainsString('artefact [options] [--] ', implode(PHP_EOL, $output)); + $output = $this->runRoboCommand('--help artifact'); + $this->assertStringContainsString('artifact [options] [--] ', implode(PHP_EOL, $output)); } public function testCompulsoryParameter() { - $output = $this->runRoboCommand('artefact', true); + $output = $this->runRoboCommand('artifact', true); $this->assertStringContainsString('Not enough arguments (missing: "remote")', implode(PHP_EOL, $output)); } @@ -64,7 +64,7 @@ public function testNoCleanup() $this->gitCreateFixtureCommits(1); $output = $this->runBuild('--no-cleanup'); - $this->assertGitCurrentBranch($this->src, $this->artefactBranch); + $this->assertGitCurrentBranch($this->src, $this->artifactBranch); $this->assertStringContainsString('Cowardly refusing to push to remote. Use --push option to perform an actual push.', $output); $this->gitAssertFilesNotExist($this->dst, 'f1', $this->currentBranch); diff --git a/tests/Integration/TagTest.php b/tests/Integration/TagTest.php index e0217aa..676d31e 100644 --- a/tests/Integration/TagTest.php +++ b/tests/Integration/TagTest.php @@ -1,6 +1,6 @@ prepareMock('IntegratedExperts\Robo\TokenTrait', [ + $mock = $this->prepareMock('DrevOps\Robo\TokenTrait', [ 'getToken'.ucfirst($name) => function ($prop) use ($replacement) { return !empty($prop) ? $replacement.' with property '.$prop : $replacement; }, @@ -98,7 +98,7 @@ public function dataProviderTokenProcess() */ public function testHasToken($string, $hasToken) { - $mock = $this->prepareMock('IntegratedExperts\Robo\TokenTrait'); + $mock = $this->prepareMock('DrevOps\Robo\TokenTrait'); $actual = $this->callProtectedMethod($mock, 'hasToken', [$string]); $this->assertEquals($hasToken, $actual); diff --git a/tests/Unit/AbstractUnitTest.php b/tests/Unit/AbstractUnitTest.php index 7f85b1c..07b7e79 100644 --- a/tests/Unit/AbstractUnitTest.php +++ b/tests/Unit/AbstractUnitTest.php @@ -1,8 +1,8 @@ mock = $this->getMockForTrait('IntegratedExperts\Robo\ArtefactTrait'); + $this->mock = $this->getMockForTrait('DrevOps\Robo\ArtefactTrait'); $this->callProtectedMethod($this->mock, 'fsSetRootDir', [$this->fixtureDir]); } } diff --git a/tests/Unit/ExcludeTest.php b/tests/Unit/ExcludeTest.php index 49a0576..c176a8a 100644 --- a/tests/Unit/ExcludeTest.php +++ b/tests/Unit/ExcludeTest.php @@ -1,6 +1,6 @@