|
1 | 1 | name: Module checks |
| 2 | + |
2 | 3 | on: |
3 | 4 | push: |
4 | 5 | branches: [ develop ] |
5 | 6 | pull_request: |
6 | 7 | branches: [ develop ] |
7 | 8 | workflow_dispatch: |
| 9 | + |
8 | 10 | jobs: |
9 | 11 | build: |
10 | 12 | runs-on: ubuntu-latest |
| 13 | + |
11 | 14 | steps: |
12 | | - - name: setup php |
| 15 | + - name: Setup PHP 8.4 |
13 | 16 | uses: shivammathur/setup-php@v2 |
14 | 17 | with: |
15 | | - php-version: 7.3 |
16 | | - tools: composer:v2 |
17 | | - - uses: actions/checkout@v2 |
18 | | - - name: validate composer json |
| 18 | + php-version: '8.4' |
| 19 | + tools: composer:v2, phpunit, phpcs |
| 20 | + coverage: none |
| 21 | + |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Validate composer.json |
19 | 26 | run: composer validate |
| 27 | + |
20 | 28 | - name: Cache Composer packages |
21 | 29 | id: composer-cache |
22 | | - uses: actions/cache@v2 |
| 30 | + uses: actions/cache@v4 |
23 | 31 | with: |
24 | 32 | path: ${{ github.workspace }}/${{ env.namespace }}-source/vendor |
25 | | - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} |
| 33 | + key: ${{ runner.os }}-php84-${{ hashFiles('**/composer.lock') }} |
26 | 34 | restore-keys: | |
27 | | - ${{ runner.os }}-php- |
28 | | - - name: PHPUnit and PHPCS |
| 35 | + ${{ runner.os }}-php84- |
| 36 | +
|
| 37 | + - name: Prepare auth for Magento repo |
| 38 | + run: | |
| 39 | + printf '%s\n' \ |
| 40 | + '{' \ |
| 41 | + ' "http-basic": {' \ |
| 42 | + ' "repo.magento.com": {' \ |
| 43 | + ' "username": "${{ secrets.REPO_USERNAME }}",' \ |
| 44 | + ' "password": "${{ secrets.REPO_PASS }}"' \ |
| 45 | + ' }' \ |
| 46 | + ' }' \ |
| 47 | + '}' > auth.json |
| 48 | +
|
| 49 | + - name: Determine changed files (PR only) |
| 50 | + if: ${{ github.event_name == 'pull_request' }} |
29 | 51 | run: | |
30 | 52 | pull_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH") |
31 | | - url="https://api.github.com/repos/buckaroo-it/Magento2/pulls/$pull_number/files" |
32 | | - echo $url |
33 | | - curl $url > files_changed |
34 | | - cat files_changed | grep '"filename"' | sed 's/\"filename\"\: \"//' | sed 's/\",//' | xargs ls |
35 | | - echo '{"http-basic": {"repo.magento.com": {"username": "${{ secrets.REPO_USERNAME }}","password": "${{ secrets.REPO_PASS }}"}}}' > auth.json |
36 | | - composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.3.6 m23 |
37 | | - mkdir -p m23/app/code/Buckaroo/Magento2/ |
38 | | - rsync -r --exclude='m23' ./ m23/app/code/Buckaroo/Magento2/ |
39 | | - cat files_changed | grep '"filename"' | sed 's/\"filename\"\: \"//' | sed 's/\",//' | xargs ./m23/vendor/bin/phpcs --standard=Magento2 |
40 | | - cd m23 |
| 53 | + url="https://api.github.com/repos/${{ github.repository }}/pulls/$pull_number/files" |
| 54 | + echo "$url" |
| 55 | + curl -sS "$url" > files_changed |
| 56 | + cat files_changed | grep '"filename"' | sed 's/\"filename\"\: \"//' | sed 's/\",//' | xargs -r ls -la |
| 57 | +
|
| 58 | + - name: Create Magento 2.4.8-p3 project |
| 59 | + run: | |
| 60 | + composer create-project --repository-url=https://repo.magento.com/ \ |
| 61 | + magento/project-community-edition=2.4.8-p3 m248 |
| 62 | +
|
| 63 | + - name: Copy module into Magento |
| 64 | + run: | |
| 65 | + mkdir -p m248/app/code/Buckaroo/Magento2/ |
| 66 | + rsync -r --exclude='m248' ./ m248/app/code/Buckaroo/Magento2/ |
| 67 | +
|
| 68 | + - name: Run PHPCS against changed files (PR) or whole module (push) |
| 69 | + run: | |
| 70 | + if [ -f files_changed ]; then |
| 71 | + cat files_changed | grep '"filename"' | sed 's/\"filename\"\: \"//' | sed 's/\",//' \ |
| 72 | + | xargs -r ./m248/vendor/bin/phpcs --standard=Magento2 |
| 73 | + else |
| 74 | + ./m248/vendor/bin/phpcs --standard=Magento2 m248/app/code/Buckaroo/Magento2 |
| 75 | + fi |
| 76 | +
|
| 77 | + - name: Compile and run unit tests |
| 78 | + working-directory: m248 |
| 79 | + run: | |
41 | 80 | bin/magento module:enable --all |
42 | 81 | bin/magento setup:di:compile |
43 | 82 | vendor/phpunit/phpunit/phpunit -c dev/tests/unit/phpunit.xml.dist app/code/Buckaroo/Magento2 |
0 commit comments