Merge remote-tracking branch 'origin/v7.1.0' into v7.1.0 #920
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Cyr2Lat CI | |
| on: | |
| workflow_dispatch: | |
| push: | |
| paths: | |
| - '**/*.php' | |
| - 'composer.*' | |
| - 'package.json' | |
| - 'yarn.lock' | |
| - '.yarnrc.yml' | |
| - 'babel.config.json' | |
| - 'eslint.config.cjs' | |
| - 'postcss.config.js' | |
| - 'webpack.config.js' | |
| - 'assets/**' | |
| - 'src/**' | |
| - 'tests/**' | |
| - 'readme.txt' | |
| - '.github/scripts/**' | |
| - '.github/workflows/**' | |
| pull_request: | |
| paths: | |
| - '**/*.php' | |
| - 'composer.*' | |
| - 'package.json' | |
| - 'yarn.lock' | |
| - '.yarnrc.yml' | |
| - 'babel.config.json' | |
| - 'eslint.config.cjs' | |
| - 'postcss.config.js' | |
| - 'webpack.config.js' | |
| - 'assets/**' | |
| - 'src/**' | |
| - 'tests/**' | |
| - 'readme.txt' | |
| - '.github/scripts/**' | |
| - '.github/workflows/**' | |
| permissions: | |
| actions: read | |
| contents: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| phpcs: | |
| name: PHPCS | |
| runs-on: ubuntu-latest | |
| if: >- | |
| github.event_name != 'push' || | |
| !contains(github.event.head_commit.message || '', '[skip ci]') | |
| env: | |
| wp-plugin-directory: wordpress/wp-content/plugins/cyr2lat | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| with: | |
| path: ${{ env.wp-plugin-directory }} | |
| persist-credentials: false | |
| - name: Setup PHP 8.5 | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.5' | |
| extensions: json, mysqli, mbstring, zip | |
| ini-values: register_argc_argv=On | |
| - name: Install dependencies with caching | |
| uses: ramsey/composer-install@v4 | |
| with: | |
| working-directory: ${{ env.wp-plugin-directory }} | |
| - name: Run code sniffer | |
| working-directory: ${{ env.wp-plugin-directory }} | |
| run: composer phpcs | |
| js: | |
| name: JS lint and tests | |
| runs-on: ubuntu-latest | |
| needs: phpcs | |
| env: | |
| wp-plugin-directory: wordpress/wp-content/plugins/cyr2lat | |
| YARN_ENABLE_IMMUTABLE_INSTALLS: false | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| with: | |
| path: ${{ env.wp-plugin-directory }} | |
| persist-credentials: false | |
| - name: Install JS dependencies | |
| working-directory: ${{ env.wp-plugin-directory }} | |
| run: | | |
| corepack enable | |
| yarn install --no-immutable | |
| - name: Run ESLint | |
| working-directory: ${{ env.wp-plugin-directory }} | |
| run: | | |
| yarn dev | |
| yarn lint | |
| - name: Run Jest | |
| working-directory: ${{ env.wp-plugin-directory }} | |
| run: yarn test | |
| php_versions: | |
| name: Resolve PHP versions | |
| runs-on: ubuntu-latest | |
| needs: js | |
| outputs: | |
| matrix: ${{ steps.resolve.outputs.matrix }} | |
| env: | |
| FULL_PHP_MATRIX: >- | |
| ${{ | |
| github.event_name == 'push' && | |
| ( | |
| github.ref_name == github.event.repository.default_branch || | |
| contains(github.event.head_commit.message || '', '[all]') | |
| ) | |
| }} | |
| steps: | |
| - name: Resolve PHP versions | |
| id: resolve | |
| run: | | |
| if [ "$FULL_PHP_MATRIX" = "true" ]; then | |
| echo 'matrix=["7.4","8.0","8.1","8.2","8.3","8.4","8.5"]' >> "$GITHUB_OUTPUT" | |
| else | |
| echo 'matrix=["7.4","8.5"]' >> "$GITHUB_OUTPUT" | |
| fi | |
| unit: | |
| name: Unit tests on PHP ${{ matrix.php-version }} | |
| runs-on: ubuntu-latest | |
| needs: php_versions | |
| strategy: | |
| matrix: | |
| php-version: ${{ fromJSON(needs.php_versions.outputs.matrix) }} | |
| env: | |
| wp-plugin-directory: wordpress/wp-content/plugins/cyr2lat | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| with: | |
| path: ${{ env.wp-plugin-directory }} | |
| persist-credentials: false | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php-version }} | |
| extensions: json, mysqli, mbstring, zip | |
| ini-values: register_argc_argv=On | |
| - name: Install dependencies with caching | |
| uses: ramsey/composer-install@v4 | |
| with: | |
| working-directory: ${{ env.wp-plugin-directory }} | |
| - name: Run unit tests | |
| working-directory: ${{ env.wp-plugin-directory }} | |
| run: composer unit | |
| integration: | |
| name: WP integration tests on PHP ${{ matrix.php-version }} | |
| runs-on: ubuntu-latest | |
| needs: [ unit, php_versions ] | |
| strategy: | |
| matrix: | |
| php-version: ${{ fromJSON(needs.php_versions.outputs.matrix) }} | |
| env: | |
| wp-directory: wordpress | |
| wp-plugin-directory: wordpress/wp-content/plugins/cyr2lat | |
| DB_HOST: localhost | |
| DB_NAME: cyr2lat-tests | |
| DB_USER: test | |
| DB_PASSWORD: test | |
| DB_TABLE_PREFIX: wptests_ | |
| WP_URL: https://test.test | |
| WP_DOMAIN: test.test | |
| WP_ADMIN_USERNAME: admin | |
| WP_ADMIN_PASSWORD: admin | |
| WP_ADMIN_EMAIL: admin@test.test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| with: | |
| path: ${{ env.wp-plugin-directory }} | |
| persist-credentials: false | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php-version }} | |
| extensions: json, mysqli, mbstring, zip | |
| ini-values: register_argc_argv=On | |
| - name: Install dependencies with caching | |
| uses: ramsey/composer-install@v4 | |
| with: | |
| working-directory: ${{ env.wp-plugin-directory }} | |
| - name: Install WP CLI | |
| run: | | |
| WPCLI_VERSION=2.12.0 | |
| curl -fsSL -o wp-cli.phar "https://github.com/wp-cli/wp-cli/releases/download/v${WPCLI_VERSION}/wp-cli-${WPCLI_VERSION}.phar" | |
| curl -fsSL -o wp-cli.phar.sha256 "https://github.com/wp-cli/wp-cli/releases/download/v${WPCLI_VERSION}/wp-cli-${WPCLI_VERSION}.phar.sha256" | |
| echo "$(cat wp-cli.phar.sha256) wp-cli.phar" | sha256sum -c - | |
| chmod +x wp-cli.phar | |
| mkdir -p wp-cli | |
| sudo mv wp-cli.phar wp-cli/wp | |
| echo "$GITHUB_WORKSPACE/wp-cli" >> "$GITHUB_PATH" | |
| - name: Start MySQL | |
| run: | | |
| echo '[mysqld]' | sudo tee -a /etc/mysql/my.cnf | |
| echo 'default_authentication_plugin=mysql_native_password' | sudo tee -a /etc/mysql/my.cnf | |
| sudo systemctl start mysql | |
| mysql -e "CREATE USER '${{ env.DB_USER }}'@'${{ env.DB_HOST }}' IDENTIFIED BY '${{ env.DB_PASSWORD }}'" -uroot -proot 2>/dev/null | |
| mysql -e "ALTER USER '${{ env.DB_USER }}'@'${{ env.DB_HOST }}' IDENTIFIED WITH mysql_native_password BY '${{ env.DB_PASSWORD }}'" -uroot -proot 2>/dev/null | |
| mysql -e "GRANT ALL PRIVILEGES ON *.* TO '${{ env.DB_USER }}'@'${{ env.DB_HOST }}'" -uroot -proot 2>/dev/null | |
| mysql -e 'FLUSH PRIVILEGES' -uroot -proot 2>/dev/null | |
| - name: Install WordPress | |
| working-directory: ${{ env.wp-directory }} | |
| run: | | |
| wp core download | |
| wp config create --dbname="${{ env.DB_NAME }}" --dbuser="${{ env.DB_USER }}" --dbpass="${{ env.DB_PASSWORD }}" --dbhost="${{ env.DB_HOST }}" --dbprefix="${{ env.DB_TABLE_PREFIX }}" | |
| wp db create | |
| wp core install --url="${{ env.WP_URL }}" --title="Test" --admin_user="${{ env.WP_ADMIN_USERNAME }}" --admin_password="${{ env.WP_ADMIN_PASSWORD }}" --admin_email="${{ env.WP_ADMIN_EMAIL }}" --skip-email | |
| - name: Install WooCommerce | |
| working-directory: ${{ env.wp-directory }} | |
| run: wp plugin install woocommerce | |
| - name: Run integration tests | |
| working-directory: ${{ env.wp-plugin-directory }} | |
| run: composer integration | |
| update_changelog: | |
| name: Update Changelog | |
| runs-on: ubuntu-latest | |
| needs: integration | |
| if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/') | |
| permissions: | |
| contents: write | |
| env: | |
| wp-plugin-directory: wordpress/wp-content/plugins/cyr2lat | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| with: | |
| path: ${{ env.wp-plugin-directory }} | |
| ref: ${{ github.ref }} | |
| - name: Update changelog | |
| working-directory: ${{ env.wp-plugin-directory }} | |
| run: .github/scripts/update-changelog.sh |