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

multiple fixes v1 #40

Merged
merged 1 commit into from
Oct 8, 2021
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
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,20 @@ See [Workflow syntax for GitHub Actions](https://help.github.com/en/articles/wor
## Other settings

As well as `apiKey`, `collection`, and `environment`, all other Newman settings are supported. You can find a full list [on the Newman docs](https://github.com/postmanlabs/newman#api-reference). This action uses the Node module under the hood, so ensure you are reading the API reference rather than the command line options. Alternatively, you can see the available options in `action.yml` in this repo.

Note that:
- GitHub Actions only supports `string`, `number` and `boolean` types. For fields that require objects/arrays, you will need to stringify them appropriately.
- `environment` and `globals` are only supported as a `string` in this Action. They cannot be passed stringified objects.

The following example demonstrates these notes in practice:

```
- uses: actions/checkout@master
- uses: matt-ball/newman-action@master
with:
collection: postman_collection.json
environment: postman_environment.json
reporters: '["emojitrain"]'
delayRequest: 5000
envVar: '[{ "key": "url", "value": "http://localhost:3000" }]'
```
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ inputs:
required: true
environment:
description: 'Environment to use'
envVar:
description: 'Environment variables'
globals:
description: 'Globals to use'
globalVar:
description: 'Global variables'
iterationCount:
description: 'Number of iterations to run on the collection'
iterationData:
Expand Down
18 changes: 9 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -254216,10 +254216,12 @@ async function init () {
apiKey: get('apiKey'),
collection: get('collection', required),
environment: get('environment'),
envVar: safeParse(get('envVar')),
globals: get('globals'),
globalVar: safeParse(get('globalVar')),
iterationCount: num(get('iterationCount')),
iterationData: get('iterationData'),
folder: split(get('folder')),
folder: safeParse(get('folder')),
workingDir: get('workingDir'),
insecureFileRead: safeParse(get('insecureFileRead')),
timeout: num(get('timeout')),
Expand All @@ -254230,13 +254232,13 @@ async function init () {
insecure: safeParse(get('insecure')),
bail: safeParse(get('bail')),
suppressExitCode: safeParse(get('suppressExitCode')),
reporters: split(get('reporters')),
reporters: safeParse(get('reporters')),
reporter: safeParse(get('reporter')),
color: get('color'),
sslClientCert: get('sslClientCert'),
sslClientKey: get('sslClientKey'),
sslClientPassphrase: get('sslClientPassphrase'),
sslClientCertList: split(get('sslClientCertList')),
sslClientCertList: safeParse(get('sslClientCertList')),
sslExtraCaCerts: get('sslExtraCaCerts'),
requestAgents: safeParse(get('requestAgents')),
cookieJar: get('cookieJar')
Expand Down Expand Up @@ -254287,20 +254289,18 @@ function num (i) {
return i
}

function split (str) {
return str ? str.split(',') : null
}

function removeEmpty (obj) {
return Object.entries(obj)
.filter(([_, v]) => v != null)
.reduce((acc, [k, v]) => ({ ...acc, [k]: v }), {})
}

function runNewman (options) {
newman.run(options).on('done', (err, summary) => {
newman.run(options, (err) => {
core.setFailed('Newman run failed! ' + (err || ''))
}).on('done', (err, summary) => {
if (!options.suppressExitCode && (err || summary.run.failures.length)) {
core.setFailed('Newman run failed!' + (err || ''))
core.setFailed('Newman run failed! ' + (err || ''))
}
})
}
Expand Down
18 changes: 9 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ async function init () {
apiKey: get('apiKey'),
collection: get('collection', required),
environment: get('environment'),
envVar: safeParse(get('envVar')),
globals: get('globals'),
globalVar: safeParse(get('globalVar')),
iterationCount: num(get('iterationCount')),
iterationData: get('iterationData'),
folder: split(get('folder')),
folder: safeParse(get('folder')),
workingDir: get('workingDir'),
insecureFileRead: safeParse(get('insecureFileRead')),
timeout: num(get('timeout')),
Expand All @@ -27,13 +29,13 @@ async function init () {
insecure: safeParse(get('insecure')),
bail: safeParse(get('bail')),
suppressExitCode: safeParse(get('suppressExitCode')),
reporters: split(get('reporters')),
reporters: safeParse(get('reporters')),
reporter: safeParse(get('reporter')),
color: get('color'),
sslClientCert: get('sslClientCert'),
sslClientKey: get('sslClientKey'),
sslClientPassphrase: get('sslClientPassphrase'),
sslClientCertList: split(get('sslClientCertList')),
sslClientCertList: safeParse(get('sslClientCertList')),
sslExtraCaCerts: get('sslExtraCaCerts'),
requestAgents: safeParse(get('requestAgents')),
cookieJar: get('cookieJar')
Expand Down Expand Up @@ -84,20 +86,18 @@ function num (i) {
return i
}

function split (str) {
return str ? str.split(',') : null
}

function removeEmpty (obj) {
return Object.entries(obj)
.filter(([_, v]) => v != null)
.reduce((acc, [k, v]) => ({ ...acc, [k]: v }), {})
}

function runNewman (options) {
newman.run(options).on('done', (err, summary) => {
newman.run(options, (err) => {
core.setFailed('Newman run failed! ' + (err || ''))
}).on('done', (err, summary) => {
if (!options.suppressExitCode && (err || summary.run.failures.length)) {
core.setFailed('Newman run failed!' + (err || ''))
core.setFailed('Newman run failed! ' + (err || ''))
}
})
}
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "newman-action",
"version": "0.3.7",
"version": "1.0.0",
"description": "Run Postman collections with Newman as a GitHub Action",
"main": "dist/index.js",
"repository": {
Expand Down