Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

v1.0.0 #174

Merged
merged 4 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set Node.js 16.x
- name: Set Node.js 20.x
uses: actions/[email protected]
with:
node-version: 16.x
node-version: 20.x

- name: Install dependencies
run: npm ci
Expand Down
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 @stark-lab-inc/accessibility-cli@0.8.0-beta.0 \
RUN npm i -g @stark-lab-inc/accessibility-cli@1.0.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
153 changes: 79 additions & 74 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,80 +51,85 @@ jobs:
id: stark
uses: stark-contrast/accessibility-check-action@beta
with:
# [Optional; only required when used with Stark Projects]
# The token used by the action to send an audit report back to Stark.
token: ${{ github.event.inputs.token }}

# [Optional] Shell commands for setting up the container.
# You can use this to install tools, export variables, etc.
# Example: 'nvm install 16 && nvm use 16'
setup: ''

# [Optional] Shell comamnds to run before the app is built.
# Run any prebuild steps, cd into subdirectories, etc.
prebuild: ''

# [Optional] Shell commands for building your app.
# Example: 'npm run build'
build: ''

# [Optional] Shell commands for serving your app.
# This command is slightly different from the others: it runs in a long-lived,
# detached process that is only terminated when the scan finishes and our action stops.
# Example: 'SERVER_PORT=3000 && npm run serve'
serve: ''

# [Optional] The number of milliseconds to wait before your app is ready.
# Defaults to 5000 milliseconds.
wait_time: 5000

# [Required] A list of URLs to be scanned, with each URL belonging to its own line. This value follows YAML conventions for multiline strings.
# Example:
# urls:|-
# http://localhost:3000
# http://localhost:3000/about
# http://localhost:3000/help
# OR
# urls:'
# http://localhost:3000
#
# http://localhost:3000/about
#
# http://localhost:3000/help
# '
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: ''
# [Optional; only required when used with Stark Projects]
# The token used by the action to send an audit report back to Stark.
token: ${{ github.event.inputs.token }}

# [Optional] Shell commands for setting up the container.
# You can use this to install tools, export variables, etc.
# Example: 'nvm install 16 && nvm use 16'
setup: ''

# [Optional] Shell comamnds to run before the app is built.
# Run any prebuild steps, cd into subdirectories, etc.
prebuild: ''

# [Optional] Shell commands for building your app.
# Example: 'npm run build'
build: ''

# [Optional] Shell commands for serving your app.
# This command is slightly different from the others: it runs in a long-lived,
# detached process that is only terminated when the scan finishes and our action stops.
# Example: 'SERVER_PORT=3000 && npm run serve'
serve: ''

# [Optional] The number of milliseconds to wait before your app is ready.
# Defaults to 5000 milliseconds.
wait_time: 5000

# [Required] A list of URLs to be scanned, with each URL belonging to its own line. This value follows YAML conventions for multiline strings.
# Example:
# urls:|-
# http://localhost:3000
# http://localhost:3000/about
# http://localhost:3000/help
# OR
# urls:'
# http://localhost:3000
#
# http://localhost:3000/about
#
# http://localhost:3000/help
# '
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: ''

# [Optional] Puppeteer browser viewport [width]x[height].
# Use this to specify a browser window size for your scan.
# Defaults to 800x600
viewport: '800x600'
```

The Stark action offers convenient arguments for building and serving your repository. For most builds, the key arguments you’ll need to configure are `build`, `serve`, and `urls`. At a minimum, you’ll want to configure `urls` and `wait_time`.
Expand Down
3 changes: 2 additions & 1 deletion __tests__/parse-inputs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ describe('parseInput', () => {
scanDelay: '100',
skipErrors: false,
stealthMode: false,
disableFerryman: false
disableFerryman: false,
viewport: '800x600'
}

const inputs = parseInputs()
Expand Down
29 changes: 17 additions & 12 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ inputs:
description: 'Install project dependencies. E.g. npm install'
required: false
default: 'echo "Nothing to prebuild"'
build: # build the project
build: # build the project
description: 'Build the project. E.g npm build'
required: false
default: 'echo "Nothing to build"'
serve: # serve the project on localhost
serve: # serve the project on localhost
description: 'Serve the project. E.g npm start'
required: false
default: 'echo "Nothing to serve"'
Expand All @@ -26,44 +26,48 @@ inputs:
required: false
default: 'echo "Nothing to cleanup"'
disable_ferryman:
description: "Enable ferryman on the scanner for optimised scans"
description: 'Enable ferryman on the scanner for optimised scans'
required: false
default: false
urls:
description: 'A list of URLs to be scanned, with each URL belonging to its own line. This value follows YAML conventions for multiline strings.'
required: true
default: 'https://getstark.co'
wait_time:
description: "Time in milliseconds to wait before running the scanner. A rough time delay for your server to start"
description: 'Time in milliseconds to wait before running the scanner. A rough time delay for your server to start'
required: false
default: 5000
min_score:
description: "Minimum score for the action to pass. A number from 0 to 100"
description: 'Minimum score for the action to pass. A number from 0 to 100'
required: false
default: 0
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"
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."
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:
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"
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)"
description: 'Delay running a scan after navigation has completed (wait for something to happen on the page)'
required: false
default: 100
viewport:
description: 'Puppeteer browser viewport [width]x[height]'
required: false
default: '800x600'
runs:
using: 'docker'
image: 'Dockerfile'
Expand All @@ -76,4 +80,5 @@ runs:
- ${{ inputs.urls }}
- ${{ inputs.min_score }}
- ${{ inputs.wait_time }}
- ${{ inputs.token }}
- ${{ inputs.token }}
- ${{ inputs.viewport }}
9 changes: 7 additions & 2 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.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "accessibility-check-action",
"version": "0.8.0-beta.0",
"version": "1.0.0",
"private": true,
"description": "Stark action to run accessibility in github actions",
"main": "lib/main.js",
Expand Down
7 changes: 6 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const {
stealthMode,
skipErrors,
scanDelay,
disableFerryman
disableFerryman,
viewport
} = parseInputs()

async function run(): Promise<void> {
Expand Down Expand Up @@ -83,6 +84,10 @@ async function run(): Promise<void> {
params.push(...['--puppeteer-timeout', puppeteerTimeout])
params.push(...['--scan-delay', scanDelay])

if (viewport) {
params.push('--viewport', viewport)
}

try {
const metadataDir = await dumpMetadata(github, 'github')
if (metadataDir) params.push('--metadata', metadataDir)
Expand Down
5 changes: 4 additions & 1 deletion src/parse-inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type InputParams = {
stealthMode: boolean
skipErrors: boolean
scanDelay: string
viewport: string
}
/**
* Function to parse inputs from github action. Replaces empty values with sensible defaults
Expand Down Expand Up @@ -62,6 +63,7 @@ export function parseInputs(): InputParams {
const sleepTime = getCoreInputWithFallback('wait_time', '5000')
const token = getCoreInputWithFallback('token', '')
const disableFerryman = !!core.getBooleanInput('disable_ferryman')
const viewport = getCoreInputWithFallback('viewport', '800x600')

const parsedInputs = {
setupScript,
Expand All @@ -78,7 +80,8 @@ export function parseInputs(): InputParams {
stealthMode,
skipErrors,
scanDelay,
disableFerryman
disableFerryman,
viewport
}
core.debug(`Provided inputs: ${JSON.stringify(parsedInputs)}`)
return parsedInputs
Expand Down