|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, master ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, master ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + javascript-tests: |
| 11 | + name: JavaScript Tests |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + node-version: [16.x, 18.x, 20.x] |
| 17 | + |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v3 |
| 20 | + |
| 21 | + - name: Use Node.js ${{ matrix.node-version }} |
| 22 | + uses: actions/setup-node@v3 |
| 23 | + with: |
| 24 | + node-version: ${{ matrix.node-version }} |
| 25 | + cache: 'npm' |
| 26 | + |
| 27 | + - name: Install dependencies |
| 28 | + run: npm ci |
| 29 | + |
| 30 | + - name: Run linter |
| 31 | + run: npm run lint |
| 32 | + |
| 33 | + - name: Run tests with coverage |
| 34 | + run: npm run test:js:coverage |
| 35 | + |
| 36 | + - name: Upload coverage to Codecov |
| 37 | + uses: codecov/codecov-action@v3 |
| 38 | + with: |
| 39 | + files: ./coverage/lcov.info |
| 40 | + flags: javascript |
| 41 | + |
| 42 | + php-tests: |
| 43 | + name: PHP Tests |
| 44 | + runs-on: ubuntu-latest |
| 45 | + |
| 46 | + strategy: |
| 47 | + matrix: |
| 48 | + php-version: ['7.4', '8.0', '8.1', '8.2'] |
| 49 | + silverstripe-version: ['^4.0', '^5.0'] |
| 50 | + exclude: |
| 51 | + - php-version: '7.4' |
| 52 | + silverstripe-version: '^5.0' |
| 53 | + |
| 54 | + steps: |
| 55 | + - uses: actions/checkout@v3 |
| 56 | + |
| 57 | + - name: Setup PHP |
| 58 | + uses: shivammathur/setup-php@v2 |
| 59 | + with: |
| 60 | + php-version: ${{ matrix.php-version }} |
| 61 | + extensions: mbstring, intl, pdo, pdo_mysql |
| 62 | + coverage: xdebug |
| 63 | + |
| 64 | + - name: Validate composer.json |
| 65 | + run: composer validate --strict |
| 66 | + |
| 67 | + - name: Cache Composer packages |
| 68 | + uses: actions/cache@v3 |
| 69 | + with: |
| 70 | + path: vendor |
| 71 | + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} |
| 72 | + restore-keys: | |
| 73 | + ${{ runner.os }}-php- |
| 74 | + |
| 75 | + - name: Install dependencies |
| 76 | + run: | |
| 77 | + composer require silverstripe/framework:${{ matrix.silverstripe-version }} --no-update |
| 78 | + composer install --prefer-dist --no-progress |
| 79 | + |
| 80 | + - name: Run test suite |
| 81 | + run: vendor/bin/phpunit --coverage-clover coverage.xml |
| 82 | + |
| 83 | + - name: Upload coverage to Codecov |
| 84 | + uses: codecov/codecov-action@v3 |
| 85 | + with: |
| 86 | + files: ./coverage.xml |
| 87 | + flags: php |
| 88 | + |
| 89 | + build: |
| 90 | + name: Build Assets |
| 91 | + runs-on: ubuntu-latest |
| 92 | + |
| 93 | + steps: |
| 94 | + - uses: actions/checkout@v3 |
| 95 | + |
| 96 | + - name: Use Node.js |
| 97 | + uses: actions/setup-node@v3 |
| 98 | + with: |
| 99 | + node-version: '18.x' |
| 100 | + cache: 'npm' |
| 101 | + |
| 102 | + - name: Install dependencies |
| 103 | + run: npm ci |
| 104 | + |
| 105 | + - name: Build production assets |
| 106 | + run: npm run build |
| 107 | + |
| 108 | + - name: Verify build output |
| 109 | + run: | |
| 110 | + test -f client/dist/queuedjobs-admin.js || exit 1 |
| 111 | + test -f client/dist/queuedjobs-admin.css || exit 1 |
0 commit comments