mattermost-desktop/.github/workflows/e2e-functional.yml

322 lines
12 KiB
YAML
Raw Normal View History

name: Electron Playwright Tests
on:
2024-01-17 00:43:04 -08:00
workflow_call:
inputs:
tag:
description: "Reference tag of the nightly build"
required: true
type: string
push:
branches:
- master
pull_request:
types:
- labeled
2024-01-17 00:43:04 -08:00
workflow_dispatch:
inputs:
version_name:
type: string
description: 'Desktop Version name eg: 5.6'
required: true
job_name:
type: choice
description: 'Job name'
required: true
default: 'e2e-linux'
options:
- 'e2e-linux'
- 'e2e-macos'
- 'e2e-windows'
- 'All'
env:
AWS_S3_BUCKET: "mattermost-cypress-report"
2024-02-08 03:06:59 -08:00
BRANCH: ${{ github.head_ref || github.ref_name }}
2024-02-07 09:36:35 -08:00
BUILD_TAG: ${{ github.sha }}
JIRA_PROJECT_KEY: 'MM'
2023-12-13 00:54:16 -08:00
MM_TEST_SERVER_URL: ${{ secrets.MM_DESKTOP_E2E_SERVER_URL }}
MM_TEST_USER_NAME: ${{ secrets.MM_DESKTOP_E2E_USER_NAME }}
MM_TEST_PASSWORD: ${{ secrets.MM_DESKTOP_E2E_USER_CREDENTIALS }}
2024-02-08 12:38:26 -08:00
PULL_REQUEST: "https://github.com/mattermost/desktop/pull/${{ github.event.number }}"
ZEPHYR_ENVIRONMENT_NAME: 'Desktop app'
2024-02-08 14:49:21 -08:00
ZEPHYR_FOLDER_ID: "12413253"
TEST_CYCLE_LINK_PREFIX: ${{ secrets.MM_DESKTOP_E2E_TEST_CYCLE_LINK_PREFIX }}
AWS_ACCESS_KEY_ID: ${{ secrets.MM_DESKTOP_E2E_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.MM_DESKTOP_E2E_AWS_SECRET_ACCESS_KEY }}
2023-12-13 00:54:16 -08:00
AWS_REGION: "us-east-1"
WEBHOOK_URL: ${{ secrets.MM_DESKTOP_E2E_WEBHOOK_URL }}
ZEPHYR_API_KEY: ${{ secrets.MM_DESKTOP_E2E_ZEPHYR_API_KEY }}
jobs:
e2e-linux:
2024-01-17 00:43:04 -08:00
if: ${{
(
2024-01-26 01:18:12 -08:00
(inputs.job_name == 'e2e-linux' || inputs.job_name == 'All')
2024-02-07 07:34:10 -08:00
&&
2024-01-17 00:43:04 -08:00
github.event_name == 'workflow_dispatch'
) ||
(
2024-02-08 13:27:53 -08:00
github.event_name == 'push' && github.ref == 'refs/heads/master'
2024-01-17 00:43:04 -08:00
) ||
(
github.event_name == 'pull_request' &&
github.event.pull_request.labels &&
contains(github.event.pull_request.labels.*.name, 'Run Desktop E2E Tests')
) ||
2024-01-26 00:48:16 -08:00
(
2024-02-07 07:34:10 -08:00
(inputs.tag != '')
2024-01-26 00:48:16 -08:00
)
2024-01-17 00:43:04 -08:00
}}
runs-on: ubuntu-latest
steps:
- name: ci/checkout-repo
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: ci/setup-node
2024-02-08 12:38:26 -08:00
uses: actions/setup-node@v4
with:
node-version-file: "package.json"
cache: "npm"
cache-dependency-path: package-lock.json
- name: Install dependencies
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 0
run: |
wget -qO - https://download.opensuse.org/repositories/Emulators:/Wine:/Debian/xUbuntu_22.04/Release.key | sudo apt-key add -
wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.20.1/yq_linux_amd64 && chmod a+x /usr/local/bin/yq
sudo apt-get update || true && sudo apt-get install -y ca-certificates libxtst-dev libpng++-dev gcc-aarch64-linux-gnu g++-aarch64-linux-gnu jq icnsutils graphicsmagick tzdata
npm ci
2024-02-16 00:24:27 -08:00
npm install -g node-gyp
npm i robotjs
npx electron-rebuild --platform=linux -f -t prod,optional,dev -w robotjs
- name: Set Environment Variables
run: |
2024-01-28 09:27:38 -08:00
if [ "${{ github.event_name }}" == "pull_request" ]; then
2024-01-17 00:43:04 -08:00
echo "BUILD_SUFFIX=desktop-pr" >> $GITHUB_ENV
echo "TYPE=PR" >> $GITHUB_ENV
elif [ "${{ github.event_name }}" == "release" ]; then
echo "BUILD_SUFFIX=desktop-release" >> $GITHUB_ENV
2024-01-17 00:43:04 -08:00
echo "TYPE=RELEASE" >> $GITHUB_ENV
echo "ZEPHYR_ENABLE=true" >> $GITHUB_ENV
2024-01-17 00:43:04 -08:00
2024-02-08 02:07:40 -08:00
elif [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ "${{ inputs.tag }}" == "" ]; then
2024-01-17 00:43:04 -08:00
echo "BUILD_SUFFIX=desktop-manual-trigger" >> $GITHUB_ENV
echo "TYPE=MANUAL" >> $GITHUB_ENV
2024-02-08 13:27:53 -08:00
elif [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/master" ]; then
2024-01-17 00:43:04 -08:00
echo "BUILD_SUFFIX=desktop-master-push" >> $GITHUB_ENV
2024-02-08 02:07:40 -08:00
echo "TYPE=MASTER" >> $GITHUB_ENV
2024-01-17 00:43:04 -08:00
echo "ZEPHYR_ENABLE=true" >> $GITHUB_ENV
2024-02-07 07:34:10 -08:00
elif [ "${{ inputs.tag }}" != "" ]; then
2024-01-17 00:43:04 -08:00
echo "BUILD_SUFFIX=desktop-nightly" >> $GITHUB_ENV
echo "TYPE=NIGHTLY" >> $GITHUB_ENV
echo "ZEPHYR_ENABLE=true" >> $GITHUB_ENV
fi
2024-02-08 15:15:25 -08:00
- name: Set Build ID
run: echo "BUILD_ID=${{ github.run_id }}-${{ env.BUILD_SUFFIX }}" >> $GITHUB_ENV
- name: Run Playwright tests (Ubuntu OS)
run: |
export DISPLAY=:99
Xvfb $DISPLAY -screen 0 1024x768x24 > /dev/null 2>&1 &
npm run test:e2e || true # making job pass even if the tests fail due to flakyness
npm run test:e2e:send-report
2024-01-17 00:43:04 -08:00
e2e-macos:
2024-01-17 00:43:04 -08:00
if: ${{
(
2024-01-26 01:18:12 -08:00
(inputs.job_name == 'e2e-macos' || inputs.job_name == 'All')
2024-02-07 07:34:10 -08:00
&&
2024-01-17 00:43:04 -08:00
github.event_name == 'workflow_dispatch'
) ||
(
2024-02-08 13:27:53 -08:00
github.event_name == 'push' && github.ref == 'refs/heads/master'
2024-01-17 00:43:04 -08:00
) ||
(
github.event_name == 'pull_request' &&
github.event.pull_request.labels &&
contains(github.event.pull_request.labels.*.name, 'Run Desktop E2E Tests')
) ||
2024-01-26 00:48:16 -08:00
(
2024-02-07 07:34:10 -08:00
(inputs.tag != '')
2024-01-26 00:48:16 -08:00
)
2024-01-17 00:43:04 -08:00
}}
2023-12-13 00:54:16 -08:00
runs-on: macos-13
steps:
- name: ci/checkout-repo
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: ci/setup-node
2024-02-08 12:38:26 -08:00
uses: actions/setup-node@v4
with:
node-version-file: "package.json"
cache: "npm"
cache-dependency-path: package-lock.json
2024-01-17 00:43:04 -08:00
- name: Cache Electron Headers
uses: actions/cache@v3
with:
2024-01-17 00:43:04 -08:00
path: |
~/.electron
~/.cache/electron
key: electron-headers-${{ runner.os }}-${{ hashFiles('**/*.gyp') }}
2023-12-13 00:54:16 -08:00
- name: Set up Python
2024-01-17 00:43:04 -08:00
uses: actions/setup-python@v5
2023-12-13 00:54:16 -08:00
with:
2024-01-17 00:43:04 -08:00
python-version: '3.10'
2023-12-13 00:54:16 -08:00
- name: ci/install-dependencies
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: |
2024-02-16 00:24:27 -08:00
npm cache clean --force
jq '.mac.target=["zip"]' electron-builder.json | jq '.mac.gatekeeperAssess=false' > /tmp/electron-builder.json && cp /tmp/electron-builder.json .
npm ci
2023-12-13 00:54:16 -08:00
npm install -g node-gyp
npm i robotjs
2024-02-16 00:24:27 -08:00
npx electron-rebuild --platform=darwin -f -t prod,optional,dev -w robotjs
- name: Set Environment Variables
run: |
2024-01-28 09:27:38 -08:00
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "BUILD_SUFFIX=desktop-pr" >> $GITHUB_ENV
2024-01-17 00:43:04 -08:00
echo "TYPE=PR" >> $GITHUB_ENV
elif [ "${{ github.event_name }}" == "release" ]; then
echo "BUILD_SUFFIX=desktop-release" >> $GITHUB_ENV
2024-01-17 00:43:04 -08:00
echo "TYPE=RELEASE" >> $GITHUB_ENV
echo "ZEPHYR_ENABLE=true" >> $GITHUB_ENV
2024-02-08 02:07:40 -08:00
elif [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ "${{ inputs.tag }}" == "" ]; then
2024-01-17 00:43:04 -08:00
echo "BUILD_SUFFIX=desktop-manual-trigger" >> $GITHUB_ENV
echo "TYPE=MANUAL" >> $GITHUB_ENV
2024-02-08 13:27:53 -08:00
elif [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/master" ]; then
2024-01-17 00:43:04 -08:00
echo "BUILD_SUFFIX=desktop-master-push" >> $GITHUB_ENV
2024-02-08 02:07:40 -08:00
echo "TYPE=MASTER" >> $GITHUB_ENV
echo "ZEPHYR_ENABLE=true" >> $GITHUB_ENV
2024-01-17 00:43:04 -08:00
2024-02-07 07:34:10 -08:00
elif [ "${{ inputs.tag }}" != "" ]; then
echo "BUILD_SUFFIX=desktop-nightly" >> $GITHUB_ENV
2024-01-17 00:43:04 -08:00
echo "TYPE=NIGHTLY" >> $GITHUB_ENV
echo "ZEPHYR_ENABLE=true" >> $GITHUB_ENV
fi
2024-02-08 15:15:25 -08:00
- name: Set Build ID
run: echo "BUILD_ID=${{ github.run_id }}-${{ env.BUILD_SUFFIX }}" >> $GITHUB_ENV
- name: Run Playwright tests (macOS)
run: |
npm run test:e2e || true # making job pass even if the tests fail due to flakyness
npm run test:e2e:send-report
e2e-windows:
2024-01-17 00:43:04 -08:00
if: ${{
(
2024-01-26 01:18:12 -08:00
(inputs.job_name == 'e2e-windows' || inputs.job_name == 'All')
2024-02-07 07:34:10 -08:00
&&
2024-01-17 00:43:04 -08:00
github.event_name == 'workflow_dispatch'
) ||
(
2024-02-08 13:27:53 -08:00
github.event_name == 'push' && github.ref == 'refs/heads/master'
2024-01-17 00:43:04 -08:00
) ||
(
github.event_name == 'pull_request' &&
github.event.pull_request.labels &&
contains(github.event.pull_request.labels.*.name, 'Run Desktop E2E Tests')
) ||
2024-01-26 00:48:16 -08:00
(
2024-02-07 07:34:10 -08:00
(inputs.tag != '')
2024-01-26 00:48:16 -08:00
)
2024-01-17 00:43:04 -08:00
}}
2023-12-13 00:54:16 -08:00
runs-on: windows-2022
steps:
- name: ci/checkout-repo
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: ci/setup-node
2024-02-08 12:38:26 -08:00
uses: actions/setup-node@v4
with:
node-version-file: "package.json"
cache: "npm"
cache-dependency-path: package-lock.json
- name: ci/cache-node-modules
id: cache-node-modules
uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
with:
path: node_modules
key: ${{ runner.os }}-build-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-node-modules
${{ runner.os }}-build-
${{ runner.os }}-
- name: ci/install-node-gyp
if: steps.cache-node-modules.outputs.cache-hit != 'true'
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: |
choco install yq --version 4.15.1 -y
npm i -g node-gyp
node-gyp install
node-gyp install --devdir="C:\Users\runneradmin\.electron-gyp" --target=$(jq -r .devDependencies.electron package.json) --dist-url="https://electronjs.org/headers"
node-gyp install --devdir="C:\Users\runneradmin\.electron-gyp" --target=$(jq -r .devDependencies.electron package.json) --dist-url="https://electronjs.org/headers" --arch arm64
node-gyp install --devdir="C:\Users\runneradmin\.electron-gyp" --target=$(jq -r .devDependencies.electron package.json) --dist-url="https://electronjs.org/headers" --arch ia32
2023-12-13 00:54:16 -08:00
npm ci --openssl_fips=''
2024-02-16 00:24:27 -08:00
npm i robotjs
npx electron-rebuild --platform=win32 -f -t prod,optional,dev -w robotjs
- name: Set Environment Variables
shell: bash
run: |
2024-01-28 09:27:38 -08:00
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "BUILD_SUFFIX=desktop-pr" >> $GITHUB_ENV
2024-01-17 00:43:04 -08:00
echo "TYPE=PR" >> $GITHUB_ENV
elif [ "${{ github.event_name }}" == "release" ]; then
echo "BUILD_SUFFIX=desktop-release" >> $GITHUB_ENV
2024-01-17 00:43:04 -08:00
echo "TYPE=RELEASE" >> $GITHUB_ENV
echo "ZEPHYR_ENABLE=true" >> $GITHUB_ENV
2024-01-17 00:43:04 -08:00
2024-02-08 02:07:40 -08:00
elif [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ "${{ inputs.tag }}" == "" ]; then
2024-01-17 00:43:04 -08:00
echo "BUILD_SUFFIX=desktop-manual-trigger" >> $GITHUB_ENV
echo "TYPE=MANUAL" >> $GITHUB_ENV
2024-02-08 13:27:53 -08:00
elif [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/master" ]; then
2024-01-17 00:43:04 -08:00
echo "TYPE=MASTER" >> $GITHUB_ENV
echo "BUILD_SUFFIX=desktop-master-push" >> $GITHUB_ENV
echo "ZEPHYR_ENABLE=true" >> $GITHUB_ENV
2024-02-07 07:34:10 -08:00
elif [ "${{ inputs.tag }}" != "" ]; then
2024-01-17 00:43:04 -08:00
echo "TYPE=NIGHTLY" >> $GITHUB_ENV
2024-02-08 02:07:40 -08:00
echo "BUILD_SUFFIX=desktop-nightly" >> $GITHUB_ENV
2024-01-17 00:43:04 -08:00
echo "ZEPHYR_ENABLE=true" >> $GITHUB_ENV
fi
2024-02-08 14:05:37 -08:00
2024-02-08 15:15:25 -08:00
- name: Set Build ID
run: echo "BUILD_ID=${{ github.run_id }}-${{ env.BUILD_SUFFIX }}" >> $GITHUB_ENV
- name: Run Playwright tests (Windows OS)
run: |
npm run test:e2e || true
npm run test:e2e:send-report
shell: bash
2023-12-13 00:54:16 -08:00
e2e-remove-label:
2024-01-17 00:43:04 -08:00
if: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'Run Desktop E2E Tests') }}
2023-12-13 00:54:16 -08:00
needs: [e2e-linux, e2e-macos, e2e-windows]
runs-on: ubuntu-latest
steps:
- name: Remove "Run Desktop E2E Tests" label
uses: actions-ecosystem/action-remove-labels@v1
with:
labels: |
Run Desktop E2E Tests