Skip to content

Commit

Permalink
Merge pull request #40 from matt-ball/v1
Browse files Browse the repository at this point in the history
multiple fixes v1
  • Loading branch information
matt-ball authored Oct 8, 2021
2 parents b46f18d + 833848a commit 3bf3cf3
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 20 deletions.
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

0 comments on commit 3bf3cf3

Please sign in to comment.