Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(e2e): initial implementation #541

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
"plugin:react/jsx-runtime",
"prettier"
],
"plugins": [
"unused-imports",
"react-native"
],
"plugins": ["unused-imports", "react-native"],
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
Expand All @@ -20,6 +17,11 @@
"react-native/no-single-element-style-arrays": 2
},
"overrides": [
{
"files": ["./tests/e2e/*.ts"],
"plugins": ["wdio"],
"extends": ["eslint:recommended", "plugin:wdio/recommended"]
},
{
"files": ["*.ts", "*.tsx"],
"rules": {
Expand All @@ -39,9 +41,12 @@
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-use-before-define": "off",
"no-console": ["error", {
"allow": ["warn", "error", "debug"]
}],
"no-console": [
"error",
{
"allow": ["warn", "error", "debug"]
}
],
"react/jsx-curly-brace-presence": "error",
"react/jsx-no-useless-fragment": "error"
}
Expand Down
98 changes: 98 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Appium CI

on:
push:
branches:
- main
workflow_dispatch:
inputs:
tests_to_run:
type: string
description: 'Tests to run (e.g., "place teaching_page/course")'

env:
STUDENTID_TEST: ${{secrets.STUDENTID_TEST}}
PASSWORD_TEST: ${{secrets.PASSWORD_TEST}}
TOKEN: ${{secrets.TOKEN}}
PACKAGE_NAME: ${{vars.PACKAGE_NAME}}
LOCAL: ${{vars.LOCAL}}
USE_PLAYSTORE: ${{vars.USE_PLAYSTORE}}

jobs:
tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: "./tests/e2e"


steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get apk from polito students repo
run: |
wget https://github.com/polito/students-app/releases/download/v1.6.7/app-release.apk -O ./apps/app-release.apk

- name: Enable KVM (hw accelleration)
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm

- name: Setup .npmrc
run: printf '@polito:registry=https://npm.pkg.github.com\n//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}\n' > .npmrc

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "adopt"
java-version: 21

- name: Setup Node.js environment
uses: actions/[email protected]
with:
node-version-file: .nvmrc

- name: Cache node modules
uses: actions/cache@v4
with:
path: ./tests/e2e/node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('./tests/e2e/package-lock.json') }}

- name: Install npm dependencies and create error screenshots folder
run: |
npm install
mkdir -p screenshots

- name: Run emulator and tests
uses: reactivecircus/android-emulator-runner@v2 # install and create the Emulator
with:
api-level: ${{vars.API_LEVEL}} #34
target: ${{ env.USE_PLAYSTORE == 'true' && 'google_apis' || 'default' }} #default
arch: x86_64
profile: ${{vars.PROFILE}} #pixel_3a_xl
emulator-options: -no-window -gpu swiftshader_indirect -noaudio
working-directory: "./tests/e2e"
disable-animations: false #reanimate issue map view
script: npm run wdio

- name: Test report
run: |
npx ctrf merge report --output ctrf-report.json
npx github-actions-ctrf report/ctrf-report.json
if: always()

- name: Upload report
uses: actions/upload-artifact@v4
with:
name: ctrf-report
path: ./tests/e2e/report/ctrf-report.json
if: always()

- name: Upload screenshot
uses: actions/upload-artifact@v4
with:
name: screenshots
path: ./tests/e2e/screenshots/*
if: failure()
Loading
Loading