180 lines
7.8 KiB
YAML
180 lines
7.8 KiB
YAML
name: Run tests against trunk after PR merge
|
|
on:
|
|
workflow_dispatch:
|
|
#pull_request:
|
|
#types:
|
|
#- closed
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
|
cancel-in-progress: true
|
|
permissions: {}
|
|
|
|
jobs:
|
|
api:
|
|
name: Run API tests
|
|
runs-on: ubuntu-latest
|
|
if: (github.event.pull_request.merged == true) && (github.event.pull_request.base.ref == 'trunk')
|
|
permissions:
|
|
contents: read
|
|
env:
|
|
ALLURE_RESULTS_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/api-core-tests/test-results/allure-results
|
|
ALLURE_REPORT_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/api-core-tests/test-results/allure-report
|
|
ARTIFACT_NAME: api-pr-merge-${{ github.event.pull_request.number }}-run-${{ github.run_number }}
|
|
steps:
|
|
- name: Checkout merge commit on trunk
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event.pull_request.merge_commit_sha }}
|
|
|
|
- name: Setup WooCommerce Monorepo
|
|
uses: ./.github/actions/setup-woocommerce-monorepo
|
|
with:
|
|
install: '@woocommerce/plugin-woocommerce...'
|
|
build: '@woocommerce/plugin-woocommerce'
|
|
|
|
- name: Setup local test environment
|
|
uses: ./.github/actions/tests/setup-local-test-environment
|
|
with:
|
|
test-type: api
|
|
|
|
- name: Run API tests
|
|
id: run-api-composite-action
|
|
uses: ./.github/actions/tests/run-api-tests
|
|
with:
|
|
report-name: ${{ env.ARTIFACT_NAME }}
|
|
|
|
- name: Upload Allure files to bucket
|
|
if: success() || ( failure() && steps.run-api-composite-action.conclusion == 'failure' )
|
|
uses: ./.github/actions/tests/upload-allure-files-to-bucket
|
|
with:
|
|
aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }}
|
|
aws-region: ${{ secrets.REPORTS_AWS_REGION }}
|
|
aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }}
|
|
artifact-name: ${{ env.ARTIFACT_NAME }}
|
|
s3-bucket: ${{ secrets.REPORTS_BUCKET }}
|
|
|
|
- name: Publish Allure report
|
|
if: success() || ( failure() && steps.run-api-composite-action.conclusion == 'failure' )
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.REPORTS_TOKEN }}
|
|
run: |
|
|
gh workflow run publish-test-reports-trunk-merge.yml \
|
|
-f run_id=${{ github.run_id }} \
|
|
-f artifact=${{ env.ARTIFACT_NAME }} \
|
|
-f pr_number=${{ github.event.pull_request.number }} \
|
|
-f test_type="api" \
|
|
--repo woocommerce/woocommerce-test-reports
|
|
|
|
- name: Send Slack alert on test failure
|
|
if: failure() && steps.run-api-composite-action.conclusion == 'failure'
|
|
uses: ./.github/actions/tests/slack-alert-on-pr-merge
|
|
with:
|
|
slack-bot-token: ${{ secrets.E2E_SLACK_TOKEN }}
|
|
channel-id: ${{ secrets.E2E_TRUNK_SLACK_CHANNEL }}
|
|
test-type: API
|
|
|
|
e2e:
|
|
name: Run E2E tests
|
|
needs: [api]
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
env:
|
|
ALLURE_RESULTS_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/e2e-pw/test-results/allure-results
|
|
ALLURE_REPORT_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/e2e-pw/test-results/allure-report
|
|
ARTIFACT_NAME: e2e-pr-merge-${{ github.event.pull_request.number }}-run-${{ github.run_number }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event.pull_request.merge_commit_sha }}
|
|
|
|
- name: Setup WooCommerce Monorepo
|
|
uses: ./.github/actions/setup-woocommerce-monorepo
|
|
with:
|
|
install: '@woocommerce/plugin-woocommerce...'
|
|
build: '@woocommerce/plugin-woocommerce'
|
|
|
|
- name: Setup local test environment
|
|
uses: ./.github/actions/tests/setup-local-test-environment
|
|
with:
|
|
test-type: e2e
|
|
|
|
- name: Run E2E tests
|
|
id: run-e2e-composite-action
|
|
timeout-minutes: 60
|
|
uses: ./.github/actions/tests/run-e2e-tests
|
|
env:
|
|
E2E_MAX_FAILURES: 15
|
|
with:
|
|
report-name: ${{ env.ARTIFACT_NAME }}
|
|
|
|
- name: Upload Allure files to bucket
|
|
if: success() || ( failure() && steps.run-e2e-composite-action.conclusion == 'failure' )
|
|
uses: ./.github/actions/tests/upload-allure-files-to-bucket
|
|
with:
|
|
aws-access-key-id: ${{ secrets.REPORTS_AWS_ACCESS_KEY_ID }}
|
|
aws-region: ${{ secrets.REPORTS_AWS_REGION }}
|
|
aws-secret-access-key: ${{ secrets.REPORTS_AWS_SECRET_ACCESS_KEY }}
|
|
artifact-name: ${{ env.ARTIFACT_NAME }}
|
|
s3-bucket: ${{ secrets.REPORTS_BUCKET }}
|
|
include-allure-results: false
|
|
|
|
- name: Publish Allure report
|
|
if: success() || ( failure() && steps.run-e2e-composite-action.conclusion == 'failure' )
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.REPORTS_TOKEN }}
|
|
run: |
|
|
gh workflow run publish-test-reports-trunk-merge.yml \
|
|
-f run_id=${{ github.run_id }} \
|
|
-f artifact=${{ env.ARTIFACT_NAME }} \
|
|
-f pr_number=${{ github.event.pull_request.number }} \
|
|
-f test_type="e2e" \
|
|
--repo woocommerce/woocommerce-test-reports
|
|
|
|
- name: Send Slack alert on test failure
|
|
if: failure() && steps.run-e2e-composite-action.conclusion == 'failure'
|
|
uses: ./.github/actions/tests/slack-alert-on-pr-merge
|
|
with:
|
|
slack-bot-token: ${{ secrets.E2E_SLACK_TOKEN }}
|
|
channel-id: ${{ secrets.E2E_TRUNK_SLACK_CHANNEL }}
|
|
test-type: E2E
|
|
|
|
k6:
|
|
name: Runs k6 Performance tests
|
|
if: (github.event.pull_request.user.login != 'github-actions[bot]') && (github.event.pull_request.merged == true) && (github.event.pull_request.base.ref == 'trunk')
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup WooCommerce Monorepo
|
|
uses: ./.github/actions/setup-woocommerce-monorepo
|
|
with:
|
|
install: '@woocommerce/plugin-woocommerce...'
|
|
build: '@woocommerce/plugin-woocommerce'
|
|
|
|
- name: Load docker images and start containers.
|
|
working-directory: plugins/woocommerce
|
|
env:
|
|
ENABLE_HPOS: 0
|
|
run: |
|
|
pnpm --filter=@woocommerce/plugin-woocommerce env:dev
|
|
pnpm --filter=@woocommerce/plugin-woocommerce env:performance-init
|
|
|
|
- name: Install k6
|
|
run: |
|
|
curl https://github.com/grafana/k6/releases/download/v0.33.0/k6-v0.33.0-linux-amd64.tar.gz -L | tar xvz --strip-components 1
|
|
|
|
- name: Run k6 tests
|
|
run: |
|
|
./k6 run plugins/woocommerce/tests/performance/tests/gh-action-pr-requests.js
|
|
|
|
- name: Send Slack alert on test failure
|
|
if: failure() && steps.run-k6-composite-action.conclusion == 'failure'
|
|
uses: ./.github/actions/tests/slack-alert-on-pr-merge
|
|
with:
|
|
slack-bot-token: ${{ secrets.E2E_SLACK_TOKEN }}
|
|
channel-id: ${{ secrets.E2E_TRUNK_SLACK_CHANNEL }}
|
|
test-type: k6
|