Skip to content

krummbar/bruno-run-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Bruno Run Action

Continuous Integration Lint Codebase

Containerized GitHub Action executing bruno cli runner. Can be used to execute sanity checks and integration tests via bruno collections. Internally executes @usebruno/cli@1.x, passing the action’s input parameters to the command line interface.

Usage

The following example runs a collection located in the folder bruno/api-it. It uses the bruno environment integration, and provides the secret environment variables foo=bar and say=hello. The runner results are dumped to the JSON file ./output.json.

Run full collection with secrets
name: Bruno Test Collection

on:
  workflow_dispatch:

jobs:
  bruno-tests:
    name: Bruno test collection
    runs-on: ubuntu-latest
    steps:
      - name: Bruno CLI runner
        id: bru-cli
        uses: krummbar/bruno-run-action@main # (1)
        with:
          path: bruno/api-it
          env: integration
          env-vars: |- # (2)
            foo=bar
            say='${{ secrets.MESSAGE }}'
          output: output.json
          output-format: json
  1. Change @main to a specific commit SHA or version tag, e.g.:
    krummbar/bruno-run-action@e76147da8e5c81eaf017dede5645551d4b94427b
    krummbar/bruno-run-action@v0.1.0

  2. envVars need to be separated with line breaks

Run single request
name: Bruno Run Individual Folder

on:
  workflow_dispatch:

jobs:
  bruno-tests:
    name: Bruno test collection
    runs-on: ubuntu-latest
    steps:
      - name: Bruno CLI runner
        id: bru-cli
        uses: krummbar/bruno-run-action@main
        with:
          path: bruno/api-it # (1)
          filename: echo # (2)
          recursive: true # (3)
  1. Path to bruno collection

  2. Relative path of the request folder inside the collection

  3. Includes all requests in subfolders

Inputs

csv-file-path:
  description: CSV file pat for input parameters
  required: false
path:
  description: >-
    Path of the target bruno collection.
    Should point to the root directory of the collection.
    If not provided it uses the current working directory.
  required: false
  default: .
filename:
  description: >-
    File or folder name of the requests to run.
    It is relative to the `path` input.
  required: false
recursive:
  description: Indicate a recursive run.
  required: false
  default: 'false'
ca-cert:
  description: CA certificate to verify peer against.
  required: false
env:
  description: Select a collection environment.
  required: false
  default: ''
env-vars:
  description: List of environment variables to set with the run.
  required: false
  default: ''
output:
  description: >-
    Output file containing test results.
    The path is relative to the current working-directory and not to the targeted bruno collection.
  required: false
output-format:
  description: >-
    The output format of the test results.
    Possible values `html|json|junit`.
  required: false
  default: json
insecure:
  description: Allow insecure server connections.
  required: false
  default: 'false'
tests-only:
  description: Only run requests that have a test.
  required: false
bail:
  description: Stop execution after a failure of a request, test, or assertion.
  required: false

Outputs

success:
  description: Indicates test run success status.
bru-version:
  description: Bruno CLI version used during workflow execution.

Development

Test Locally

After you’ve cloned the repository to your local machine or codespace, you’ll need to perform some initial setup steps before you can test your action.

ℹ️

You’ll need to have a reasonably modern version of Docker handy (e.g. docker engine version 20 or later).

  1. 🛠️ Build the container

    docker build -t bruno-run-action-local .
  2. ✅ Test the container

    You can pass individual environment variables using the --env or -e flag.

    $ docker run --env INPUT_PATH=".github/bruno-collection" --env INPUT_ENV="cicd" --env BRUNO_ACTION_DRY_RUN="true" -v ${PWD}:/usr/src bruno-run-action-local
    ::notice::collection directory: '/usr/src/.github/bruno-collection'
    ::notice::bru run  --env cicd
    ::notice::Executed in dry mode, skipped executing bruno collection

    Or you can pass a file with environment variables using --env-file.

    $ docker run --env-file .github/workflows/ci.env -v ${PWD}/.github:/usr/src/.github bruno-run-action-local
    ::notice::collection directory: '/usr/src/.github/bruno-collection'
    ::notice::bru run users/get-user.bru -r --env cicd --output /usr/src/output.html --format html --insecure --tests-only --bail --env-var apikey=myPassword --env-var id=myId
    ::notice::Executed in dry mode, skipped executing bruno collection
    💡

    If BRUNO_ACTION_DRY_RUN=true is provided, execution of the actual collection is skipped. Only the fully composed bru run command with all arguments is dumped.

Documentation

The README.adoc file is generated from the sources in the docs folder. Any documentation changes must be applied to the files located in there.

In order to update the contents of the README.adoc run the following command.

Update README.adoc
asciidoctor-reducer --preserve-conditionals -o README.adoc docs/index.adoc