Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: Add test #96

Merged
merged 73 commits into from
Jan 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
781f58e
feat: Add test
jackton1 May 18, 2022
30cb8d6
Update test.yml
jackton1 May 18, 2022
6c76ea1
Update test.yml
jackton1 May 18, 2022
b71487a
Merge branch 'main' into feat/add-test
jackton1 Dec 31, 2022
6ebcbb0
Merge branch 'main' into feat/add-test
jackton1 Dec 31, 2022
2ebe136
Updated test
jackton1 Dec 31, 2022
0bcbfcc
Updated action.yml
jackton1 Dec 31, 2022
236bc02
Updated action.yml
jackton1 Dec 31, 2022
9c78202
Updated action.yml
jackton1 Dec 31, 2022
ef4d8e8
Updated the action.yml
jackton1 Jan 1, 2023
418af68
Fixed error with image
jackton1 Jan 1, 2023
84b58e0
Updated Dockerfile and action.yml
jackton1 Jan 1, 2023
5917df0
Updated Dockerfile
jackton1 Jan 1, 2023
cf26167
Updated if statement
jackton1 Jan 1, 2023
c9bbffd
Updated if statement
jackton1 Jan 1, 2023
9a3a4ff
Updated if statement
jackton1 Jan 1, 2023
a9f0c0b
Updated if statement
jackton1 Jan 1, 2023
cee983a
Updated if statement
jackton1 Jan 1, 2023
6914e0c
Updated if statement
jackton1 Jan 1, 2023
6db5095
Updated if statement
jackton1 Jan 1, 2023
6332b37
Updated if statement
jackton1 Jan 1, 2023
06d5c92
Updated if statement
jackton1 Jan 1, 2023
f5ae4d8
Updated if statement
jackton1 Jan 1, 2023
8c87a0c
Updated to use image
jackton1 Jan 1, 2023
1749205
Updated to use image
jackton1 Jan 1, 2023
d449203
Updated to use image
jackton1 Jan 1, 2023
599a6d5
Updated dockerfile
jackton1 Jan 1, 2023
2ea9719
Remove unused code
jackton1 Jan 1, 2023
dcb098e
Remove unused code
jackton1 Jan 1, 2023
5d5b2eb
Updated dockerfile
jackton1 Jan 1, 2023
1c4b660
Updated dockerfile
jackton1 Jan 1, 2023
0ba8dd0
Updated action.yml
jackton1 Jan 1, 2023
c07cf6c
Updated action.yml
jackton1 Jan 1, 2023
9499b46
Updated dockerfile
jackton1 Jan 1, 2023
28b50b0
Updated action.yml
jackton1 Jan 1, 2023
ea6c132
Updated action.yml
jackton1 Jan 1, 2023
16ca4ab
Updated action.yml
jackton1 Jan 1, 2023
5580077
Updated dockerfile
jackton1 Jan 1, 2023
6d45b66
Updated dockerfile
jackton1 Jan 1, 2023
657d8c4
Updated action.yml
jackton1 Jan 1, 2023
e9db75c
Updated action.yml
jackton1 Jan 1, 2023
0287ee9
Updated test
jackton1 Jan 1, 2023
656f800
Updated test
jackton1 Jan 1, 2023
371e8c9
Updated test
jackton1 Jan 1, 2023
402d681
Updated test
jackton1 Jan 1, 2023
e16fee1
Updated test
jackton1 Jan 1, 2023
f01fcb1
Updated action
jackton1 Jan 1, 2023
5cf718c
Updated action
jackton1 Jan 1, 2023
2c4e9b6
Updated action
jackton1 Jan 1, 2023
2eb893c
Updated action
jackton1 Jan 1, 2023
0a84545
Updated action
jackton1 Jan 1, 2023
a123e5f
Updated action
jackton1 Jan 1, 2023
6bf0253
Updated action
jackton1 Jan 1, 2023
d3bf508
Updated action
jackton1 Jan 1, 2023
b265ea1
Updated action
jackton1 Jan 1, 2023
6284664
Updated action
jackton1 Jan 1, 2023
413d623
Updated action
jackton1 Jan 1, 2023
9162185
Updated action
jackton1 Jan 1, 2023
8ce54a4
Updated action
jackton1 Jan 1, 2023
972b0c8
Updated action
jackton1 Jan 1, 2023
31e50c3
Updated action
jackton1 Jan 1, 2023
b6bc6c4
Updated action
jackton1 Jan 1, 2023
58fcd25
Updated the test
jackton1 Jan 1, 2023
d44b604
Updated the test
jackton1 Jan 1, 2023
1810a76
Updated the test
jackton1 Jan 1, 2023
2dfc23a
Updated the test
jackton1 Jan 1, 2023
caf5751
Updated README
jackton1 Jan 1, 2023
f3a148d
Removed unused code
jackton1 Jan 1, 2023
aba70f5
Removed unused code
jackton1 Jan 1, 2023
e94ba5e
Updated README.md
jackton1 Jan 1, 2023
d5d8db7
Updated action.yml
jackton1 Jan 1, 2023
ee94fb4
Updated action.yml
jackton1 Jan 1, 2023
7500a6a
Updated the HOME path
jackton1 Jan 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 0 additions & 46 deletions .github/workflows/ghcr.yml

