Skip to content

Commit 90f0046

Browse files
Merge pull request #29 from tawk/release/pattern-matching-and-automated-tests
- Enhanced pattern matching feature. - Integration tests using selenium. - Workflows for - Building package on release. - Running selenium tests on PR request/update.
2 parents 4d52406 + 253a3e7 commit 90f0046

55 files changed

Lines changed: 10379 additions & 847 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use-strict';
2+
3+
module.exports = {
4+
'env': {
5+
'browser': true,
6+
'jquery': true
7+
},
8+
'extends': 'wordpress'
9+
};

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# ignore .github files
2+
/.github export-ignore
3+
4+
# export-ignore test files
5+
/phpunit.xml export-ignore
6+
/tests export-ignore
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: Notify ui test
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
notify:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Notifying ui-tests workflow
10+
run: echo 'done';

.github/workflows/release.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: create-release-artifact
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
create-release-artifact:
9+
name: Creating release artifact
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: checkout
13+
uses: actions/checkout@v2
14+
15+
- name: cached dependencies
16+
uses: actions/cache@v2
17+
id: cached-dependencies
18+
with:
19+
path: ./tawkto/vendor
20+
# the key will change if composer.lock changes
21+
key: ${{ runner.os }}-dependencies-${{ hashFiles('**/composer.lock') }}
22+
23+
- name: install dependencies
24+
uses: php-actions/composer@v6
25+
with:
26+
command: run build:prod
27+
28+
- name: version
29+
id: version
30+
run: echo "::set-output name=version::$(jq -r '.version' ./composer.json)"
31+
32+
- name: build artifact
33+
run: composer run package && mv ./tmp/tawkto-live-chat.zip tawkto-live-chat-${{ steps.version.outputs.version }}.zip
34+
35+
- name: upload artifact
36+
uses: actions/upload-release-asset@v1
37+
env:
38+
GITHUB_TOKEN: ${{ github.token }}
39+
with:
40+
upload_url: ${{ github.event.release.upload_url }}
41+
asset_path: ./tawkto-live-chat-${{ steps.version.outputs.version }}.zip
42+
asset_name: tawkto-live-chat-${{ steps.version.outputs.version }}.zip
43+
asset_content_type: application/zip

.github/workflows/ui-tests.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: ui-tests
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Notify ui test"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: bansan85/action-workflow_run-status@main
14+
15+
- name: checkout
16+
uses: actions/checkout@v2
17+
with:
18+
# checkouts the commit that triggered the Notify ui test workflow
19+
ref: ${{ github.event.workflow_run.head_sha }}
20+
21+
- name: cached dependencies
22+
uses: actions/cache@v2
23+
id: cached-dependencies
24+
with:
25+
path: |
26+
./vendor
27+
./tawkto/vendor
28+
# the key will change if composer.lock changes
29+
key: ${{ runner.os }}-composer-dependencies-${{ hashFiles('**/composer.lock') }}
30+
31+
- name: install dependencies
32+
if: steps.cached-dependencies.outputs.cache-hit != 'true'
33+
uses: php-actions/composer@v6
34+
with:
35+
php_extensions: zip
36+
command: run build
37+
38+
tests:
39+
needs: [build]
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
browser: ['chrome', 'firefox', 'edge']
44+
45+
runs-on: ubuntu-latest
46+
env:
47+
WEB_HOST: wordpress
48+
SELENIUM_BROWSER: ${{ matrix.browser }}
49+
SELENIUM_HOST: localhost
50+
SELENIUM_PORT: 4444
51+
52+
steps:
53+
- name: Report to PR
54+
env:
55+
MATRIX_CONTEXT: ${{ toJSON(matrix) }}
56+
uses: bansan85/action-workflow_run-status@main
57+
58+
- name: checkout
59+
uses: actions/checkout@v2
60+
with:
61+
# checkouts the commit that triggered the Notify ui test workflow
62+
ref: ${{ github.event.workflow_run.head_sha }}
63+
64+
- name: Start docker services and setup WordPress
65+
run: |
66+
docker-compose -f ./tests/docker/docker-compose.yml up -d;
67+
docker attach wordpress-cli;
68+
69+
- name: cached dependencies
70+
uses: actions/cache@v2
71+
id: cached-dependencies
72+
with:
73+
path: |
74+
./vendor
75+
./tawkto/vendor
76+
# the key will change if composer.lock changes
77+
key: ${{ runner.os }}-composer-dependencies-${{ hashFiles('**/composer.lock') }}
78+
79+
- name: prepare test artifact
80+
run: composer run package
81+
82+
- name: run tests
83+
env:
84+
TAWK_PROPERTY_ID: 61efb9abb9e4e21181bbc347
85+
TAWK_WIDGET_ID: 1fq86qic0
86+
TAWK_USERNAME: ${{ secrets.TAWK_USERNAME }}
87+
TAWK_PASSWORD: ${{ secrets.TAWK_PASSWORD }}
88+
run: composer run test

