|  | 
|  | 1 | +name: Coding Standards and Tests | 
|  | 2 | + | 
|  | 3 | +on: | 
|  | 4 | +  push: | 
|  | 5 | +    branches: | 
|  | 6 | +      - master | 
|  | 7 | +      - develop | 
|  | 8 | +  pull_request: | 
|  | 9 | + | 
|  | 10 | +jobs: | 
|  | 11 | +  lint: | 
|  | 12 | +    name: "Coding Standards" | 
|  | 13 | +    runs-on: ubuntu-latest | 
|  | 14 | + | 
|  | 15 | +    steps: | 
|  | 16 | +      - uses: actions/checkout@v2 | 
|  | 17 | +      - uses: actions/setup-node@v1 | 
|  | 18 | +        with: | 
|  | 19 | +          node-version: "14" | 
|  | 20 | + | 
|  | 21 | +      - name: Install dependencies | 
|  | 22 | +        run: npm ci | 
|  | 23 | + | 
|  | 24 | +      - name: Run coding standards check | 
|  | 25 | +        run: npm run lint | 
|  | 26 | + | 
|  | 27 | +  test-e2e: | 
|  | 28 | +    needs: [lint] | 
|  | 29 | +    name: "E2E tests (PHP ${{ matrix.php_versions }}, WordPress ${{ matrix.wp_versions }})" | 
|  | 30 | +    runs-on: ubuntu-latest | 
|  | 31 | + | 
|  | 32 | +    strategy: | 
|  | 33 | +      fail-fast: false | 
|  | 34 | +      matrix: | 
|  | 35 | +        php_versions: [7.4] | 
|  | 36 | +        wp_versions: [5.7] | 
|  | 37 | +        include: | 
|  | 38 | +          - php_versions: 7.3 | 
|  | 39 | +            wp_versions: 5.2 | 
|  | 40 | + | 
|  | 41 | +    env: | 
|  | 42 | +      NODE_ENV: teste2e | 
|  | 43 | +      WP_VERSION: ${{ matrix.wp_versions }} | 
|  | 44 | +      PHP_VERSION: php${{ matrix.php_versions }}-apache | 
|  | 45 | + | 
|  | 46 | +    steps: | 
|  | 47 | +      - uses: actions/checkout@v2 | 
|  | 48 | +      - uses: hmarr/debug-action@v2 | 
|  | 49 | +      - uses: actions/setup-node@v1 | 
|  | 50 | +        with: | 
|  | 51 | +          node-version: "14" | 
|  | 52 | + | 
|  | 53 | +      - name: Install dependencies | 
|  | 54 | +        run: npm ci | 
|  | 55 | + | 
|  | 56 | +      - name: Build assets | 
|  | 57 | +        run: npm run build:js | 
|  | 58 | + | 
|  | 59 | +      - name: Sleep for 10 seconds | 
|  | 60 | +        uses: jakejarvis/wait-action@master | 
|  | 61 | +        with: | 
|  | 62 | +          time: '10s' | 
|  | 63 | + | 
|  | 64 | +      - name: Start docker local env | 
|  | 65 | +        run: | | 
|  | 66 | +          npm run env:start | 
|  | 67 | +          docker-compose exec -T wordpress bash -c "chown -R www-data:www-data /var/www/html/wp-content/" # ensure WP folders have correct permissions | 
|  | 68 | +          docker-compose exec -T mysql bash -c "chown -R mysql:mysql /var/lib/mysql" | 
|  | 69 | +
 | 
|  | 70 | +      - name: Docker containers debug information | 
|  | 71 | +        run: | | 
|  | 72 | +          docker ps -a | 
|  | 73 | +
 | 
|  | 74 | +      - name: Sleep for 10 seconds | 
|  | 75 | +        uses: jakejarvis/wait-action@master | 
|  | 76 | +        with: | 
|  | 77 | +          time: '10s' | 
|  | 78 | + | 
|  | 79 | +      - name: Install WordPress | 
|  | 80 | +        run: | | 
|  | 81 | +          npm run wp -- wp core install --title=WordPress --admin_user=admin --admin_password=password [email protected] --skip-email --url=http://localhost:8088 --quiet | 
|  | 82 | +          npm run wp -- wp plugin activate material-design | 
|  | 83 | +
 | 
|  | 84 | +      - name: Run E2E tests | 
|  | 85 | +        if: ${{ matrix.wp_versions == '5.2' }} | 
|  | 86 | +        run: npm run test:e2e | 
|  | 87 | + | 
|  | 88 | +      - name: Run E2E tests with coverage | 
|  | 89 | +        if: ${{ matrix.wp_versions != '5.2' }} | 
|  | 90 | +        run: | | 
|  | 91 | +          sudo chown -R runner:runner plugin/tests node_modules # ensure coverage folder can be created | 
|  | 92 | +          npm run test:e2e:coverage | 
|  | 93 | +
 | 