This file was deleted.

23 changes: 15 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,23 @@ on:
jobs:
test:
name: Test puppeteer
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest]
node-version: [10, 12, 14, 15, 16]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3.2.0
- name: Test action with node ${{ matrix.node-version }}

- name: Test action
uses: ./
id: puppeteer-test
with:
files: test/test.js

- name: Copy test output
uses: tj-actions/docker-cp@v2
with:
node-version: ${{ matrix.node-version }}
container: ${{ steps.puppeteer-test.outputs.container-id }}
source: ${{ steps.puppeteer-test.outputs.home }}/test.pdf
destination: test.pdf

- name: Display contents of test.pdf
run: cat test.pdf
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
.idea/
.envrc

node_modules

22 changes: 0 additions & 22 deletions Dockerfile

This file was deleted.

28 changes: 4 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,18 @@

Run Test through [puppeteer](https://github.com/puppeteer/puppeteer), the headless chrome Node API

## Environment Variables

* `PUPPETEER_SKIP_CHROMIUM_DOWNLOAD`
* `PUPPETEER_EXECUTABLE_PATH`

## Usage

```yaml
...
steps:
- uses: actions/checkout@v2
- name: Install dependencies
uses: tj-actions/puppeteer@v3.2
with:
args: yarn install
- name: Run test
uses: tj-actions/puppeteer@v3.2
id: puppeteer
with:
args: yarn test
files: |
test/test.js
```

## Inputs
Expand All @@ -40,21 +33,8 @@ Run Test through [puppeteer](https://github.com/puppeteer/puppeteer), the headle

<!-- AUTO-DOC-INPUT:END -->

### Using docker

```shell script
docker pull ghcr.io/tj-actions/puppeteer:node-12
```

| Supported node versions |
|:------------------------:|
| 10 |
| 12 |
| 14 |
| 15 |
| 16 |
## Outputs

<!---->

* Free software: [MIT license](LICENSE)

Expand Down
37 changes: 21 additions & 16 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,32 @@ name: puppeteer-chrome
description: Run Test through Puppeteer, the headless chrome Node API
author: tj-actions
inputs:
token:
description: '[GITHUB_TOKEN](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow#using-the-github_token-in-a-workflow) or a repo scoped [Personal Access Token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token)'
required: true
default: ${{ github.token }}
node-version:
description: 'Node version'
required: false
default: '14'
args:
description: 'Command to run puppeteer'
files:
description: 'Files to run'
required: true

outputs:
container-id:
description: 'Container ID'
value: ${{ steps.puppeteer-run.outputs.container-id }}
home:
description: 'Home directory'
value: /home/pptruser

runs:
using: 'composite'
steps:
- id: build
run: docker build --build-arg NODE_VERSION=${{ inputs.node-version }} -t puppetter:local-node${{ inputs.node-version }} .
shell: bash
- id: run
run: docker run --rm -v $(pwd):/github/workspace --workdir /github/workspace puppetter:local-node${{ inputs.node-version }} ${{ inputs.args }}
shell: bash
- name: Run puppeteer
id: puppeteer-run
uses: tj-actions/docker-run@v2
with:
image: ghcr.io/puppeteer/puppeteer:19.4.1
name: puppeteer-chrome
options: '-i --init --cap-add=SYS_ADMIN -v ${{ github.workspace }}:${{ github.workspace }}'
args: |
bash -c 'while read -r file; do echo "Running $file..." && mkdir -p $(dirname /home/pptruser/$file) && cp ${{ github.workspace }}/$file /home/pptruser/$file && node $file && echo "Completed executing $file"; done <<< "$(echo "${{ inputs.files }}" | xargs -n1)"'


branding:
icon: camera-off
color: white
12 changes: 12 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const puppeteer = require('puppeteer');

Check notice

Code scanning / Jshint (reported by Codacy)

Prohibits the use of __iterator__ property due to compatibility issues

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();

Check notice

Code scanning / Jshint (reported by Codacy)

Prohibits the use of __iterator__ property due to compatibility issues

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
await page.goto('https://news.ycombinator.com', {
waitUntil: 'networkidle2',
});
await page.pdf({ path: 'test.pdf', format: 'a4' });

await browser.close();
})();