.gitignore

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
tawkto.zip
1+
tawkto.zip
2+
vendor
3+
.phpunit*
4+
tawkto/vendor
5+
node_modules
6+
.phpcs.cache
7+
.eslintcache
8+
.stylelintcache
9+
**/*.env.local
10+
tmp
11+
dev

.huskyrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
module.exports = {
4+
hooks: {
5+
'pre-commit': 'lint-staged'
6+
}
7+
};

.lintstagedrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
'*.js': 'eslint --cache --fix',
3+
'*.css': 'stylelint --cache --fix',
4+
'*.php': [
5+
'composer run lint:fix',
6+
'composer run lint'
7+
]
8+
}

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
12.22.7

.phpcs.xml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="CS">
3+
<description>Custom coding standards.</description>
4+
<config name="testVersion" value="5.6-"/>
5+
<exclude-pattern>\.github/*</exclude-pattern>
6+
<exclude-pattern>vendor/*</exclude-pattern>
7+
<exclude-pattern>tawkto/vendor/*</exclude-pattern>
8+
<exclude-pattern>node_modules/*</exclude-pattern>
9+
<exclude-pattern>assets/*</exclude-pattern>
10+
11+
<arg value="ps"/>
12+
<arg name="colors"/>
13+
<arg name="parallel" value="100"/>
14+
<arg name="extensions" value="php"/>
15+
<arg name="cache" value=".phpcs.cache"/>
16+
17+
<rule ref="WordPress">
18+
<exclude name="Squiz.Commenting.FileComment.Missing"/>
19+
<exclude name="Generic.Commenting.DocComment.MissingShort"/>
20+
<exclude name="Generic.Files.OneObjectStructurePerFile.MultipleFound"/>
21+
<exclude name="WordPress.Files.FileName.InvalidClassFileName"/>
22+
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase"/>
23+
</rule>
24+
25+
<rule ref="WooCommerce-Core">
26+
<exclude name="WooCommerce.Commenting"/>
27+
</rule>
28+
<rule ref="PHPCompatibility">
29+
<exclude-pattern>tests/*</exclude-pattern>
30+
</rule>
31+
<rule ref="Squiz.Commenting.FileComment">
32+
<exclude-pattern>tests/*</exclude-pattern>
33+
</rule>
34+
<rule ref="Squiz.Commenting.ClassComment">
35+
<exclude-pattern>tests/*</exclude-pattern>
36+
</rule>
37+
<rule ref="Squiz.Commenting.VariableComment">
38+
<exclude-pattern>tests/*</exclude-pattern>
39+
</rule>
40+
<rule ref="Squiz.Commenting.FunctionComment">
41+
<exclude-pattern>tests/*</exclude-pattern>
42+
</rule>
43+
</ruleset>

0 commit comments

Comments
 (0)