2021-01-21 07:39:19 +00:00
|
|
|
name: Build zip for PR
|
|
|
|
on:
|
|
|
|
pull_request
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
name: Build zip for PR
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v2
|
2021-01-22 07:23:07 +00:00
|
|
|
|
2021-01-21 07:39:19 +00:00
|
|
|
- name: Build
|
|
|
|
id: build
|
|
|
|
uses: woocommerce/action-build@v2
|
2021-01-22 07:23:07 +00:00
|
|
|
|
2021-01-21 07:39:19 +00:00
|
|
|
- name: Upload PR zip
|
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
2021-01-22 07:23:07 +00:00
|
|
|
name: woocommerce
|
2021-01-21 07:39:19 +00:00
|
|
|
path: ${{ steps.build.outputs.zip_path }}
|
|
|
|
retention-days: 7
|
2021-01-22 07:23:07 +00:00
|
|
|
|
2021-01-22 01:51:15 +00:00
|
|
|
- name: Add comment
|
|
|
|
uses: actions/github-script@v3
|
2021-02-09 10:50:00 +00:00
|
|
|
if: "woocommerce" == {{ github.repository_owner }}
|
2021-01-22 01:51:15 +00:00
|
|
|
with:
|
|
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
script: |
|
|
|
|
github.issues.createComment({
|
|
|
|
issue_number: context.issue.number,
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
2021-01-22 03:18:07 +00:00
|
|
|
body: ':package: Artifacts ready for [download](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})!'
|
2021-01-22 01:51:15 +00:00
|
|
|
})
|
2021-01-22 07:23:07 +00:00
|
|
|
|
|
|
|
e2e-tests-cache:
|
|
|
|
name: Set e2e caches for running tests
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout code.
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Load Node.js.
|
|
|
|
uses: actions/setup-node@v2
|
|
|
|
with:
|
|
|
|
node-version: '12'
|
|
|
|
|
|
|
|
# From https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#using-the-cache-action
|
|
|
|
- name: Cache node modules
|
|
|
|
uses: actions/cache@v2
|
2021-01-29 11:15:14 +00:00
|
|
|
id: cache_node_modules
|
2021-01-22 07:23:07 +00:00
|
|
|
env:
|
|
|
|
cache-name: cache-node-modules
|
|
|
|
with:
|
|
|
|
path: ./node_modules
|
|
|
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
2021-01-29 11:49:29 +00:00
|
|
|
|
2021-01-22 07:23:07 +00:00
|
|
|
- name: Run npm install, and cache if they aren't.
|
|
|
|
run: npm install
|
|
|
|
|
|
|
|
e2e-tests-run:
|
|
|
|
name: Runs E2E tests.
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: [ build, e2e-tests-cache ]
|
|
|
|
steps:
|
|
|
|
|
|
|
|
- name: Create dirs.
|
|
|
|
run: |
|
|
|
|
mkdir -p code/woocommerce
|
|
|
|
mkdir -p package/woocommerce
|
|
|
|
mkdir -p tmp/woocommerce
|
2021-01-29 11:49:29 +00:00
|
|
|
mkdir -p node_modules
|
2021-01-22 07:23:07 +00:00
|
|
|
|
|
|
|
- name: Checkout code.
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
path: package/woocommerce
|
|
|
|
|
|
|
|
# From https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#using-the-cache-action
|
|
|
|
- name: Cache node modules
|
|
|
|
uses: actions/cache@v2
|
2021-01-29 11:02:34 +00:00
|
|
|
id: cache_node_modules
|
2021-01-22 07:23:07 +00:00
|
|
|
env:
|
|
|
|
cache-name: cache-node-modules
|
|
|
|
with:
|
|
|
|
path: ./node_modules
|
|
|
|
key: ${{ runner.os }}-build-${{ hashFiles('package-lock.json') }}
|
2021-01-29 11:49:29 +00:00
|
|
|
restore-keys: ${{ runner.os }}-build-${{ env.cache-name }}-
|
2021-01-22 07:23:07 +00:00
|
|
|
|
2021-01-29 11:02:34 +00:00
|
|
|
- name: Restore node modules from cache, if available.
|
|
|
|
run: mv ./node_modules package/woocommerce/node_modules
|
|
|
|
|
|
|
|
- name: Run npm install.
|
2021-01-22 07:23:07 +00:00
|
|
|
working-directory: package/woocommerce
|
|
|
|
run: npm install
|
|
|
|
|
|
|
|
- name: Load docker images and start containers.
|
|
|
|
working-directory: package/woocommerce
|
|
|
|
run: npx wc-e2e docker:up
|
|
|
|
|
|
|
|
- name: Move current directory to code. We will install zip file in this dir later.
|
|
|
|
run: mv ./package/woocommerce/* ./code/woocommerce
|
|
|
|
|
|
|
|
- name: Download WooCommerce ZIP.
|
|
|
|
uses: actions/download-artifact@v2
|
|
|
|
with:
|
|
|
|
name: woocommerce
|
|
|
|
path: tmp
|
|
|
|
|
|
|
|
- name: Extract and replace WooCommerce zip.
|
|
|
|
working-directory: tmp
|
|
|
|
run: |
|
|
|
|
unzip woocommerce.zip -d woocommerce
|
|
|
|
mv woocommerce/woocommerce/* ../package/woocommerce/
|
|
|
|
|
|
|
|
- name: Run tests command.
|
|
|
|
working-directory: code/woocommerce
|
|
|
|
run: npx wc-e2e test:e2e
|