|  | 94 | +      - name: Coveralls | 
|  | 95 | +        if: ${{ matrix.wp_versions != '5.2' }} | 
|  | 96 | +        uses: coverallsapp/github-action@master | 
|  | 97 | +        with: | 
|  | 98 | +          github-token: ${{ secrets.GITHUB_TOKEN }} | 
|  | 99 | +          path-to-lcov: ./plugin/tests/coverage/e2e/lcov.info | 
|  | 100 | +          flag-name: "E2E Tests" | 
|  | 101 | +          parallel: true | 
|  | 102 | + | 
|  | 103 | +  test-js: | 
|  | 104 | +    needs: [lint] | 
|  | 105 | +    name: "JS unit tests (with code coverage)" | 
|  | 106 | +    runs-on: ubuntu-latest | 
|  | 107 | + | 
|  | 108 | +    steps: | 
|  | 109 | +      - uses: actions/checkout@v2 | 
|  | 110 | +      - uses: actions/setup-node@v1 | 
|  | 111 | +        with: | 
|  | 112 | +          node-version: "14" | 
|  | 113 | + | 
|  | 114 | +      - name: Install dependencies | 
|  | 115 | +        run: npm ci | 
|  | 116 | + | 
|  | 117 | +      - name: Run JS tests | 
|  | 118 | +        run: npm run test:js:coverage | 
|  | 119 | + | 
|  | 120 | +      - name: Coveralls | 
|  | 121 | +        uses: coverallsapp/github-action@master | 
|  | 122 | +        with: | 
|  | 123 | +          github-token: ${{ secrets.GITHUB_TOKEN }} | 
|  | 124 | +          path-to-lcov: ./plugin/tests/coverage/js/lcov.info | 
|  | 125 | +          flag-name: "JS Unit Tests" | 
|  | 126 | +          parallel: true | 
|  | 127 | + | 
|  | 128 | +  test-php: | 
|  | 129 | +    needs: [lint] | 
|  | 130 | +    name: "PHP tests (PHP ${{ matrix.php_versions }}, WordPress ${{ matrix.wp_versions }})" | 
|  | 131 | +    runs-on: ${{ matrix.os }} | 
|  | 132 | +    strategy: | 
|  | 133 | +      fail-fast: false | 
|  | 134 | +      matrix: | 
|  | 135 | +        php_versions: [7.4, 7.3, 7.2, 7.1] | 
|  | 136 | +        wp_versions: ["latest"] | 
|  | 137 | +        os: [ubuntu-latest] | 
|  | 138 | +        include: | 
|  | 139 | +          - php_versions: 7.4 | 
|  | 140 | +            wp_versions: "trunk" | 
|  | 141 | +            os: ubuntu-latest | 
|  | 142 | + | 
|  | 143 | +          - php_versions: "7.0" | 
|  | 144 | +            wp_versions: "latest" | 
|  | 145 | +            os: ubuntu-18.04 # Use ubuntu-18.4 which has MySQL 5.7 for back-compat < PHP7.0 | 
|  | 146 | + | 
|  | 147 | +          - php_versions: 5.6.20 | 
|  | 148 | +            wp_versions: "latest" | 
|  | 149 | +            os: ubuntu-18.04 | 
|  | 150 | + | 
|  | 151 | +          - php_versions: 5.6.20 | 
|  | 152 | +            wp_versions: "5.2" | 
|  | 153 | +            os: ubuntu-18.04 | 
|  | 154 | + | 
|  | 155 | +    env: | 
|  | 156 | +      WP_VERSION: ${{ matrix.wp_versions }} | 
|  | 157 | +      COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} | 
|  | 158 | +      COVERALLS_PARALLEL: true | 
|  | 159 | +      COVERALLS: ${{ matrix.php_versions == 7.4 && matrix.wp_versions == 'latest' }} | 
|  | 160 | +      PROJECT_TYPE: plugin | 
|  | 161 | + | 
|  | 162 | +    steps: | 
|  | 163 | +      - uses: actions/checkout@v2 | 
|  | 164 | +      - name: Setup PHP ${{ matrix.php_versions }} | 
|  | 165 | +        uses: shivammathur/setup-php@v2 | 
|  | 166 | +        with: | 
|  | 167 | +          php-version: ${{ matrix.php_versions }} | 
|  | 168 | +          tools: phpunit | 
|  | 169 | + | 
|  | 170 | +      - name: Start MySQL | 
|  | 171 | +        run: | | 
|  | 172 | +          sudo systemctl enable mysql.service | 
|  | 173 | +          sudo systemctl start mysql.service | 
|  | 174 | +
 | 
|  | 175 | +      - name: Install dependencies | 
|  | 176 | +        run: composer install | 
|  | 177 | + | 
|  | 178 | +      - name: Copy block.json files | 
|  | 179 | +        run: for file in ./plugin/assets/src/block-editor/blocks/*/block.json; do dest="${file/.\/plugin\/assets\/src\/block-editor\//./plugin/assets/js/}"; mkdir -p `dirname $dest`; cp $file $dest; done | 
|  | 180 | + | 
|  | 181 | +      - name: Install and Run tests | 
|  | 182 | +        if: ${{ matrix.php_versions == '7.0' || matrix.php_versions == '5.6.20' }} | 
|  | 183 | +        run: | | 
|  | 184 | +          wget -O bin/phpunit https://phar.phpunit.de/phpunit-5.phar | 
|  | 185 | +          chmod +x bin/phpunit | 
|  | 186 | +          source bin/php-tests.sh wordpress_test root root localhost false bin/phpunit | 
|  | 187 | +
 | 
|  | 188 | +      - name: Install and Run tests | 
|  | 189 | +        if: ${{ matrix.php_versions != '7.0' && matrix.php_versions != '5.6.20' }} | 
|  | 190 | +        run: source bin/php-tests.sh wordpress_test root root localhost | 
|  | 191 | + | 
|  | 192 | +  finish: | 
|  | 193 | +    needs: [test-e2e, test-js, test-php] | 
|  | 194 | +    name: Finish | 
|  | 195 | +    runs-on: ubuntu-latest | 
|  | 196 | +    steps: | 
|  | 197 | +      - name: Coveralls Finished | 
|  | 198 | +        uses: coverallsapp/github-action@master | 
|  | 199 | +        with: | 
|  | 200 | +          github-token: ${{ secrets.github_token }} | 
|  | 201 | +          parallel-finished: true | 
0 commit comments