From 73ba1e591f0adfb9f30cfba93eb4f814783a762a Mon Sep 17 00:00:00 2001 From: roykho Date: Tue, 17 May 2022 06:20:23 -0700 Subject: [PATCH] Add composite install and build action --- .github/actions/install-build/action.yml | 39 ++++++++++++++++++++ .github/workflows/pr-build-and-e2e-tests.yml | 38 +++++-------------- 2 files changed, 48 insertions(+), 29 deletions(-) create mode 100644 .github/actions/install-build/action.yml diff --git a/.github/actions/install-build/action.yml b/.github/actions/install-build/action.yml new file mode 100644 index 00000000000..4f4717a1c3a --- /dev/null +++ b/.github/actions/install-build/action.yml @@ -0,0 +1,39 @@ +name: Install and Build (Composite) +description: Installs and builds WooCommerce. +inputs: + workflow_cache: + required: true + description: The workflow cache key. + workflow_name: + required: true + description: The name of the workflow. + +runs: + using: "composite" + steps: + - name: Dependency caching + uses: actions/cache@v3 + id: cache-deps + with: + path: | + ~/.pnpm-store + ~/.local/share/pnpm/store + ~/.cache/composer/files + key: ${{ runner.os }}-${{ inputs.workflow_name }}-${{ inputs.workflow_cache }}-${{ hashFiles('**/composer.lock', '**/pnpm-lock.yaml') }} + + - name: Install PNPM + run: npm install -g pnpm@^6.24.2 + + - name: Install dependencies + run: pnpm install + + - name: Install Composer dependencies + run: pnpm nx composer-install-no-dev woocommerce + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + + - name: Run build + run: pnpm nx build woocommerce diff --git a/.github/workflows/pr-build-and-e2e-tests.yml b/.github/workflows/pr-build-and-e2e-tests.yml index cffb4f22070..0296105fdfb 100644 --- a/.github/workflows/pr-build-and-e2e-tests.yml +++ b/.github/workflows/pr-build-and-e2e-tests.yml @@ -1,5 +1,8 @@ name: Run tests against PR -on: pull_request +on: + pull_request: + workflow_dispatch: + concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -9,35 +12,12 @@ jobs: name: Runs E2E tests. runs-on: ubuntu-20.04 steps: - - name: Checkout code. - uses: actions/checkout@v3 - - - name: Dependency caching - uses: actions/cache@v3 - id: cache-deps + - uses: actions/checkout@v3 + - name: Install and Build + uses: ./.github/actions/install-build with: - path: | - ~/.pnpm-store - ~/.local/share/pnpm/store - ~/.cache/composer/files - key: ${{ runner.os }}-pr-build-and-e2e-tests-${{ secrets.WORKFLOW_CACHE }}-${{ hashFiles('**/composer.lock', '**/pnpm-lock.yaml') }} - - - name: Install PNPM - run: npm install -g pnpm@^6.24.2 - - - name: Install dependencies - run: pnpm install - - - name: Install Composer dependencies - run: pnpm nx composer-install-no-dev woocommerce - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '7.4' - - - name: Run build - run: pnpm nx build woocommerce + workflow_name: pr-build-and-e2e-tests + workflow_cache: ${{ secrets.WORKFLOW_CACHE }} - name: Load docker images and start containers. working-directory: plugins/woocommerce