From 44d0ef21d027db266f94b08052dcc1e257ef9f88 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Wed, 8 Jan 2020 18:14:28 +0100 Subject: [PATCH] clean: Move build to CircleCI --- .circleci/config.yml | 85 ++++++++++++++++++++++++++ .travis.yml | 17 ------ box.json | 9 --- circle.yml | 26 -------- composer.json | 12 +++- src/Codacy/Coverage/Command/Clover.php | 4 +- 6 files changed, 97 insertions(+), 56 deletions(-) create mode 100644 .circleci/config.yml delete mode 100644 .travis.yml delete mode 100644 box.json delete mode 100644 circle.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..c4cc0e7 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,85 @@ +version: 2.1 + +orbs: + codacy: codacy/base@1.2.1 + +references: + default_php_job: &default_php_job + docker: + - image: circleci/php:7.4-node-browsers + working_directory: ~/workdir + workspace_attach: &workspace_attach + attach_workspace: + at: ~/ + workspace_persist: &workspace_persist + persist_to_workspace: + paths: + - workdir/* + root: ~/ + cache_restore: &cache_restore + restore_cache: + keys: + - composer-v1-{{ checksum "composer.lock" }} + - composer-v1- + cache_save: &cache_save + save_cache: + key: composer-v1-{{ checksum "composer.lock" }} + paths: + - vendor + +jobs: + test: + <<: *default_php_job + steps: + - *workspace_attach + - *cache_restore + - run: + command: composer install + - *cache_save + - run: + command: composer test + - *workspace_persist + publish: + <<: *default_php_job + steps: + - *workspace_attach + - run: + command: | + composer codacyCoverage + composer build + - *workspace_persist + publish_circleci_artifacts: + machine: true + working_directory: ~/workdir + steps: + - *workspace_attach + - store_artifacts: + path: ~/workdir/artifacts/ + +workflows: + version: 2 + compile_test_deploy: + jobs: + - codacy/checkout_and_version + - test: + requires: + - codacy/checkout_and_version + - publish: + requires: + - test + filters: + branches: + only: + - master + - publish_circleci_artifacts: + requires: + - publish + - codacy/publish_ghr: + path: ~/workdir/artifacts/ + requires: + - publish_circleci_artifacts + - codacy/tag_version: + name: tag_version + context: CodacyAWS + requires: + - codacy/publish_ghr diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c9e189e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: php - -php: - - '7.2' - - '7.3' - - '7.4' - -before_script: -# In case of timeouts and build failures you may want to prepend 'travis_retry' to the following commands: - - composer install -n - -# Explicitly use the phpunit from composer, not any system-wide found -script: - - php vendor/bin/phpunit --coverage-clover build/coverage/xml tests - -after_success: - - php vendor/bin/codacycoverage clover build/coverage/xml diff --git a/box.json b/box.json deleted file mode 100644 index c3c06a6..0000000 --- a/box.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "directories": [ - "src", - "vendor" - ], - "main": "bin/codacycoverage", - "output": "build/codacy-coverage.phar", - "stub": true -} diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 7eff31e..0000000 --- a/circle.yml +++ /dev/null @@ -1,26 +0,0 @@ -machine: - php: - version: 7.1.6 - -dependencies: - pre: - - curl -s http://getcomposer.org/installer | php - - php composer.phar install -n - - go get github.com/aktau/github-release - - wget -O box.phar https://github.com/box-project/box2/releases/download/2.7.5/box-2.7.5.phar - -test: - post: - - php vendor/bin/phpunit --coverage-clover build/coverage/xml tests - -deployment: - master: - branch: master - commands: - - php bin/codacycoverage clover build/coverage/xml - release: - tag: /[0-9]+(\.[0-9]+)*/ - commands: - - php -d phar.readonly=0 box.phar build - - git config user.name $CIRCLE_PROJECT_USERNAME - - github-release upload --user $CIRCLE_PROJECT_USERNAME --repo $CIRCLE_PROJECT_REPONAME --tag $CIRCLE_TAG --name codacy-coverage.phar --file build/codacy-coverage.phar diff --git a/composer.json b/composer.json index fcc7e7d..1093aa3 100644 --- a/composer.json +++ b/composer.json @@ -9,9 +9,17 @@ "symfony/console": "~2.5|~3.0|~4.0|~5.0" }, "require-dev": { - "phpunit/phpunit": "~6.5" + "phpunit/phpunit": "~6.5", + "clue/phar-composer": "^1.1" }, - "bin": ["bin/codacycoverage"], + "scripts": { + "test": "php vendor/bin/phpunit --coverage-clover build/coverage/xml tests", + "codacyCoverage": "php bin/codacycoverage clover build/coverage/xml", + "build": "mkdir -p artifacts && php -d phar.readonly=off ./vendor/bin/phar-composer build . artifacts/codacy-coverage.phar" + }, + "bin": [ + "bin/codacycoverage" + ], "autoload": { "classmap": [ "src/" diff --git a/src/Codacy/Coverage/Command/Clover.php b/src/Codacy/Coverage/Command/Clover.php index b17ee9d..844da33 100644 --- a/src/Codacy/Coverage/Command/Clover.php +++ b/src/Codacy/Coverage/Command/Clover.php @@ -70,7 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($output->isVerbose()) { $output->writeln($result); } - + return 0; } @@ -102,7 +102,7 @@ protected function getProjectToken() if ($projectToken == false) { throw new \InvalidArgumentException( "Cannot continue with execution as long as your project token is not set as an environmental variable." - . PHP_EOL . "Please type: export CODACY_PROJECT_TOKEN=" + . PHP_EOL . "Please type: export CODACY_PROJECT_TOKEN=" ); }