Skip to content

Commit

Permalink
Merge pull request #10 from muuklabs/pw-suport-and-selenium-refactor
Browse files Browse the repository at this point in the history
[semver:major] Introduce mkpw job and refactor mkcli job
  • Loading branch information
napoles-mk authored Dec 14, 2023
2 parents f78074d + 272e7cd commit 66d9be1
Show file tree
Hide file tree
Showing 15 changed files with 219 additions and 44 deletions.
15 changes: 12 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ version: 2.1
orbs:
muuktest: muuklabs/muuktest@<<pipeline.parameters.dev-orb-version>>
orb-tools: circleci/orb-tools@10.0
bats: circleci/bats@1.0
shellcheck: circleci/shellcheck@2.0

filters: &filters
tags:
only: /.*/

# Pipeline Parameters
## These parameters are used internally by orb-tools. Skip to the Jobs section.
parameters:
Expand Down Expand Up @@ -35,8 +38,10 @@ workflows:
test-pack:
unless: << pipeline.parameters.run-integration-tests >>
jobs:
- orb-tools/lint # Lint Yaml files
- orb-tools/pack # Pack orb source
- orb-tools/lint: # Lint Yaml files
filters: *filters
- orb-tools/pack: # Pack orb source
filters: *filters
# Publish development version(s) of the orb.
- orb-tools/publish-dev:
orb-name: muuklabs/muuktest
Expand All @@ -62,6 +67,10 @@ workflows:
# Run any integration tests defined within the `jobs` key.
- muuktest/mkcli: # Run orb itself
t: TC17937
muuk_key: MUUK_KEY
- muuktest/mkpw: # Run orb itself
t: TC17937
muuk_key: MUUK_KEY
# Publish a semver version of the orb. relies on
# the commit subject containing the text "[semver:patch|minor|major|skip]"
# as that will determine whether a patch, minor or major
Expand Down
7 changes: 3 additions & 4 deletions src/@orb.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
version: 2.1

