Skip to content

Commit

Permalink
Merge pull request #99 from stark-contrast/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
abcdefghiraj authored Nov 23, 2023
2 parents 4de1d73 + 4507833 commit ea5617a
Show file tree
Hide file tree
Showing 10 changed files with 169 additions and 48 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ COPY entrypoint.sh /stark_ga/entrypoint.sh
COPY dist /stark_ga/dist

# Install stark accessibility cli
RUN npm i -g npm i @stark-lab-inc/accessibility-cli@0.4.0-beta.0 \
RUN npm i -g npm i @stark-lab-inc/accessibility-cli@0.5.0-beta.0 \
&& stark-accessibility --version

# TODO: symlink /root/.local-chromium to $GITHUB_HOME/.local-chromium to avoid double install or remove install from this step.
Expand Down
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ jobs:
# http://localhost:3000
# http://localhost:3000/about
# http://localhost:3000/help
# OR
# urls:'
# http://localhost:3000
#
Expand All @@ -93,6 +94,34 @@ jobs:
# '
urls: ''

# [Optional] Navigation timeout for puppeteer in ms. How long should puppeteer wait till it checks page load (wait until event) is complete.
# Note: This timeout applies to all pages in your url list individually
# Defaults to 30000 ms
puppeteer_timeout: 30000

# [Optional] Event that puppeteer looks out for to assume completed navigation to a given page. In case of multiple values, navigation is considered to be successful after all events have been fired
# This can be multiple values from [load, domcontentloaded, networkidle0, networkidle2], with each value belonging to its own line.
# This value follows YAML conventions for multiline strings.
# Example:
# puppeteer_wait_until: |-
# load
# domcontentloaded
# Defaults to load
puppeteer_wait_until: 'load'

# [Optional] Run puppeteer in stealth mode. Attempts to hide puppeteer from your server. Won't be necessary for localhost
# Note: Uses puppeteer-extra stealth-mode. This is not a guaranteed way to hide usage of automated software to control browsers.
# Defaults to false (use if you have bot checks in your server code)
stealth_mode: false

# [Optional] If a url scan failed, scans the next one without failing the action.
# Defaults to false
skip_errors: false

# [Optional] Adds a delay before running the scan. This is different from the timeout and delay in the sense that this delay occurs after the page is navigated to.
# Defaults to 100
scan_delay: 500

# [Optional] Shell commands to run after the action finishes a scan.
# Use this to run any cleanup commands.
cleanup: ''
Expand Down
17 changes: 12 additions & 5 deletions __tests__/parse-inputs.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import {afterEach, describe} from 'node:test'
import {getInput} from '@actions/core'
import {getInput, getBooleanInput} from '@actions/core'
import {expect, jest, test} from '@jest/globals'
import {
InputParams,
getCoreInputWithFallback,
parseInputs,
parseUrls
parseMultilineString
} from '../src/parse-inputs'

jest.mock('@actions/core', () => ({
getInput: jest.fn(),
getBooleanInput: jest.fn(),
debug: jest.fn()
}))

Expand All @@ -34,6 +35,7 @@ describe('getCoreInputSafe', () => {
describe('parseInput', () => {
afterEach(() => {
;(getInput as jest.Mock).mockClear()
;(getBooleanInput as jest.Mock).mockClear()
})
test('should return correct default values', () => {
;(getInput as jest.Mock).mockImplementation(key => {
Expand All @@ -51,7 +53,12 @@ describe('parseInput', () => {
urls: ['localhost:3000/test', 'localhost:3000/about'],
minScore: '0',
sleepTime: '5000',
token: ''
token: '',
puppeteerTimeout: '30000',
puppeteerWaitUntil: ['load'],
scanDelay: '100',
skipErrors: false,
stealthMode: false
}

const inputs = parseInputs()
Expand All @@ -72,7 +79,7 @@ describe('parseUrls', () => {
test('should trim whitespaces', () => {
const multiUrlString =
' localhost:3000/test\n http://localhost:5000/test'
const urls = parseUrls(multiUrlString)
const urls = parseMultilineString(multiUrlString)

const expected = ['localhost:3000/test', 'http://localhost:5000/test']
expect(urls).toEqual(expected)
Expand All @@ -83,7 +90,7 @@ describe('parseUrls', () => {
'\n\
localhost:3000/test\n\
http://localhost:5000/test'
const urls = parseUrls(multiUrlString)
const urls = parseMultilineString(multiUrlString)

const expected = ['localhost:3000/test', 'http://localhost:5000/test']
expect(urls).toEqual(expected)
Expand Down
20 changes: 20 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@ inputs:
token:
description: "Stark token required to send data back to stark web. The cli doesn't post data if token is not provided"
required: false
puppeteer_timeout:
description: "Navigation timeout for puppeteer in ms"
required: false
default: 30000
puppeteer_wait_until:
description: "Wait until params for puppeteer from [load, domcontentloaded, networkidle0, networkidle2]. Each value belongs to a new line. Follows YAML conventions."
required: false
default: "load"
stealth_mode:
description: "Run puppeteer in stealth mode. Attempts to hide puppeteer from your server. Won't be necessary for localhost"
required: false
default: false
skip_errors:
description: "Continue to scanning the next url if an error occurs while scanning a url"
required: false
default: false
scan_delay:
description: "Delay running a scan after navigation has completed (wait for something to happen on the page)"
required: false
default: 100
runs:
using: 'docker'
image: 'Dockerfile'
Expand Down
41 changes: 32 additions & 9 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "accessibility-check-action",
"version": "0.4.0-beta.0",
"version": "0.5.0-beta.0",
"private": true,
"description": "Stark action to run accessibility in github actions",
"main": "lib/main.js",
Expand Down Expand Up @@ -34,10 +34,10 @@
},
"devDependencies": {
"@types/lodash": "^4.14.201",
"@types/node": "^20.9.0",
"@types/node": "^20.9.2",
"@typescript-eslint/parser": "^5.59.2",
"@vercel/ncc": "^0.38.1",
"eslint": "^8.53.0",
"eslint": "^8.54.0",
"eslint-plugin-github": "^4.10.1",
"eslint-plugin-jest": "^27.6.0",
"eslint-plugin-prettier": "^5.0.1",
Expand Down
Loading

0 comments on commit ea5617a

Please sign in to comment.