Skip to content

build

build #1047

Workflow file for this run

name: "build"
on:
pull_request:
paths-ignore:
- "docs/**"
push:
branches:
- "main"
tags:
- v*
schedule:
- cron: "0 8 * * 1" # At 08:00 on Monday
env:
extensions: "json, intl, :php-psr"
cache-version: "1"
composer-version: "v2"
composer-options: "--no-interaction --no-progress --no-suggest --prefer-dist --prefer-stable"
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.ORGANIZATION_ACCESS_TOKEN }}"}}'
jobs:
qa:
name: "Code quality assurance"
runs-on: "${{ matrix.operating-system }}"
strategy:
fail-fast: false
matrix:
php-version: [ "8.1", "8.2" ]
node-version: [ "18" ]
operating-system: [ "ubuntu-latest" ]
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Setup PHP cache environment"
id: "extcache"
uses: "shivammathur/cache-extensions@v1"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.extensions }}"
key: "${{ env.cache-version }}"
- name: "Cache PHP extensions"
uses: "actions/cache@v3"
with:
path: "${{ steps.extcache.outputs.dir }}"
key: "${{ steps.extcache.outputs.key }}"
restore-keys: "${{ steps.extcache.outputs.key }}"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.extensions }}"
tools: "composer:${{ env.composer-version }}, cs2pr"
coverage: "none"
- name: "Setup problem matchers for PHP"
run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"'
- name: "Setup composer & install dependencies"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "highest"
composer-options: "${{ env.composer-options }}"
custom-cache-key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
- name: "Setup node"
uses: "actions/setup-node@v4"
with:
node-version: "${{ matrix.node-version }}"
- name: "Get Yarn cache directory"
id: "yarn-cache-dir-path"
run: 'echo "::set-output name=dir::$(yarn cache dir)"'
- name: "Cache JS dependencies"
uses: "actions/cache@v3"
with:
path: "${{ steps.yarn-cache-dir-path.outputs.dir }}"
key: "${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }}"
restore-keys: "${{ runner.os }}-node-modules-"
- name: "Install dependencies"
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: "yarn install"
- name: "Check Prettier with eslint"
run: "yarn pretty:check"
- name: "Coding Standard"
run: "make cs"
static-analysis:
name: "Code static analysis"
runs-on: "${{ matrix.operating-system }}"
strategy:
fail-fast: false
matrix:
php-version: [ "8.1", "8.2" ]
node-version: [ "18" ]
operating-system: [ "ubuntu-latest" ]
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Setup PHP cache environment"
id: "extcache"
uses: "shivammathur/cache-extensions@v1"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.extensions }}"
key: "${{ env.cache-version }}"
- name: "Cache PHP extensions"
uses: "actions/cache@v3"
with:
path: "${{ steps.extcache.outputs.dir }}"
key: "${{ steps.extcache.outputs.key }}"
restore-keys: "${{ steps.extcache.outputs.key }}"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.extensions }}"
tools: "composer:${{ env.composer-version }}"
coverage: "none"
- name: "Setup problem matchers for PHP"
run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"'
- name: "Setup composer & install dependencies"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "highest"
composer-options: "${{ env.composer-options }}"
custom-cache-key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
- name: "Setup node"
uses: "actions/setup-node@v4"
with:
node-version: "${{ matrix.node-version }}"
- name: "Get Yarn cache directory"
id: "yarn-cache-dir-path"
run: 'echo "::set-output name=dir::$(yarn cache dir)"'
- name: "Cache JS dependencies"
uses: "actions/cache@v3"
with:
path: "${{ steps.yarn-cache-dir-path.outputs.dir }}"
key: "${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }}"
restore-keys: "${{ runner.os }}-node-modules-"
- name: "Install dependencies"
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: "yarn install"
- name: "PHPStan"
run: "make phpstan"
- name: "Check typescript"
run: "yarn types"
tests:
name: "Code tests"
runs-on: "${{ matrix.operating-system }}"
needs: [ "qa", "static-analysis" ]
strategy:
fail-fast: false
matrix:
php-version: [ "8.1", "8.2" ]
operating-system: [ "ubuntu-latest" ]
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name : "Setup MySQL"
uses : "mirromutth/mysql-action@v1.1"
with :
mysql version : "5.7"
mysql database : "testdb"
mysql root password : "root"
- name: "Setup PHP cache environment"
id: "extcache"
uses: "shivammathur/cache-extensions@v1"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.extensions }}"
key: "${{ env.cache-version }}"
- name: "Cache PHP extensions"
uses: "actions/cache@v3"
with:
path: "${{ steps.extcache.outputs.dir }}"
key: "${{ steps.extcache.outputs.key }}"
restore-keys: "${{ steps.extcache.outputs.key }}"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.extensions }}"
tools: "composer:${{ env.composer-version }}"
coverage: "none"
- name: "Setup problem matchers for PHP"
run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"'
- name: "Setup composer & install dependencies"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "highest"
composer-options: "${{ env.composer-options }}"
custom-cache-key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
- name: "Tests"
run: "make tests"
- name: "Upload logs"
uses: "actions/upload-artifact@v3"
with:
name: "Logs - Tests (${{ matrix.operating-system }}, ${{ matrix.php-version }})"
path: "var/log"
if-no-files-found: "ignore"
tests-code-coverage:
name: "Code tests with code coverage"
runs-on: "${{ matrix.operating-system }}"
needs: [ "tests" ]
strategy:
matrix:
php-version: [ "8.2" ]
operating-system: [ "ubuntu-latest" ]
fail-fast: false
if: "github.event_name == 'push'"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name : "Setup MySQL"
uses : "mirromutth/mysql-action@v1.1"
with :
mysql version : "5.7"
mysql database : "testdb"
mysql root password : "root"
- name: "Setup PHP cache environment"
id: "extcache"
uses: "shivammathur/cache-extensions@v1"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.extensions }}"
key: "${{ env.cache-version }}"
- name: "Cache PHP extensions"
uses: "actions/cache@v3"
with:
path: "${{ steps.extcache.outputs.dir }}"
key: "${{ steps.extcache.outputs.key }}"
restore-keys: "${{ steps.extcache.outputs.key }}"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.extensions }}"
tools: "composer:${{ env.composer-version }}"
coverage: "pcov"
- name: "Setup problem matchers for PHP"
run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"'
- name: "Setup composer & install dependencies"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "highest"
composer-options: "${{ env.composer-options }}"
custom-cache-key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
- name: "Tests"
run: "make coverage-clover"
- name: "Coveralls.io"
env:
CI_NAME: github
CI: true
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.5.3/php-coveralls.phar
php php-coveralls.phar --verbose --config tools/.coveralls.yml
tests-mutations:
name: "Test for mutants"
runs-on: "${{ matrix.operating-system }}"
strategy:
matrix:
php-version: [ "8.2" ]
operating-system: [ "ubuntu-latest" ]
fail-fast: false
if: "github.event_name == 'push'"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name : "Setup MySQL"
uses : "mirromutth/mysql-action@v1.1"
with :
mysql version : "5.7"
mysql database : "testdb"
mysql root password : "root"
- name: "Setup PHP cache environment"
id: "extcache"
uses: "shivammathur/cache-extensions@v1"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.extensions }}"
key: "${{ env.cache-version }}"
- name: "Cache PHP extensions"
uses: "actions/cache@v3"
with:
path: "${{ steps.extcache.outputs.dir }}"
key: "${{ steps.extcache.outputs.key }}"
restore-keys: "${{ steps.extcache.outputs.key }}"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.extensions }}"
tools: "composer:${{ env.composer-version }}"
coverage: "pcov"
- name: "Setup problem matchers for PHP"
run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"'
- name: "Setup composer & install dependencies"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "highest"
composer-options: "${{ env.composer-options }}"
custom-cache-key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
- name: "Mutation tests"
run: "make mutations-tests"
- name: "Cache Infection data"
uses: "actions/cache@v3"
with:
path: "var/tools/Infection"
key: "php-infection-${{ runner.os }}"
restore-keys: "php-infection-${{ runner.os }}"
- name: "Mutation tests with report"
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
shell: "bash"
run: "make mutations-infection ARGS='--logger-github'"
- name: "Upload logs"
uses: "actions/upload-artifact@v3"
with:
name: "Logs - Mutations"
path: "var/coverage/mutations/infection.log"
if-no-files-found: "ignore"
lint:
name: "Code linting"
runs-on: "${{ matrix.operating-system }}"
strategy:
matrix:
php-version: [ "8.1", "8.2" ]
node-version: [ "18" ]
operating-system: [ "ubuntu-latest" ]
fail-fast: false
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Setup PHP cache environment"
id: "extcache"
uses: "shivammathur/cache-extensions@v1"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.extensions }}"
key: "${{ env.cache-version }}"
- name: "Cache PHP extensions"
uses: "actions/cache@v3"
with:
path: "${{ steps.extcache.outputs.dir }}"
key: "${{ steps.extcache.outputs.key }}"
restore-keys: "${{ steps.extcache.outputs.key }}"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.extensions }}"
tools: "composer:${{ env.composer-version }}"
coverage: "none"
- name: "Setup problem matchers for PHP"
run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"'
- name: "Setup composer & install dependencies"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "highest"
composer-options: "${{ env.composer-options }}"
custom-cache-key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
- name: "Setup node"
uses: "actions/setup-node@v4"
with:
node-version: "${{ matrix.node-version }}"
- name: "Get Yarn cache directory"
id: "yarn-cache-dir-path"
run: 'echo "::set-output name=dir::$(yarn cache dir)"'
- name: "Cache JS dependencies"
uses: "actions/cache@v3"
with:
path: "${{ steps.yarn-cache-dir-path.outputs.dir }}"
key: "${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }}"
restore-keys: "${{ runner.os }}-node-modules-"
- name: "Install dependencies"
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: "yarn install"
- name: "Check js linter"
run: "yarn lint:js"
- name: "Check php linter"
run: "make lint"
build:
name: "Build code for distribution"
runs-on: "${{ matrix.operating-system }}"
needs: "lint"
strategy:
matrix:
node-version: [ "18" ]
operating-system: [ "ubuntu-latest" ]
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Install node"
uses: "actions/setup-node@v4"
with:
node-version: "${{ matrix.node-version }}"
registry-url: "https://registry.npmjs.org"
- name: "Install package dependencies"
run: "yarn install"
- name: "Build the project"
run: "yarn build"
- name: "Upload build result"
uses: "actions/upload-artifact@v3"
with:
name: js-dist
path: dist
publish-npmjs:
name: "Publish code distribution to NPM"
runs-on: "${{ matrix.operating-system }}"
needs: [ "build" ]
strategy:
matrix:
node-version: [ "18" ]
operating-system: [ "ubuntu-latest" ]
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Install node"
uses: "actions/setup-node@v4"
with:
node-version: "${{ matrix.node-version }}"
registry-url: "https://registry.npmjs.org"
- name: "Extract version"
uses: "battila7/get-version-action@v2"
id: "get_version"
- name: "Set up git since we will later push to the repo"
run: |
git config --global user.name "GitHub CD bot"
git config --global user.email "code@fastybird.com"
- name: "Upgrade npm version in package.json to the tag used in the release"
if: contains(github.ref, 'refs/tags/')
run: npm version ${{ steps.get_version.outputs.version-without-v }} --allow-same-version
- name: "Download build result"
uses: "actions/download-artifact@v1"
with:
name: js-dist
path: dist
- name: "Publish to NPM"
uses: "JS-DevTools/npm-publish@v3"
id: "npm_publish"
if: contains(github.ref, 'refs/tags/')
with:
token: ${{ secrets.NPMJS_TOKEN }}
access: "public"
- name: "Publish to NPM result"
if: contains(github.ref, 'refs/tags/') && steps.npm_publish.outputs.type != 'none'
run: |
echo "Version changed: ${{ steps.publish.outputs.old-version }} => ${{ steps.publish.outputs.version }}"
- name: "Publish to NPM"
uses: "JS-DevTools/npm-publish@v3"
id: "npm_publish_dev"
if: contains(github.ref, 'refs/tags/') == false
with:
token: ${{ secrets.NPMJS_TOKEN }}
access: "public"
tag: "dev"
- name: "Publish to NPM result"
if: contains(github.ref, 'refs/tags/') == false && steps.npm_publish_dev.outputs.type != 'none'
run: |
echo "Version changed: ${{ steps.publish.outputs.old-version }} => ${{ steps.publish.outputs.version }}"
publish-github:
name: "Publish code distribution to Github packages"
runs-on: "${{ matrix.operating-system }}"
needs: [ "build" ]
strategy:
matrix:
node-version: [ "18" ]
operating-system: [ "ubuntu-latest" ]
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Install node"
uses: "actions/setup-node@v4"
with:
node-version: "${{ matrix.node-version }}"
registry-url: "https://npm.pkg.github.com"
- name: "Extract version"
uses: "battila7/get-version-action@v2"
id: "get_version"
- name: "Set up git since we will later push to the repo"
run: |
git config --global user.name "GitHub CD bot"
git config --global user.email "code@fastybird.com"
- name: "Upgrade npm version in package.json to the tag used in the release"
if: contains(github.ref, 'refs/tags/')
run: npm version ${{ steps.get_version.outputs.version-without-v }} --allow-same-version
- name: "Download build result"
uses: "actions/download-artifact@v1"
with:
name: js-dist
path: dist
- name: "Publish to NPM"
uses: "JS-DevTools/npm-publish@v3"
id: "npm_publish"
if: contains(github.ref, 'refs/tags/')
with:
token: ${{ secrets.GITHUB_TOKEN }}
access: "public"
registry: "https://npm.pkg.github.com"
- name: "Publish to NPM result"
if: contains(github.ref, 'refs/tags/') && steps.npm_publish.outputs.type != 'none'
run: |
echo "Version changed: ${{ steps.publish.outputs.old-version }} => ${{ steps.publish.outputs.version }}"
- name: "Publish to NPM"
uses: "JS-DevTools/npm-publish@v3"
id: "npm_publish_dev"
if: contains(github.ref, 'refs/tags/') == false
with:
token: ${{ secrets.GITHUB_TOKEN }}
access: "public"
tag: "dev"
registry: "https://npm.pkg.github.com"
- name: "Publish to NPM result"
if: contains(github.ref, 'refs/tags/') == false && steps.npm_publish_dev.outputs.type != 'none'
run: |
echo "Version changed: ${{ steps.publish.outputs.old-version }} => ${{ steps.publish.outputs.version }}"