PMM-7 Check target branch when checking out UI tests #2805
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: UI Tests | |
on: | |
pull_request: | |
jobs: | |
test: | |
name: Run UI tests | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
node-version: [18.x] | |
timeout-minutes: 50 | |
steps: | |
- name: Checkout Grafana code | |
uses: percona-platform/checkout@v2 | |
with: | |
path: ./grafana | |
- name: Run with Node ${{ matrix.node-version }} | |
uses: percona-platform/setup-node@v2 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Get Yarn cache directory | |
id: yarn-cache-dir-path | |
working-directory: ./grafana | |
run: echo "::set-output name=dir::$(yarn config get cacheFolder)" | |
- name: Use Yarn cache | |
uses: percona-platform/cache@v2 | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }} | |
- name: Clean Yarn cache | |
run: yarn cache clean | |
- name: Install dependencies for Grafana | |
working-directory: ./grafana | |
run: YARN_CHECKSUM_BEHAVIOR=update yarn install --immutable | |
- name: Start Environment | |
working-directory: ./grafana | |
run: make run-local-env | |
- name: Checkout UI tests in ${{ github.head_ref }} branch | |
uses: percona-platform/checkout@v2 | |
continue-on-error: true | |
id: branch_checkout | |
with: | |
token: ${{ secrets.ROBOT_TOKEN }} | |
ref: ${{ github.head_ref }} | |
repository: percona/pmm-ui-tests | |
path: ./pmm-ui-tests | |
- name: Checkout UI tests in ${{ github.base_ref }} branch | |
uses: percona-platform/checkout@v2 | |
if: ${{ steps.branch_checkout.outcome != 'success' }} | |
continue-on-error: true | |
id: target_branch_checkout | |
with: | |
token: ${{ secrets.ROBOT_TOKEN }} | |
ref: ${{ github.base_ref }} | |
repository: percona/pmm-ui-tests | |
path: ./pmm-ui-tests | |
- name: Checkout UI tests in main branch | |
uses: percona-platform/checkout@v2 | |
if: ${{ steps.branch_checkout.outcome != 'success' && steps.target_branch_checkout.outcome != 'success' }} | |
with: | |
token: ${{ secrets.ROBOT_TOKEN }} | |
ref: main | |
repository: percona/pmm-ui-tests | |
path: ./pmm-ui-tests | |
- name: Install dependencies for UI tests | |
working-directory: ./pmm-ui-tests | |
run: npm install | |
- name: install playwright | |
working-directory: ./pmm-ui-tests | |
run: npx playwright install | |
- name: Run UI tests | |
working-directory: ./pmm-ui-tests | |
run: npm run e2e:grafana-pr | |
- name: Attaching artifacts | |
if: ${{ always() }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ui-tests-output | |
path: ./pmm-ui-tests/tests/output |