|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, develop] |
| 6 | + pull_request: |
| 7 | + branches: [main, develop] |
| 8 | + |
| 9 | +jobs: |
| 10 | + php-tests: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + php-version: [7.4, 8.0, 8.1, 8.2] |
| 15 | + wordpress-version: [6.3, 6.4] |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout code |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Setup PHP |
| 22 | + uses: shivammathur/setup-php@v2 |
| 23 | + with: |
| 24 | + php-version: ${{ matrix.php-version }} |
| 25 | + extensions: mbstring, xml, ctype, iconv, intl, pdo_mysql, zip |
| 26 | + |
| 27 | + - name: Setup WordPress test environment |
| 28 | + uses: WordPress/wordpress-develop-tests@v2 |
| 29 | + with: |
| 30 | + wp-version: ${{ matrix.wordpress-version }} |
| 31 | + |
| 32 | + - name: Install dependencies |
| 33 | + run: composer install --no-dev --optimize-autoloader |
| 34 | + |
| 35 | + - name: Run PHPCS |
| 36 | + run: | |
| 37 | + composer global require wp-coding-standards/wpcs |
| 38 | + ./vendor/bin/phpcs --standard=phpcs.xml |
| 39 | +
|
| 40 | + - name: Run PHPUnit tests |
| 41 | + run: ./vendor/bin/phpunit |
| 42 | + |
| 43 | + js-tests: |
| 44 | + runs-on: ubuntu-latest |
| 45 | + |
| 46 | + steps: |
| 47 | + - name: Checkout code |
| 48 | + uses: actions/checkout@v4 |
| 49 | + |
| 50 | + - name: Setup Node.js |
| 51 | + uses: actions/setup-node@v4 |
| 52 | + with: |
| 53 | + node-version: '18' |
| 54 | + cache: 'npm' |
| 55 | + |
| 56 | + - name: Install dependencies |
| 57 | + run: npm ci |
| 58 | + |
| 59 | + - name: Run ESLint |
| 60 | + run: npm run lint:js |
| 61 | + |
| 62 | + - name: Build assets |
| 63 | + run: npm run build |
| 64 | + |
| 65 | + e2e-tests: |
| 66 | + runs-on: ubuntu-latest |
| 67 | + |
| 68 | + steps: |
| 69 | + - name: Checkout code |
| 70 | + uses: actions/checkout@v4 |
| 71 | + |
| 72 | + - name: Setup Node.js |
| 73 | + uses: actions/setup-node@v4 |
| 74 | + with: |
| 75 | + node-version: '18' |
| 76 | + cache: 'npm' |
| 77 | + |
| 78 | + - name: Install dependencies |
| 79 | + run: npm ci |
| 80 | + |
| 81 | + - name: Install Playwright browsers |
| 82 | + run: npx playwright install --with-deps |
| 83 | + |
| 84 | + - name: Run Playwright tests |
| 85 | + run: npm run e2e |
| 86 | + |
| 87 | + package: |
| 88 | + runs-on: ubuntu-latest |
| 89 | + needs: [php-tests, js-tests, e2e-tests] |
| 90 | + |
| 91 | + steps: |
| 92 | + - name: Checkout code |
| 93 | + uses: actions/checkout@v4 |
| 94 | + |
| 95 | + - name: Setup Node.js |
| 96 | + uses: actions/setup-node@v4 |
| 97 | + with: |
| 98 | + node-version: '18' |
| 99 | + cache: 'npm' |
| 100 | + |
| 101 | + - name: Install dependencies |
| 102 | + run: npm ci |
| 103 | + |
| 104 | + - name: Build assets |
| 105 | + run: npm run build |
| 106 | + |
| 107 | + - name: Package plugin |
| 108 | + run: npm run package |
| 109 | + |
| 110 | + - name: Upload artifact |
| 111 | + uses: actions/upload-artifact@v4 |
| 112 | + with: |
| 113 | + name: wp-telegram-post-notifier |
| 114 | + path: dist/wp-telegram-post-notifier.zip |
0 commit comments