Skip to content

Commit

Permalink
Transform the run-qit-extension workflow into an action.
Browse files Browse the repository at this point in the history
  • Loading branch information
eason9487 committed Oct 3, 2023
1 parent a8f23ba commit d7e552e
Showing 1 changed file with 143 additions and 0 deletions.
143 changes: 143 additions & 0 deletions packages/github-actions/actions/run-qit-extension/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: Run QIT for a given extension
description: Runs QIT tests and annotates the results for a given extension.

# **What it does**: Runs a set of QIT tests for a given extension.
# **Why we have it**: To reuse across other repos, to make a full test of a single extension.

inputs:
# Basic params.
qit-partner-user:
description: 'QIT partner username'
required: true
qit-partner-secret:
description: 'QIT partner password'
required: true
github-token:
description: 'Github token to access private repos'
required: false
default: ${{ github.token }}
extension:
description: Extension to test
required: true
version:
description: |
Version to be tested: `latest`, `dev`, or `local`.
`latest` will test latest released version,
`dev` will make the action look up for an `{extension}.zip` file in the root
of the repository under the `gha-dev-build` tag,
`local` will look up for an `{extension}.zip` artifact in the current workflow.
required: true
default: 'latest'

# Customize which types to run.
test-activation:
description: 'Should activation be tested?'
default: 'true'
test-security:
description: 'Should security be tested?'
default: 'true'
test-phpstan:
description: 'Should PHPStan be tested?'
default: 'true'
test-api:
description: 'Should API be tested?'
default: 'true'
test-e2e:
description: 'Should E2E be tested?'
default: 'true'

# Advanced customization.
options:
description: 'Additional options for `qit` command, like `--optional_features=hpos`'
type: string

runs:
using: composite
steps:
- name: Prepare env variables
shell: bash
run: |
dev_build="${{ inputs.version != 'latest' && format('{0}.zip', inputs.extension) || '' }}"
echo "dev_build=$dev_build" >> $GITHUB_ENV
echo "QIT_DISABLE_ONBOARDING=yes" >> $GITHUB_ENV
- name: Download `gha-dev-build`
if: ${{ inputs.version == 'dev' }}
uses: robinraju/release-downloader@v1.8
with:
repository: "woocommerce/${{ inputs.extension }}"
tag: 'gha-dev-build'
fileName: ${{ env.dev_build }}
token: ${{ inputs.github-token }}

- name: Install QIT via composer
shell: bash
run: composer require woocommerce/qit-cli

- name: Add Partner
shell: bash
run: |
./vendor/bin/qit partner:add \
--user='${{ inputs.qit-partner-user }}' \
--application_password='${{ inputs.qit-partner-secret }}'
- name: Create results dir
shell: bash
run: mkdir -p ./qit-results/${{ inputs.extension }}

- name: Activation test
id: activation-test
if: ${{ inputs.test-activation == 'true' }}
uses: woocommerce/grow/run-qit-annotate@actions-v1.10.2-pre
with:
type: activation
extension: ${{ inputs.extension }}
extension-file: ${{ env.dev_build }}
options: ${{ inputs.options }}

- name: Security test
id: security-test
if: ${{ inputs.test-security == 'true' }}
uses: woocommerce/grow/run-qit-annotate@actions-v1.10.2-pre
with:
type: security
extension: ${{ inputs.extension }}
extension-file: ${{ env.dev_build }}
options: ${{ inputs.options }}

- name: PHPStan test
id: phpstan-test
if: ${{ inputs.test-phpstan == 'true' }}
uses: woocommerce/grow/run-qit-annotate@actions-v1.10.2-pre
with:
type: phpstan
extension: ${{ inputs.extension }}
extension-file: ${{ env.dev_build }}
options: ${{ inputs.options }}

- name: API test
id: api-test
if: ${{ inputs.test-api == 'true' }}
uses: woocommerce/grow/run-qit-annotate@actions-v1.10.2-pre
with:
type: api
extension: ${{ inputs.extension }}
extension-file: ${{ env.dev_build }}
options: ${{ inputs.options }}

- name: E2E test
id: e2e-test
if: ${{ inputs.test-e2e == 'true' }}
uses: woocommerce/grow/run-qit-annotate@actions-v1.10.2-pre
with:
type: e2e
extension: ${{ inputs.extension }}
extension-file: ${{ env.dev_build }}
options: ${{ inputs.options }}

- name: Upload results
uses: actions/upload-artifact@v1
with:
name: "qit-results-${{ inputs.extension }}"
path: ./qit-results/${{ inputs.extension }}

0 comments on commit d7e552e

Please sign in to comment.