Refactor caching for workflows
This commit is contained in:
parent
22b86726ea
commit
bd23093c42
|
@ -1,17 +1,16 @@
|
|||
name: Build zip for PR
|
||||
on: pull_request
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build zip for PR
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Cancel Previous Runs
|
||||
uses: styfle/cancel-workflow-action@0.7.0
|
||||
with:
|
||||
access_token: ${{ github.token }}
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Build
|
||||
id: build
|
||||
|
@ -20,7 +19,7 @@ jobs:
|
|||
BUILD_ENV: e2e
|
||||
|
||||
- name: Upload PR zip
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
|
@ -38,10 +37,9 @@ jobs:
|
|||
mkdir -p code/woocommerce
|
||||
mkdir -p package/woocommerce
|
||||
mkdir -p tmp/woocommerce
|
||||
mkdir -p node_modules
|
||||
|
||||
- name: Checkout code.
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
path: package/woocommerce
|
||||
|
||||
|
@ -49,7 +47,7 @@ jobs:
|
|||
run: mv ./package/woocommerce/plugins/woocommerce/* ./code/woocommerce
|
||||
|
||||
- name: Download WooCommerce ZIP.
|
||||
uses: actions/download-artifact@v2
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: woocommerce
|
||||
path: tmp
|
||||
|
@ -60,15 +58,23 @@ jobs:
|
|||
unzip woocommerce.zip -d woocommerce
|
||||
mv woocommerce/woocommerce/* ../package/woocommerce/plugins/woocommerce/
|
||||
|
||||
- name: Cache modules
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.pnpm-store
|
||||
key: ${{ runner.os }}-npm-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
|
||||
- name: Install PNPM
|
||||
run: npm install -g pnpm
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: package/woocommerce
|
||||
run: |
|
||||
npm install -g pnpm
|
||||
pnpm install
|
||||
run: pnpm install
|
||||
|
||||
- name: Load docker images and start containers.
|
||||
working-directory: package/woocommerce/plugins/woocommerce
|
||||
run: pnpx wc-e2e docker:up
|
||||
run: pnpm exec wc-e2e docker:up
|
||||
|
||||
- name: Run tests command.
|
||||
working-directory: package/woocommerce/plugins/woocommerce
|
||||
|
@ -76,10 +82,10 @@ jobs:
|
|||
WC_E2E_SCREENSHOTS: 1
|
||||
E2E_SLACK_TOKEN: ${{ secrets.E2E_SLACK_TOKEN }}
|
||||
E2E_SLACK_CHANNEL: ${{ secrets.E2E_SLACK_CHANNEL }}
|
||||
run: pnpx wc-e2e test:e2e
|
||||
run: pnpm exec wc-e2e test:e2e
|
||||
|
||||
- name: Archive E2E test screenshots
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
if: always()
|
||||
with:
|
||||
name: E2E Screenshots
|
||||
|
@ -97,10 +103,9 @@ jobs:
|
|||
mkdir -p code/woocommerce
|
||||
mkdir -p package/woocommerce
|
||||
mkdir -p tmp/woocommerce
|
||||
mkdir -p node_modules
|
||||
|
||||
- name: Checkout code.
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
path: package/woocommerce
|
||||
|
||||
|
@ -108,7 +113,7 @@ jobs:
|
|||
run: mv ./package/woocommerce/plugins/woocommerce/* ./code/woocommerce
|
||||
|
||||
- name: Download WooCommerce ZIP.
|
||||
uses: actions/download-artifact@v2
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: woocommerce
|
||||
path: tmp
|
||||
|
@ -119,15 +124,23 @@ jobs:
|
|||
unzip woocommerce.zip -d woocommerce
|
||||
mv woocommerce/woocommerce/* ../package/woocommerce/plugins/woocommerce/
|
||||
|
||||
- name: Cache modules
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.pnpm-store
|
||||
key: ${{ runner.os }}-npm-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
|
||||
- name: Install PNPM
|
||||
run: npm install -g pnpm
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: package/woocommerce
|
||||
run: |
|
||||
npm install -g pnpm
|
||||
pnpm install
|
||||
run: pnpm install
|
||||
|
||||
- name: Load docker images and start containers.
|
||||
working-directory: package/woocommerce/plugins/woocommerce
|
||||
run: pnpx wc-e2e docker:up
|
||||
run: pnpm exec wc-e2e docker:up
|
||||
|
||||
- name: Run tests command.
|
||||
working-directory: package/woocommerce/plugins/woocommerce
|
||||
|
@ -135,10 +148,10 @@ jobs:
|
|||
BASE_URL: http://localhost:8084
|
||||
USER_KEY: admin
|
||||
USER_SECRET: password
|
||||
run: pnpx wc-api-tests test api
|
||||
run: pnpm exec wc-api-tests test api
|
||||
|
||||
- name: Upload API test report
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: api-test-report---pr-${{ github.event.number }}
|
||||
path: |
|
||||
|
@ -156,9 +169,9 @@ jobs:
|
|||
mkdir -p code/woocommerce
|
||||
mkdir -p package/woocommerce
|
||||
mkdir -p tmp/woocommerce
|
||||
mkdir -p node_modules
|
||||
|
||||
- name: Checkout code.
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
path: package/woocommerce
|
||||
|
||||
|
@ -166,7 +179,7 @@ jobs:
|
|||
run: mv ./package/woocommerce/plugins/woocommerce/* ./code/woocommerce
|
||||
|
||||
- name: Download WooCommerce ZIP.
|
||||
uses: actions/download-artifact@v2
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: woocommerce
|
||||
path: tmp
|
||||
|
@ -177,11 +190,19 @@ jobs:
|
|||
unzip woocommerce.zip -d woocommerce
|
||||
mv woocommerce/woocommerce/* ../package/woocommerce/plugins/woocommerce/
|
||||
|
||||
- name: Cache modules
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.pnpm-store
|
||||
key: ${{ runner.os }}-npm-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
|
||||
- name: Install PNPM
|
||||
run: npm install -g pnpm
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: package/woocommerce
|
||||
run: |
|
||||
npm install -g pnpm
|
||||
pnpm install
|
||||
run: pnpm install
|
||||
|
||||
- name: Workaround to use initialization file with prepopulated data.
|
||||
working-directory: package/woocommerce/plugins/woocommerce/tests/e2e/docker
|
||||
|
@ -190,7 +211,7 @@ jobs:
|
|||
|
||||
- name: Load docker images and start containers.
|
||||
working-directory: package/woocommerce/plugins/woocommerce
|
||||
run: pnpx wc-e2e docker:up
|
||||
run: pnpm exec wc-e2e docker:up
|
||||
|
||||
- name: Install k6
|
||||
run: |
|
||||
|
|
|
@ -4,7 +4,9 @@ on:
|
|||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: plugins/woocommerce
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
jobs:
|
||||
test:
|
||||
name: Code coverage (PHP 7.4, WP Latest)
|
||||
|
@ -19,13 +21,8 @@ jobs:
|
|||
- 3306:3306
|
||||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
|
||||
steps:
|
||||
- name: Cancel Previous Runs
|
||||
uses: styfle/cancel-workflow-action@0.7.0
|
||||
with:
|
||||
access_token: ${{ github.token }}
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 100
|
||||
|
||||
|
@ -42,24 +39,27 @@ jobs:
|
|||
php --version
|
||||
composer --version
|
||||
|
||||
- name: Get cached composer directories
|
||||
uses: actions/cache@v2
|
||||
- name: Get cached composer and pnpm directories
|
||||
uses: actions/cache@v3
|
||||
id: cache-deps
|
||||
with:
|
||||
path: |
|
||||
./packages
|
||||
./vendor
|
||||
key: ${{ runner.os }}-${{ hashFiles('./composer.lock') }}
|
||||
~/.pnpm-store
|
||||
plugins/woocommerce/packages
|
||||
plugins/woocommerce/vendor
|
||||
key: ${{ runner.os }}-npm-composer-${{ hashFiles('plugins/woocommerce/composer.lock', '**/pnpm-lock.yaml') }}
|
||||
|
||||
- name: Install PNPM and install dependencies
|
||||
run: |
|
||||
npm install -g pnpm
|
||||
pnpm install
|
||||
- name: Install PNPM
|
||||
run: npm install -g pnpm
|
||||
|
||||
- name: Setup and install composer
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Install Composer dependencies
|
||||
if: steps.cache-deps.outputs.cache-hit != 'true'
|
||||
run: pnpm nx composer-install woocommerce
|
||||
|
||||
- name: Build Admin feature config
|
||||
working-directory: ./
|
||||
run: |
|
||||
pnpm nx build:feature-config woocommerce
|
||||
|
||||
|
|
|
@ -4,20 +4,17 @@ on:
|
|||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: plugins/woocommerce
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
jobs:
|
||||
test:
|
||||
name: Code sniff (PHP 7.4, WP Latest)
|
||||
timeout-minutes: 15
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Cancel Previous Runs
|
||||
uses: styfle/cancel-workflow-action@0.7.0
|
||||
with:
|
||||
access_token: ${{ github.token }}
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 100
|
||||
|
||||
|
@ -32,25 +29,31 @@ jobs:
|
|||
php --version
|
||||
composer --version
|
||||
|
||||
- name: Get cached composer directories
|
||||
uses: actions/cache@v2
|
||||
- name: Get cached composer and pnpm directories
|
||||
uses: actions/cache@v3
|
||||
id: cache-deps
|
||||
with:
|
||||
path: |
|
||||
./packages
|
||||
./vendor
|
||||
key: ${{ runner.os }}-${{ hashFiles('./composer.lock') }}
|
||||
~/.pnpm-store
|
||||
plugins/woocommerce/packages
|
||||
plugins/woocommerce/vendor
|
||||
key: ${{ runner.os }}-npm-composer-${{ hashFiles('plugins/woocommerce/composer.lock', '**/pnpm-lock.yaml') }}
|
||||
|
||||
- name: Install PNPM and install dependencies
|
||||
run: |
|
||||
npm install -g pnpm
|
||||
pnpm install
|
||||
- name: Install PNPM
|
||||
run: npm install -g pnpm
|
||||
|
||||
- name: Setup and install composer
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Install Composer dependencies
|
||||
if: steps.cache-deps.outputs.cache-hit != 'true'
|
||||
run: pnpm nx composer-install woocommerce
|
||||
|
||||
- name: Run code sniff
|
||||
continue-on-error: true
|
||||
working-directory: plugins/woocommerce
|
||||
run: ./tests/bin/phpcs.sh "${{ github.event.pull_request.base.sha }}" "${{ github.event.after }}"
|
||||
|
||||
- name: Show PHPCS results in PR
|
||||
working-directory: plugins/woocommerce
|
||||
run: cs2pr ./phpcs-report.xml
|
||||
|
|
|
@ -6,26 +6,34 @@ on:
|
|||
- 'packages/js/**/**'
|
||||
- 'plugins/woocommerce-admin/client/**'
|
||||
- '!**.md'
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
lint-test-js:
|
||||
name: Lint and Test JS
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- name: Cancel Previous Runs
|
||||
uses: styfle/cancel-workflow-action@0.7.0
|
||||
with:
|
||||
access_token: ${{ github.token }}
|
||||
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16'
|
||||
|
||||
- name: Install PNPM and install dependencies
|
||||
run: npm install -g pnpm && pnpm install
|
||||
- name: Cache modules
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.pnpm-store
|
||||
key: ${{ runner.os }}-npm-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
|
||||
- name: Install PNPM
|
||||
run: npm install -g pnpm
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Lint
|
||||
run: |
|
||||
|
|
|
@ -4,7 +4,10 @@ on:
|
|||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: plugins/woocommerce
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: PHP ${{ matrix.php }} WP ${{ matrix.wp }}
|
||||
|
@ -32,11 +35,6 @@ jobs:
|
|||
- 3306:3306
|
||||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
|
||||
steps:
|
||||
- name: Cancel Previous Runs
|
||||
uses: styfle/cancel-workflow-action@0.7.0
|
||||
with:
|
||||
access_token: ${{ github.token }}
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
|
@ -53,21 +51,27 @@ jobs:
|
|||
php --version
|
||||
composer --version
|
||||
|
||||
- name: Get cached composer directories
|
||||
uses: actions/cache@v2
|
||||
- name: Get cached composer and pnpm directories
|
||||
uses: actions/cache@v3
|
||||
id: cache-deps
|
||||
with:
|
||||
path: |
|
||||
./packages
|
||||
./vendor
|
||||
key: ${{ runner.os }}-${{ hashFiles('./composer.lock') }}
|
||||
~/.pnpm-store
|
||||
plugins/woocommerce/packages
|
||||
plugins/woocommerce/vendor
|
||||
key: ${{ runner.os }}-npm-composer-${{ hashFiles('plugins/woocommerce/composer.lock', '**/pnpm-lock.yaml') }}
|
||||
|
||||
- name: Install PNPM
|
||||
run: npm install -g pnpm
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Install Composer dependencies
|
||||
if: steps.cache-deps.outputs.cache-hit != 'true'
|
||||
run: pnpm nx composer-install woocommerce
|
||||
|
||||
- name: Install PNPM and install dependencies
|
||||
run: |
|
||||
npm install -g pnpm
|
||||
pnpm install
|
||||
pnpm nx composer-install woocommerce
|
||||
- name: Build Admin feature config
|
||||
working-directory: ./
|
||||
run: |
|
||||
pnpm nx build:feature-config woocommerce
|
||||
|
||||
|
@ -76,6 +80,7 @@ jobs:
|
|||
if [ "$(php -r "echo version_compare(PHP_VERSION,'8.0','>=');")" ]; then
|
||||
curl -L https://github.com/woocommerce/phpunit/archive/add-compatibility-with-php8-to-phpunit-7.zip -o /tmp/phpunit-7.5-fork.zip
|
||||
unzip -d /tmp/phpunit-7.5-fork /tmp/phpunit-7.5-fork.zip
|
||||
cd plugins/woocommerce
|
||||
composer bin phpunit config --unset platform
|
||||
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
|
||||
|
@ -84,6 +89,7 @@ jobs:
|
|||
fi
|
||||
|
||||
- name: Init DB and WP
|
||||
working-directory: plugins/woocommerce
|
||||
run: ./tests/bin/install.sh woo_test root root 127.0.0.1 ${{ matrix.wp }}
|
||||
|
||||
- name: Run tests
|
||||
|
|
Loading…
Reference in New Issue