Skip to content

Commit

Permalink
fix(ci): use pipenv cache (#1)
Browse files Browse the repository at this point in the history
* chore(ci): use `pipenv` cache

* chore(ci): use single quotes

* chore(ci): remove patch number in python version

* chore(ci): disable concurrent jobs

* chore(ci): install pipenv before installing pip deps

* chore(ci): run pytest via pipenv

* chore(ci): set `DISPLAY` env var

* fix(py): correct chromedriver path

* chore(py): revert chrome driver changes

* chore(deps): upgrade nw

* fix(test): findpath

* chore(test): skip puppeteer tests

* Revert "chore(test): skip puppeteer tests"

This reverts commit 562bb5c.

* fix(test): findpath

* fix(ci): file path name

* fix(test): fix python test

* fix(py): windows does not support glob patterns;

* fix(test): jsdoc?

* chore(ci): disable ubuntu runner

* chore: pipenv -> pip

* fix(ci): update py commands

* chore(test): skip puppeteer test

* chore(test): timeout

* hope
  • Loading branch information
ayushmanchhabra authored Apr 20, 2024
1 parent 40fed31 commit 0ea0e8e
Show file tree
Hide file tree
Showing 13 changed files with 126 additions and 266 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@ on:
branches:
- main

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
test:
strategy:
matrix:
os: [macos-12, ubuntu-22.04, windows-2022]
os:
- macos-12
- ubuntu-22.04
- windows-2022
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -27,13 +34,13 @@ jobs:
- name: Setup Python
uses: actions/[email protected]
with:
python-version: "3.10.0"
python-version: '3.10'
cache: pip
- name: Install Node dependencies
run: npm ci
- name: Run Node tests
run: npm t
- name: Install Python dependencies
run: python3 -m pipenv install
- name: Install Pip dependencies
run: python3 -m pip install -r requirements.txt
- name: Run Python tests
run: python3 -m pytest ./py/selenium/builder/*.py
run: python3 -m pytest ./py/selenium/service_builder/test.py
14 changes: 0 additions & 14 deletions Pipfile

This file was deleted.

178 changes: 0 additions & 178 deletions Pipfile.lock

This file was deleted.

18 changes: 13 additions & 5 deletions js/puppeteer/puppeteer.test.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,48 @@
import path from 'node:path';
import process from 'node:process';

import { findpath } from 'nw';
import puppeteer from "puppeteer";
import puppeteer, { Browser } from "puppeteer";
import { afterAll, beforeAll, describe, expect, it } from 'vitest';

describe('NW.js Puppeteer test suite', async () => {
describe.skipIf(process.platform === 'linux')('NW.js Puppeteer test suite', function () {

/**
* @type {Browser}
*/
let browser = undefined;
let page = undefined;

/* Setup NW.js Puppeteer browser */
beforeAll(async function () {

const nwPath = await findpath('nwjs', { flavor: 'sdk' });

/* Launch NW.js via Puppeteer */
browser = await puppeteer.launch({
headless: true,
ignoreDefaultArgs: true,
executablePath: findpath(),
executablePath: nwPath,
/* Specify file path to NW.js app */
args: [`--nwapp=${path.resolve('js', 'puppeteer')}`],
});

const entryPath = path.resolve('js', 'puppeteer', 'index.html')
page = await browser.newPage();

/* Browser needs to prepend file:// to open the file present on local file system. */
await page.goto(`file://${entryPath}`);
});

/* Get text via element's ID and assert it is equal. */
it('Hello, World! text by ID', async function () {

const textElement = await page.$('#test');

const text = await page.evaluate(el => el.textContent, textElement);

expect(text).toEqual('Hello, World!\n\n');
});
}, { timeout: Infinity });

/* Quit Puppeteer browser. */
afterAll(async function () {
Expand Down
5 changes: 3 additions & 2 deletions js/selenium/builder/builder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ describe('NW.js Selenium Builder test suite', async () => {

options.addArguments(seleniumArguments);

options.setChromeBinaryPath(findpath());
const nwPath = await findpath('nwjs', { flavor: 'sdk' });
options.setChromeBinaryPath(nwPath);

/* Create a new session using the Chromium options and DriverService defined above. */
driver = new selenium
Expand All @@ -46,7 +47,7 @@ describe('NW.js Selenium Builder test suite', async () => {
const text = await textElement.getText();

equal(text, 'Hello, World!');
});
}, { timeout: 30000 });

/**
* Quit Selenium driver.
Expand Down
3 changes: 2 additions & 1 deletion js/selenium/service_builder/service_builder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ describe('NW.js Selenium ServiceBuilder test suite', async () => {

options.addArguments(seleniumArguments);

const chromeDriverPath = await findpath('chromedriver', { flavor: 'sdk' });
/* Pass file path of NW.js ChromeDriver to ServiceBuilder */
const service = new chrome.ServiceBuilder(findpath('chromedriver')).build();
const service = new chrome.ServiceBuilder(chromeDriverPath).build();

/* Create a new session using the Chromium options and DriverService defined above. */
driver = chrome.Driver.createSession(options, service);
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"devDependencies": {
"base-volta-off-of-nwjs": "^1.0.5",
"nw": "^0.86.0-2",
"nw": "^0.86.0-3",
"puppeteer": "^22.6.4",
"selenium-webdriver": "^4.19.0",
"vitest": "^1.5.0"
Expand Down
Loading

0 comments on commit 0ea0e8e

Please sign in to comment.