description: |
MuukTest is a codeless test automation platform designed to make software testing 20x faster, since first day.
MuukTest CircleCI Orb provides a simple configuration to enable test execution from your muuktest.com organization within your CircleCI CI/CD process, easily.
description: >
Easily execute tests from MuukTest on CircleCI integration. Provides jobs for executing on Selenium (using our mkcli python script) or Playwright.
display:
home_url: "https://www.muuktest.com"
source_url: "https://github.com/muuklabs/circleci-orb"
source_url: "https://github.com/muuklabs/circleci-orb/tree/alpha"
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
description: |
This example runs the test with tag TC0001. Change tag to the right value in order to run any test from your organization.
Prerequisites: set muuk_key environment variable under your CircleCi project settings with your organization key.
Prerequisites: set an environment variable under your CircleCi project settings with your organization key. Hence use the variable name for the muuk_key parameter, if the name of your variable is MUUK_KEY then you don't need set muuk_key paramter as that variable name is used by default.
Please see the following link for reference: https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-project
Want to know which is your organization key? No problem, see the next link for reference:
https://muuklabs.zendesk.com/hc/en-us/articles/4408400288787-Portal-Account
usage:
version: 2.1
orbs:
muuktest: muuklabs/muuktest@1.0.1
muuktest: muuklabs/muuktest@2.0.0
workflows:
execute:
jobs:
- muuktest/mkcli:
t: TC0001
muuk_key: MUUK_KEY
18 changes: 18 additions & 0 deletions src/examples/mkcli_run_on_firefox.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
description: |
By default, test are run on chrome, this example instead runs the test with tag TC0001 on firefox according to the browser's parameter.
Prerequisites: set an environment variable under your CircleCi project settings with your organization key. Hence use the variable name for the muuk_key parameter, if the name of your variable is MUUK_KEY then you don't need set muuk_key paramter as that variable name is used by default.
Please see the following link for reference: https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-project
Want to know which is your organization key? No problem, see the next link for reference:
https://muuklabs.zendesk.com/hc/en-us/articles/4408400288787-Portal-Account
usage:
version: 2.1
orbs:
muuktest: muuklabs/muuktest@2.0.0
workflows:
execute:
jobs:
- muuktest/mkcli:
t: TC0001
browser: firefox
muuk_key: MUUK_KEY
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
description: |
This example executes all the tests with the hashtag '#deployment' (notice the # char should not be included on the command).
Prerequisites: set muuk_key environment variable under your CircleCi project settings with your organization key.
Prerequisites: set an environment variable under your CircleCi project settings with your organization key. Hence use the variable name for the muuk_key parameter, if the name of your variable is MUUK_KEY then you don't need set muuk_key paramter as that variable name is used by default.
Please see the following link for reference: https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-project
Want to know which is your organization key? No problem, see the next link for reference:
https://muuklabs.zendesk.com/hc/en-us/articles/4408400288787-Portal-Account
usage:
version: 2.1
orbs:
muuktest: muuklabs/muuktest@1.0.1
muuktest: muuklabs/muuktest@2.0.0
workflows:
execute:
jobs:
- muuktest/mkcli:
p: hashtag
t: deployment
browser: firefox
muuk_key: MUUK_KEY
17 changes: 17 additions & 0 deletions src/examples/mkpw_basic_run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
description: |
This example runs the test with tag TC0001 on Playwright executor. Change tag to the right value in order to run any test from your organization.
Prerequisites: set an environment variable under your CircleCi project settings with your organization key. Hence use the variable name for the muuk_key parameter, if the name of your variable is MUUK_KEY then you don't need set muuk_key paramter as that variable name is used by default.
Please see the following link for reference: https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-project
Want to know which is your organization key? No problem, see the next link for reference:
https://muuklabs.zendesk.com/hc/en-us/articles/4408400288787-Portal-Account
usage:
version: 2.1
orbs:
muuktest: muuklabs/muuktest@2.0.0
workflows:
execute:
jobs:
- muuktest/mkpw:
t: TC0001
muuk_key: MUUK_KEY
18 changes: 18 additions & 0 deletions src/examples/mkpw_test_by_hashtag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
description: |
This example executes all the tests with the hashtag '#deployment' on Playwright executor (the # char could either be included or not on the value).
Prerequisites: set an environment variable under your CircleCi project settings with your organization key. Hence use the variable name for the muuk_key parameter, if the name of your variable is MUUK_KEY then you don't need set muuk_key paramter as that variable name is used by default.
Please see the following link for reference: https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-project
Want to know which is your organization key? No problem, see the next link for reference:
https://muuklabs.zendesk.com/hc/en-us/articles/4408400288787-Portal-Account
usage:
version: 2.1
orbs:
muuktest: muuklabs/muuktest@2.0.0
workflows:
execute:
jobs:
- muuktest/mkpw:
t: deployment
p: hashtag
muuk_key: MUUK_KEY
17 changes: 0 additions & 17 deletions src/examples/run_on_firefox.yml

This file was deleted.

45 changes: 29 additions & 16 deletions src/jobs/mkcli.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
description: >
MuukTest mkcli to run your MuukTest automated test with CircleCI on Github pull requests
MuukTest Selenium executor with Circle CI on Github.
docker:
- image: muuk/muuktest_v1:0.1
- image: cimg/python:3.7-browsers
environment:
GRADLE_OPTS: -Xmx1024m -XX:MaxMetaspaceSize=256m
GRADLE_USER_HOME: .gradle-home
Expand All @@ -11,32 +11,45 @@ parameters:

t:
type: string
description: "Test case id (tag) or hastag value"
description: "Test case id or hashtag name."

p:
type: enum
default: tag
enum: [tag, hashtag]
description: "Set either tag or hastag regarding t value to provide"
description: "Set either tag or hastag according value on t parameter."

browser:
type: enum
default: chrome
enum: [chrome, firefox]
description: "Set either from chrome or firefox to run the scritp on"
description: "Set either from chrome or firefox to run the script on."

muuk_key:
default: MUUKTEST_KEY
description: "Name of the env var with your MuukTest key.pub account value. This var should be set on CircleCi settings."
type: env_var_name

resource_class: medium+

steps:
- run:
name: Init
command: |
Xvfb :99 -screen 0 1366x768x16 -nolisten tcp -fbdir /var/run > /dev/null 2>&1 &
export DISPLAY=:99
git clone https://github.com/muuklabs/executor.git
cd executor/
git checkout videoEnabled
printf $muuk_key > key.pub
MUUKTEST_KEY_INTERNAL=${<< parameters.muuk_key >>}
printf "%s" "$MUUKTEST_KEY_INTERNAL" > key.pub
cat key.pub
chmod 755 gradlew
chmod 755 key.pub
sed -i 's/79.0.3945.36/86.0.4240.22/g' build.gradle
cat build.gradle
python3.7 mkcli.py -p << parameters.p >> -t << parameters.t >> -browser << parameters.browser >>
- run:
name: Install required libraries
command: <<include(scripts/install_mkcli_requirements.sh)>>

- run:
name: Get MuukTest executor and run tests
command: <<include(scripts/configure_mkcli.sh)>>

- run:
name: Execute E2E tests and report results to MuukTest
command: |
cd executor/
python3 mkcli.py -p << parameters.p >> -t << parameters.t >> -browser << parameters.browser >>
61 changes: 61 additions & 0 deletions src/jobs/mkpw.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
description: >
MuukTest Playwright executor with Circle CI on Github.
docker:
- image: cimg/node:20.9
environment:
MUUKTEST_TAG_PROPERTY: << parameters.p >>
MUUKTEST_TAG_VALUE: << parameters.t >>
MUUKTEST_BROWSER: << parameters.browser >>

parameters:

t:
type: string
description: "Test case id or hashtag name."

p:
type: enum
default: tag
enum: [tag, hashtag]
description: "Set either tag or hastag according value on t parameter."

browser:
type: enum
default: chromium
enum: [chromium, firefox]
description: "Set either from chrome or firefox to run the script on."

muuk_key:
default: MUUKTEST_KEY
description: "Name of the env var with your MuukTest key.pub account value. This var should be set on CircleCi settings."
type: env_var_name

steps:
- run:
name: Init
command: |
mkdir -p executor
cd executor
MUUKTEST_KEY_INTERNAL=${<< parameters.muuk_key >>}
printf '{ "key": "%s"}' "$MUUKTEST_KEY_INTERNAL" > file.json
cat file.json
- run:
name: Installing libraries dependencies
command: sudo apt-get update && sudo apt-get install -y unzip

- run:
name: Retrieve MuukTest config files and Test scripts
command: <<include(scripts/get_pw_config_and_tests.sh)>>

- run:
name: Installing PW and required packages
command: <<include(scripts/install_pw_and_requirements.sh)>>


- run:
name: Execute MuukTest E2E
command: |
cd executor || { echo "Failure: executor directory not found!"; exit 1; }
npx playwright test --workers=3 --project=$MUUKTEST_BROWSER
14 changes: 14 additions & 0 deletions src/scripts/configure_mkcli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
Xvfb :99 -screen 0 1366x768x16 &
DISPLAY=:99
ps -ef | grep Xvfb
[ -d "./executor" ] && rm -r executor
git clone https://github.com/muuklabs/executor.git
mv ./key.pub ./executor
cd executor || { echo "Failure: executor directory not found!"; exit 1; }
git checkout videoEnabled
chmod 755 gradlew
chmod 755 key.pub
sed -i 's/79.0.3945.36/114.0.5735.90/g' build.gradle
sed -i 's/0.23.0/0.33.0/g' build.gradle
cat build.gradle
15 changes: 15 additions & 0 deletions src/scripts/get_pw_config_and_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
cd executor || { echo "Failure: executor directory not found!"; exit 1; }
curl -H "Content-Type: application/json" -X POST -d @file.json 'https://portal.muuktest.com:8081/generate_token_executer' -o "token.json"
curl -X POST https://portal.muuktest.com:8081/api/v1/downloadpwfiles -k -d @file.json -H "Content-Type: application/json" -o ./config.zip
unzip -o config.zip -d .
MUUK1_TOKEN=$(jq --raw-output .token token.json)
printf "Authorization: Bearer %s" "$MUUK1_TOKEN" > header.txt
MUUK_USERID_TOKEN=$(jq --raw-output .userId token.json)
FIXED_TAG_VALUE=$MUUKTEST_TAG_VALUE
[[ $FIXED_TAG_VALUE != "#"* ]] && FIXED_TAG_VALUE="#$FIXED_TAG_VALUE"
printf '{"property": "%s", "value": ["%s"], "platform": "pw", "userId": "%s"}' "$MUUKTEST_TAG_PROPERTY" "$FIXED_TAG_VALUE" "$MUUK_USERID_TOKEN" > body.json
curl -X POST https://portal.muuktest.com:8081/download_byproperty -H @header.txt -d @body.json -H "Content-Type: application/json" -o ./test.zip
[ -d "./test" ] && rm -r test
unzip -o test.zip -d ./test
ls -l
3 changes: 3 additions & 0 deletions src/scripts/install_mkcli_requirements.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
pip install requests
pip install Pillow
10 changes: 10 additions & 0 deletions src/scripts/install_pw_and_requirements.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
cd executor || { echo "Failure: executor directory not found!"; exit 1; }
npm install -D @playwright/test
npx playwright install --with-deps "$MUUKTEST_BROWSER"
npm install axios
npm install archiver
npm install cheerio
npm install xpath
npm install @xmldom/xmldom
npm install @faker-js/faker
13 changes: 13 additions & 0 deletions src/scripts/install_pw_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
cd executor || { echo "Failure: executor directory not found!"; exit 1; }
sudo apt-get update && sudo apt-get install -y ca-certificates curl gnupg
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
NODE_MAJOR=20
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
sudo apt-get update && sudo apt-get install nodejs -y
echo "node -v" && node -v
sudo apt-get update && sudo apt-get install gcc g++ make
sudo apt-get update && sudo apt-get install npm
echo "npm -v" && npm -v
sudo apt-get update && sudo apt-get install -y unzip

0 comments on commit 66d9be1

Please sign in to comment.