From 39ebd7943ed2ff0d9383d20b974668ab6cd95606 Mon Sep 17 00:00:00 2001 From: Tareq Ahamed Date: Fri, 28 Oct 2022 15:45:49 +0600 Subject: [PATCH] Move CI to Github actions --- .circleci/config.yml | 89 ------------------------------ .github/workflows/ci.yaml | 52 +++++++++++++++++ .github/workflows/only-master.yaml | 49 ++++++++++++++++ 3 files changed, 101 insertions(+), 89 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/only-master.yaml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index c7148a4..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,89 +0,0 @@ -version: 2.1 - -orbs: - aws-s3: circleci/aws-s3@3.0.0 # use the AWS S3 orb in your config - -jobs: - tests-php-cs: - docker: - - image: php:8.0-cli-alpine - steps: - - checkout - - run: wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.19.0/php-cs-fixer.phar - - run: php php-cs-fixer.phar fix --dry-run --diff - - tests-phpunit: - parameters: - php-version: - type: string - docker: - - image: circleci/php:<< parameters.php-version >> - steps: - - run: sudo composer self-update - - - checkout - - # Dependencies - - restore_cache: - key: v1-deps-{{ checksum "composer.json" }} - - run: composer install - - save_cache: - paths: [ ./vendor ] - key: v1-deps-{{ checksum "composer.json" }} - - # Install PHPUnit - - restore_cache: - key: v1-phpunit-{{ checksum "composer.json" }} - - run: php vendor/bin/simple-phpunit install - - save_cache: - paths: [ ./bin/.phpunit ] - key: v1-phpunit-{{ checksum "composer.json" }} - - # Run the tests - - run: php vendor/bin/simple-phpunit -v --log-junit ./phpunit/junit.xml - - store_test_results: - path: ./phpunit - - release: - docker: - - image: circleci/php:7.4 - steps: - - run: sudo composer self-update - - - checkout - - # Dependencies - - restore_cache: - key: v1-deps-{{ checksum "composer.json" }} - - run: composer install - - save_cache: - paths: [ ./vendor ] - key: v1-deps-{{ checksum "composer.json" }} - - # Build - - run: wget https://github.com/box-project/box/releases/download/3.13.0/box.phar -O /tmp/box.phar - - run: php /tmp/box.phar build - - # Test - - run: build/insight.phar list - - # Release - - aws-s3/copy: - from: build/insight.phar - to: 's3://get.insight.symfony.com/insight.phar' - arguments: '--acl public-read' - -workflows: - version: 2 - test: - jobs: - - tests-php-cs - - tests-phpunit: - matrix: - parameters: - php-version: ['7.2', '7.3', '7.4', '8.0'] - - release: - requires: [tests-phpunit] - filters: - branches: - only: ['master'] diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..1f04c9d --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,52 @@ +on: [pull_request] +name: Insight SDK + +jobs: + php-cs: + name: Coding style + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - uses: shivammathur/setup-php@v2 + with: + php-version: '7.2' + tools: php-cs-fixer:2.13.1 + coverage: none + - name: php-cs-fixer + run: php-cs-fixer fix --dry-run --diff + + tests-phpunit: + name: Unit tests + runs-on: ubuntu-latest + + strategy: + matrix: + php-version: ["7.2", "7.3", "7.4", "8.0", "8.1"] + + steps: + - uses: actions/checkout@master + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + tools: phpunit-bridge + coverage: none + + - name: Get Composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Mount PHP dependencies cache + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('console/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install dependencies + run: | + composer install --prefer-dist --no-interaction --no-ansi --no-progress + + - name: Run the tests suite + run: | + php vendor/bin/simple-phpunit -v --log-junit ./phpunit/junit.xml diff --git a/.github/workflows/only-master.yaml b/.github/workflows/only-master.yaml new file mode 100644 index 0000000..3b22dbd --- /dev/null +++ b/.github/workflows/only-master.yaml @@ -0,0 +1,49 @@ +on: + push: + branches: + - master +name: Insight SDK (release) + +jobs: + release: + name: Release + runs-on: ubuntu-latest + + env: + AWS_DEFAULT_REGION: 'eu-west-1' + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + + steps: + - uses: actions/checkout@master + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + coverage: none + + - name: Get Composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Mount PHP dependencies cache + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('console/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install dependencies + run: composer install + + - name: Build + run: | + wget https://github.com/box-project/box/releases/download/3.13.0/box.phar -O /tmp/box.phar + php /tmp/box.phar build + + - name: Test + run: build/insight.phar list + + - name: Release + run: | + aws s3 cp build/insight.phar s3://get.insight.symfony.com/insight.phar