Skip to content

Commit

Permalink
Merge pull request #44 from stark-contrast/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
abcdefghiraj authored Aug 28, 2023
2 parents 42a7fc8 + 25c56e1 commit 878978e
Show file tree
Hide file tree
Showing 12 changed files with 958 additions and 702 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- uses: actions/checkout@v3

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

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 \
RUN npm i -g @stark-lab-inc/accessibility-cli@0.2.1-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
2 changes: 1 addition & 1 deletion __tests__/mocks/summary.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"runId":"summary","type":"pass","data":[{"name":"score","value":94.20289855072464},{"name":"passed","value":65},{"name":"failed","value":3},{"name":"potentials","value":1}]}
{"runId":"summary","url":"testurl","type":"pass","data":[{"name":"score","value":94.20289855072464},{"name":"passed","value":65},{"name":"failed","value":3},{"name":"potentials","value":1}]}
64 changes: 64 additions & 0 deletions __tests__/parse-inputs.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import {afterEach, describe} from 'node:test'
import {getInput} from '@actions/core'
import {expect, jest, test} from '@jest/globals'
import {
InputParams,
getCoreInputWithFallback,
parseInputs
} from '../src/parse-inputs'

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

describe('getCoreInputSafe', () => {
test('should return value if it exists', () => {
;(getInput as jest.Mock).mockReturnValueOnce('value')
const value = getCoreInputWithFallback('somekey', 'default')
expect(value).toBe('value')
})
test('should return default value if it does not exist', () => {
;(getInput as jest.Mock).mockReturnValueOnce(undefined)
const value = getCoreInputWithFallback('somekey', 'default')
expect(value).toBe('default')
})
test('should return default value if it is empty', () => {
;(getInput as jest.Mock).mockReturnValueOnce('')
const value = getCoreInputWithFallback('somekey', 'default')
expect(value).toBe('default')
})
})

describe('parseInput', () => {
afterEach(() => {
;(getInput as jest.Mock).mockClear()
})
test('should return correct default values', () => {
;(getInput as jest.Mock).mockImplementation(key => {
return key === 'url' ? 'localhost:3000/test' : ''
})
const expectedInputs: InputParams = {
setupScript: 'echo "No setup script"',
preBuildScript: 'echo "No prebuild script"',
buildScript: 'echo "No build script"',
serveScript: 'echo "No serve script"',
cleanupScript: 'echo "No cleanup script"',
url: 'localhost:3000/test',
minScore: '0',
sleepTime: '5000',
token: ''
}

const inputs = parseInputs()

expect(inputs).toEqual(expectedInputs)
})
test('should throw if url is not provided', () => {
;(getInput as jest.Mock).mockImplementation(key => {
if (key === 'url') throw new Error('')
return ''
})

expect(parseInputs).toThrowError()
})
})
20 changes: 10 additions & 10 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@ name: 'Stark Accessibility Checker'
description: "Run your server on github's infra and scan for accessibility issues with Stark's tooling"
inputs:
setup: # set up the container
description: 'Set up the current container. Here you can install dependencies related to the container. Eg install a node version. Use the node version.'
required: true
description: 'Set up the current container. Here you can install dependencies related to the container. E.g. install a node version. Use the node version.'
required: false
default: 'echo "Nothing to setup"'
prebuild: # install project dependencies
description: 'Install project dependencies. Eg npm install'
required: true
description: 'Install project dependencies. E.g. npm install'
required: false
default: 'echo "Nothing to prebuild"'
build: # build the project
description: 'Build the project. E.g npm build'
required: true
required: false
default: 'echo "Nothing to build"'
serve: # serve the project on localhost
description: 'Serve the project. E.g npm start'
required: true
required: false
default: 'echo "Nothing to serve"'
cleanup:
description: 'Run a cleanup if needed.'
required: true
required: false
default: 'echo "Nothing to cleanup"'
url:
description: 'Url that needs to be scanned. http:localhost:1337/'
description: 'Url that needs to be scanned. E.g http:localhost:1337/'
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"
required: true
required: false
default: 5000
min_score:
description: "Minimum score for the action to pass. A number from 0 to 100"
required: true
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"
Expand Down
94 changes: 79 additions & 15 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.

Loading

0 comments on commit 878978e

Please sign in to comment.