From 40c01ad1d43a2b9f5ca561b433418141123f77af Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Mon, 23 Nov 2020 22:39:32 +0100 Subject: [PATCH] Ditch Travis to use GitHub Actions --- .editorconfig | 3 + .github/workflows/assets.yml | 32 +++++++ .github/workflows/coding-standards.yml | 55 ++++++++++++ .github/workflows/continuous-integration.yml | 91 ++++++++++++++++++++ .github/workflows/translations.yml | 57 ++++++++++++ .travis.yml | 74 ---------------- README.md | 2 +- app/config/tests/parameters_test.mysql.yml | 2 +- app/config/tests/parameters_test.pgsql.yml | 4 +- 9 files changed, 242 insertions(+), 78 deletions(-) create mode 100644 .github/workflows/assets.yml create mode 100644 .github/workflows/coding-standards.yml create mode 100644 .github/workflows/continuous-integration.yml create mode 100644 .github/workflows/translations.yml delete mode 100644 .travis.yml diff --git a/.editorconfig b/.editorconfig index 140440443..4a54f7726 100644 --- a/.editorconfig +++ b/.editorconfig @@ -15,3 +15,6 @@ indent_size = 2 [*akefile] indent_style = tab + +[.github/**.yml] +indent_size = 2 diff --git a/.github/workflows/assets.yml b/.github/workflows/assets.yml new file mode 100644 index 000000000..f52251f93 --- /dev/null +++ b/.github/workflows/assets.yml @@ -0,0 +1,32 @@ +name: "Assets" + +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + js: + name: "Building assets" + runs-on: "ubuntu-20.04" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Install Node" + uses: actions/setup-node@v1 + with: + node-version: "12" + + - name: "Install dependencies with Yarn" + run: "yarn install" + + - name: "Build dev assets" + run: "yarn run build:dev" + + - name: "Build prod assets" + run: "yarn run build:prod" diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml new file mode 100644 index 000000000..9fca3b75f --- /dev/null +++ b/.github/workflows/coding-standards.yml @@ -0,0 +1,55 @@ +name: "CS" + +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + coding-standards: + name: "CS Fixer & PHPStan" + runs-on: "ubuntu-16.04" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + php-version: "7.3" + tools: cs2pr, pecl, composer:v1 + extensions: pdo, pdo_mysql, pdo_sqlite, pdo_pgsql, curl, imagick, pgsql, gd, tidy + ini-values: "date.timezone=Europe/Paris" + env: + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v2" + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: "php-${{ matrix.php }}-composer-locked-${{ hashFiles('composer.lock') }}" + restore-keys: "php-${{ matrix.php }}-composer-locked-" + + - name: "Install dependencies with Composer" + run: "composer install --no-interaction --optimize-autoloader --no-progress --prefer-dist" + + - name: "Run PHP CS Fixer" + run: "bin/php-cs-fixer fix --verbose --dry-run --format=checkstyle | cs2pr" + + - name: "Generate test cache for PHPStan" + run: "php bin/console cache:clear --env=test" + + - name: "Install PHPUnit for PHPStan" + run: "php bin/simple-phpunit install" + + - name: "Run PHPStan" + run: "php bin/phpstan analyse --no-progress --error-format=checkstyle | cs2pr" diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 000000000..64ed19eae --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,91 @@ +name: "CI" + +on: + pull_request: + branches: + - "master" + push: + branches: + - "master" + +env: + PGPASSWORD: wallabagrocks + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + phpunit: + name: "PHP ${{ matrix.php }} using ${{ matrix.database }}" + runs-on: "ubuntu-16.04" + services: + rabbitmq: + image: rabbitmq:3-alpine + ports: + - 5672:5672 + redis: + image: redis:6-alpine + ports: + - 6379:6379 + + strategy: + fail-fast: false + matrix: + php: + - "7.2" + - "7.3" + - "7.4" + database: + - "sqlite" + - "mysql" + - "pgsql" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + with: + fetch-depth: 2 + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php }}" + coverage: none + tools: pecl, composer:v1 + extensions: json, pdo, pdo_mysql, pdo_sqlite, pdo_pgsql, curl, imagick, pgsql, gd, tidy + ini-values: "date.timezone=Europe/Paris" + + - name: "Setup MySQL" + if: "${{ matrix.database == 'mysql' }}" + run: | + sudo systemctl start mysql.service + sudo mysql -u root -proot -e "CREATE DATABASE wallabag_test" + + - name: "Setup PostgreSQL" + if: "${{ matrix.database == 'pgsql' }}" + run: | + sudo systemctl start postgresql + sudo -u postgres psql -d template1 -c "CREATE USER wallabag WITH PASSWORD 'wallabagrocks' CREATEDB" + createdb -h localhost -p 5432 -U wallabag wallabag_test + pg_isready -d wallabag_test -h localhost -p 5432 -U wallabag + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v2" + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: "php-${{ matrix.php }}-composer-locked-${{ hashFiles('composer.lock') }}" + restore-keys: "php-${{ matrix.php }}-composer-locked-" + + - name: "Install dependencies with composer" + run: "composer install --no-interaction --optimize-autoloader --no-progress --prefer-dist" + + - name: "Prepare database" + run: "make prepare DB=${{ matrix.database }}" + + - name: "Prepare fixtures" + run: "make fixtures" + + - name: "Run PHPUnit" + run: "php bin/simple-phpunit -v" diff --git a/.github/workflows/translations.yml b/.github/workflows/translations.yml new file mode 100644 index 000000000..cf8752529 --- /dev/null +++ b/.github/workflows/translations.yml @@ -0,0 +1,57 @@ +name: "Translations" + +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + translations: + name: "Translations" + runs-on: "ubuntu-16.04" + + strategy: + matrix: + php: + - "7.3" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + php-version: "${{ matrix.php }}" + tools: pecl, composer:v1 + extensions: pdo, pdo_mysql, pdo_sqlite, pdo_pgsql, curl, imagick, pgsql, gd, tidy + ini-values: "date.timezone=Europe/Paris" + env: + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v2" + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: "php-${{ matrix.php }}-composer-locked-${{ hashFiles('composer.lock') }}" + restore-keys: "php-${{ matrix.php }}-composer-locked-" + + - name: "Install dependencies with Composer" + run: "composer install --no-interaction --optimize-autoloader --no-progress --prefer-dist" + + - name: "Validate Core translations" + run: "php bin/console lint:yaml src/Wallabag/CoreBundle/Resources/translations -v" + + - name: "Validate CraueConfig translations" + run: "php bin/console lint:yaml app/Resources/CraueConfigBundle/translations -v" + + - name: "Validate User translations" + run: "php bin/console lint:yaml src/Wallabag/UserBundle/Resources/translations -v" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 043189410..000000000 --- a/.travis.yml +++ /dev/null @@ -1,74 +0,0 @@ -os: linux -dist: xenial -language: php - -services: - - mysql - - postgresql - - rabbitmq - - redis - -# cache vendor dirs -cache: - apt: true - directories: - - $HOME/.composer/cache/files - - node_modules - - $HOME/.npm - - $HOME/.yarn-cache - -if: | - type = pull_request OR \ - branch = master - -php: - - 7.2 - - 7.3 - - 7.4 - -env: - - DB=mysql - - DB=pgsql - - DB=sqlite - -jobs: - fast_finish: true - include: - - php: 7.3 - env: CS_FIXER=run VALIDATE_TRANSLATION_FILE=run ASSETS=build DB=sqlite - -# exclude v1 branches -branches: - except: - - legacy - -before_install: - - if [[ $TRAVIS_REPO_SLUG = wallabag/wallabag ]]; then cp .composer-auth.json ~/.composer/auth.json; fi; - - PHP=$TRAVIS_PHP_VERSION - - echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - - phpenv config-rm xdebug.ini || echo "xdebug not available" - # install imagick - - pear config-set preferred_state beta - - pecl channel-update pecl.php.net - - yes | pecl install imagick - -install: - - if [[ $ASSETS = build ]]; then source ~/.nvm/nvm.sh && nvm install 12; fi; - - if [[ $ASSETS = build ]]; then npm install -g yarn@latest; fi; - - if [[ $ASSETS = build ]]; then yarn install; fi; - - composer install -o --no-interaction --no-progress --prefer-dist --no-suggest - - php bin/simple-phpunit install - -before_script: - - make prepare DB=$DB - - make fixtures - -script: - - if [[ $VALIDATE_TRANSLATION_FILE = '' ]]; then ./bin/simple-phpunit -v ; fi; - # PHPStan needs PHPUnit to be installed and cache app to be generated - - if [[ $CS_FIXER = run ]]; then php bin/phpstan analyse ; fi; - - if [[ $CS_FIXER = run ]]; then php bin/php-cs-fixer fix --verbose --dry-run ; fi; - - if [[ $VALIDATE_TRANSLATION_FILE = run ]]; then php bin/console lint:yaml src/Wallabag/CoreBundle/Resources/translations -v ; fi; - - if [[ $VALIDATE_TRANSLATION_FILE = run ]]; then php bin/console lint:yaml app/Resources/CraueConfigBundle/translations -v ; fi; - - if [[ $VALIDATE_TRANSLATION_FILE = run ]]; then php bin/console lint:yaml src/Wallabag/UserBundle/Resources/translations -v ; fi; - - if [[ $ASSETS = build ]]; then yarn run build:prod; fi; diff --git a/README.md b/README.md index e9e602123..21b7e0109 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -[![Build Status](https://api.travis-ci.org/wallabag/wallabag.svg?branch=master)](https://travis-ci.org/wallabag/wallabag) +![CI](https://github.com/wallabag/wallabag/workflows/CI/badge.svg) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/wallabag/wallabag/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/wallabag/wallabag/?branch=master) [![Gitter](https://badges.gitter.im/gitterHQ/gitter.svg)](https://gitter.im/wallabag/wallabag) [![Donation Status](https://img.shields.io/liberapay/goal/wallabag.svg?logo=liberapay)](https://liberapay.com/wallabag/donate) diff --git a/app/config/tests/parameters_test.mysql.yml b/app/config/tests/parameters_test.mysql.yml index 36b227fbc..a28f4353b 100644 --- a/app/config/tests/parameters_test.mysql.yml +++ b/app/config/tests/parameters_test.mysql.yml @@ -4,7 +4,7 @@ parameters: test_database_port: 3306 test_database_name: wallabag_test test_database_user: root - test_database_password: ~ + test_database_password: root test_database_path: ~ env(TEST_DATABASE_PATH): ~ test_database_charset: utf8mb4 diff --git a/app/config/tests/parameters_test.pgsql.yml b/app/config/tests/parameters_test.pgsql.yml index 60f51df6d..2be37aa14 100644 --- a/app/config/tests/parameters_test.pgsql.yml +++ b/app/config/tests/parameters_test.pgsql.yml @@ -3,8 +3,8 @@ parameters: test_database_host: localhost test_database_port: test_database_name: wallabag_test - test_database_user: travis - test_database_password: ~ + test_database_user: wallabag + test_database_password: wallabagrocks test_database_path: ~ env(TEST_DATABASE_PATH): ~ test_database_charset: utf8