Merge pull request #31216 from woocommerce/nx/gh-actions

Use Nx commands in GH actions
This commit is contained in:
jonathansadowski 2021-11-18 11:44:02 -06:00 committed by GitHub
commit eaf689ad78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 67 additions and 28 deletions

View File

@ -17,7 +17,7 @@ jobs:
ref: ${{ github.event.inputs.ref || github.ref }}
- name: Build the zip file
id: build
uses: woocommerce/action-build@v2
uses: woocommerce/action-build@trunk
- name: Unzip the file (prevents double zip problem)
run: unzip ${{ steps.build.outputs.zip_path }} -d zipfile
- name: Upload the zip file as an artifact

View File

@ -11,7 +11,7 @@ jobs:
uses: actions/checkout@v2
- name: Build
id: build
uses: woocommerce/action-build@v2
uses: woocommerce/action-build@trunk
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:

View File

@ -59,8 +59,13 @@ jobs:
./vendor
key: ${{ runner.os }}-${{ hashFiles('./composer.lock') }}
- name: Install PNPM and install dependencies
run: |
npm install -g pnpm
pnpm install
- name: Setup and install composer
run: composer install
run: pnpm nx composer-install woocommerce
- name: Add PHP8 Compatibility.
run: |
@ -71,11 +76,11 @@ jobs:
composer bin phpunit config repositories.0 '{"type": "path", "url": "/tmp/phpunit-7.5-fork/phpunit-add-compatibility-with-php8-to-phpunit-7", "options": {"symlink": false}}'
composer bin phpunit require --dev -W phpunit/phpunit:@dev --ignore-platform-reqs
rm -rf ./vendor/phpunit/
composer dump-autoload
pnpm nx composer-dump-autoload woocommerce
fi
- name: Init DB and WP
run: ./tests/bin/install.sh woo_test root root 127.0.0.1 ${{ matrix.wp }}
- name: Run tests
run: ./vendor/bin/phpunit -c ./phpunit.xml
run: pnpm nx test-unit woocommerce

View File

@ -45,15 +45,20 @@ jobs:
./vendor
key: ${{ runner.os }}-${{ hashFiles('./composer.lock') }}
- name: Install PNPM and install dependencies
run: |
npm install -g pnpm
pnpm install
- name: Setup and install composer
run: composer install
run: pnpm nx composer-install woocommerce
- name: Init DB and WP
run: ./tests/bin/install.sh woo_test root root 127.0.0.1 latest
run: pnpm nx install-unit-test-db woocommerce
- name: Run unit tests with code coverage. Allow to fail.
run: |
RUN_CODE_COVERAGE=1 bash ./tests/bin/phpunit.sh
pnpm nx test-code-coverage woocommerce
exit 0
- name: Send code coverage to Codecov.

View File

@ -35,8 +35,13 @@ jobs:
./vendor
key: ${{ runner.os }}-${{ hashFiles('./composer.lock') }}
- name: Install PNPM and install dependencies
run: |
npm install -g pnpm
pnpm install
- name: Setup and install composer
run: composer install
run: pnpm nx composer-install woocommerce
- name: Run code sniff
continue-on-error: true

View File

@ -28,8 +28,8 @@ jobs:
run: |
npm install -g pnpm
pnpm install
composer install --no-dev
pnpm run build:assets
pnpm nx composer-install-no-dev" woocommerce
pnpm nx build-assets woocommerce
pnpm install jest
- name: Run smoke test.

View File

@ -56,8 +56,11 @@ jobs:
./vendor
key: ${{ runner.os }}-${{ hashFiles('./composer.lock') }}
- name: Setup and install composer
run: composer install
- name: Install PNPM and install dependencies
run: |
npm install -g pnpm
pnpm install
pnpm nx composer-install woocommerce
- name: Add PHP8 Compatibility.
run: |
@ -75,4 +78,4 @@ jobs:
run: ./tests/bin/install.sh woo_test root root 127.0.0.1 ${{ matrix.wp }}
- name: Run tests
run: ./vendor/bin/phpunit -c ./phpunit.xml
run: pnpm nx test-unit woocommerce

View File

@ -26,8 +26,8 @@ jobs:
run: |
npm install -g pnpm
pnpm install
composer install --no-dev
pnpm run build:assets
pnpm nx composer-install-no-dev woocommerce
pnpm nx build-assets woocommerce
pnpm install jest
- name: Run smoke test.

View File

@ -26,8 +26,8 @@ jobs:
run: |
npm install -g pnpm
pnpm install
composer install --no-dev
pnpm run build:assets
pnpm nx composer-install-no-dev woocommerce
pnpm nx build-assets woocommerce
pnpm install jest
- name: Run smoke test.
@ -82,7 +82,7 @@ jobs:
working-directory: package/woocommerce/plugins/woocommerce
env:
LATEST_WP_VERSION_MINUS: ${{ matrix.wp }}
run: pnpx wc-e2e docker:up
run: pnpm nx docker-up woocommerce
- name: Move current directory to code. We will install zip file in this dir later.
run: mv ./package/woocommerce/plugins/woocommerce/* ./code/woocommerce
@ -103,4 +103,4 @@ jobs:
WC_E2E_SCREENSHOTS: 1
E2E_SLACK_TOKEN: ${{ secrets.SMOKE_TEST_SLACK_TOKEN }}
E2E_SLACK_CHANNEL: ${{ secrets.RELEASE_TEST_SLACK_CHANNEL }}
run: pnpx wc-e2e test:e2e
run: pnpm nx test-e2e woocommerce

View File

@ -13,8 +13,6 @@
"wp_org_slug": "woocommerce"
},
"scripts": {
"composer:install": "composer install",
"composer:dump-autoload": "composer dump-autoload",
"preinstall": "npx only-allow pnpm",
"build": "./bin/build-zip.sh",
"build:core": "grunt && pnpm run makepot",

View File

@ -4,17 +4,26 @@
"projectType": "application",
"targets": {
"composer-install": {
"executor": "@nrwl/workspace:run-script",
"executor": "@nrwl/workspace:run-commands",
"options": {
"script": "composer:install"
"command": "composer install",
"cwd": "plugins/woocommerce"
}
},
},
"composer-install-no-dev": {
"executor": "@nrwl/workspace:run-commands",
"options": {
"command": "composer install --no-dev",
"cwd": "plugins/woocommerce"
}
},
"composer-dump-autoload": {
"executor": "@nrwl/workspace:run-script",
"executor": "@nrwl/workspace:run-commands",
"options": {
"script": "composer:dump-autoload"
"command": "composer dump-autoload",
"cwd": "plugins/woocommerce"
}
},
},
"build": {
"executor": "@nrwl/workspace:run-script",
"options": {
@ -122,6 +131,20 @@
"options": {
"script": "make:collection"
}
},
"install-unit-test-db": {
"executor": "@nrwl/workspace:run-commands",
"options": {
"command": "bash tests/bin/install.sh woo_test root root 127.0.0.1 latest",
"cwd": "plugins/woocommerce"
}
},
"test-code-coverage": {
"executor": "@nrwl/workspace:run-commands",
"options": {
"command": "RUN_CODE_COVERAGE=1 bash tests/bin/phpunit.sh",
"cwd": "plugins/woocommerce"
}
}
}
}