Skip to content

Commit

Permalink
Update test runner.
Browse files Browse the repository at this point in the history
  • Loading branch information
dom111 committed May 18, 2024
1 parent d3e40d2 commit 44ece2d
Show file tree
Hide file tree
Showing 10 changed files with 1,754 additions and 3,046 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/*
20 changes: 20 additions & 0 deletions .github/workflows/build-on-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Build and test application on push to remote

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 22
- run: make build
- run: make test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
node_modules
build/
build/
docker-compose.override.yml
6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.1'
version: '3.7'

services:
web:
Expand All @@ -12,7 +12,9 @@ services:
- 8000:80

test:
init: true
image: code-sandbox-test
platform: linux/x86_64
volumes:
- ./:/src/
build:
Expand All @@ -24,4 +26,4 @@ services:
# https://stackoverflow.com/a/53975412/3145856
# https://github.com/docker/compose/issues/5574
security_opt:
- seccomp:"./docker/test/chrome.json"
- seccomp:docker/test/chrome.json
19 changes: 11 additions & 8 deletions docker/test/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM node:slim
FROM node:22.1-slim

# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
# installs, work.
RUN apt-get update \
&& apt-get install -y wget gnupg \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | tee /etc/apt/trusted.gpg.d/google.asc >/dev/null \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
Expand All @@ -22,22 +22,19 @@ RUN apt-get update \
# you'll need to launch puppeteer with:
# browser.launch({executablePath: 'google-chrome-stable'})
# ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true

WORKDIR /home/pptruser

# Install puppeteer so it's available in the container.
RUN npm install -g npm@latest \
&& npm init -y \
&& npm i puppeteer \
RUN \
# Add user so we don't need --no-sandbox.
# same layer as npm install to keep re-chowned files from using up several hundred MBs more space
&& groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \
groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \
&& mkdir -p /home/pptruser/Downloads \
&& chown -R pptruser:pptruser /home/pptruser \
&& chmod -R 777 /tmp \
&& apt-get update \
&& apt-get install -y socat \
&& npm config set update-notifier false
&& npm install -g npm@latest

COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh

Expand All @@ -46,4 +43,10 @@ RUN chmod +x /usr/local/bin/entrypoint.sh
# Run everything after as non-privileged user.
USER pptruser

RUN npm init -y \
&& npm i puppeteer \
&& npm config set update-notifier false \
&& npx @puppeteer/browsers install chrome \
&& npx @puppeteer/browsers install firefox

ENTRYPOINT ["bash", "/usr/local/bin/entrypoint.sh"]
5 changes: 5 additions & 0 deletions docker/test/puppeteer.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ghcr.io/puppeteer/puppeteer:22

WORKDIR /src

#ENTRYPOINT ["bash", "/usr/local/bin/entrypoint.sh"]
4 changes: 4 additions & 0 deletions jest.config.functional.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export default {
testMatch: ['**/tests/functional/**/*.ts'],
preset: './tests/jest.ts-puppeteer.preset.ts',
transformIgnorePatterns: ['^.+\\.js$'],
moduleNameMapper: {
'^(\\.\\.)$': '../index',
},
};
4 changes: 4 additions & 0 deletions jest.config.unit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export default {
testMatch: ['**/tests/unit/**/*.test.ts'],
preset: 'ts-jest',
transformIgnorePatterns: ['^.+\\.js$'],
moduleNameMapper: {
'^(\\.\\.)$': '../index',
},
};
Loading

0 comments on commit 44ece2d

Please sign in to comment.