Skip to content

Commit eb5a42f

Browse files
committed
Cleanup
- Refactored scripts in package.json - Replaced old workflow, now supports xvfb + playwright tests
1 parent 56c659d commit eb5a42f

File tree

13 files changed

+345
-62
lines changed

13 files changed

+345
-62
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Run Playwright e2e tests and generate documentation
2+
3+
on:
4+
# Runs on pushes targeting the main branch
5+
push:
6+
branches: [main, dev]
7+
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
18+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
19+
concurrency:
20+
group: "pages"
21+
cancel-in-progress: false
22+
23+
jobs:
24+
# Build job: runs tsdocs and playwright tests, then uploads docs and playwright-report to Pages as an artifact
25+
build:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout repo
29+
uses: actions/checkout@v3
30+
31+
- name: Setup node environment
32+
uses: actions/setup-node@v3
33+
with:
34+
node-version: "20"
35+
36+
- name: Configure Github Pages
37+
uses: actions/configure-pages@v3
38+
39+
- name: Install xvfb
40+
run: sudo apt-get update && sudo apt-get install -y xvfb
41+
42+
- name: Install node dependencies
43+
run: npm i
44+
45+
- name: Run tsdocs on the src directory
46+
run: npm run docs
47+
48+
- name: Install Playwright browsers
49+
run: npx playwright install --with-deps
50+
51+
- name: Build the extension
52+
run: npm run build:webext
53+
54+
- name: Run Playwright tests with xvfb
55+
run: xvfb-run --auto-servernum --server-args='-screen 0 1280x1024x24' npx playwright test
56+
57+
- name: Build the artifact directory
58+
run: |
59+
mkdir -p build_outputs_folder/
60+
cp -r docs build_outputs_folder/
61+
cp index.html build_outputs_folder/
62+
cp -r assets build_outputs_folder/
63+
# Uncomment for debugging purposes
64+
# cp -r playwright/playwright-report build_outputs_folder/
65+
# cp -r playwright/test-results build_outputs_folder/
66+
67+
- name: List artifact directory contents
68+
run: ls -l build_outputs_folder/*
69+
70+
- name: Upload the artifact to Pages
71+
uses: actions/upload-pages-artifact@v3
72+
with:
73+
path: build_outputs_folder/
74+
75+
# Deployment job: deploys the artifact to GitHub Pages
76+
deploy:
77+
environment:
78+
name: github-pages
79+
url: ${{ steps.deployment.outputs.page_url }}
80+
runs-on: ubuntu-latest
81+
needs: build
82+
steps:
83+
- name: Download artifact from build
84+
uses: actions/download-artifact@v4
85+
with:
86+
name: github-pages
87+
path: .
88+
- name: Deploy to GitHub Pages
89+
id: deployment
90+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
22

3+
/webext/*
4+
35
/playwright/*
4-
!/playwright/specs
5-
!/playwright/specs/**
66
!/playwright/harness
77
!/playwright/harness/**
8-
9-
/webext/*
8+
!/playwright/specs
9+
!/playwright/specs/**
1010

1111
# secrets for testing
1212
.env
@@ -25,6 +25,7 @@ node_modules
2525
# purgable, throw-away files
2626
/tmp
2727
/work
28+
/docs
2829

2930
# developer notes
3031
/admin

.npmignore

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
22

3-
/playwright/*
4-
!/playwright/specs
5-
!/playwright/specs/**
6-
!/playwright/harness
7-
!/playwright/harness/**
8-
9-
/webext/*
3+
/webext
4+
/playwright
105

116
# secrets for testing
127
.env
@@ -25,6 +20,7 @@ node_modules
2520
# purgable, throw-away files
2621
/tmp
2722
/work
23+
/docs
2824

2925
# developer notes
3026
/admin

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue)
44
![License](https://img.shields.io/github/license/rshaker/context-detect)
5+
![version](https://img.shields.io/github/package-json/v/rshaker/context-detect)
56

67
## Overview
78

89
Suppose you're a piece of code running in some context of some browser's javascript engine, and you need to determine what your API options are. This won't tell you your specific options, but it will tell you what type of environment (context) you're saddled with. That's the sole purpose of this library, to tell you in which browser and context you are currently executing.
910

11+
The library is designed to work in main, isolated, background, extension page, action popup, worker, and shared worker contexts. Not for use in server-side contexts such as Node.
12+
1013
## Installation
1114

1215
### npm

0 commit comments

Comments
 (0)