Skip to content
Open
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
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
insert_final_newline = true

[*.json]
insert_final_newline = true

[*.bru]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
9 changes: 9 additions & 0 deletions .github/bruno-collection/bruno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"version": "1",
"name": "bruno-run-action-tests",
"type": "collection",
"ignore": [
"node_modules",
".git"
]
}
Empty file.
1 change: 1 addition & 0 deletions .github/bruno-collection/dummy.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo,bar
31 changes: 31 additions & 0 deletions .github/bruno-collection/echo/echo json.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
meta {
name: echo json
type: http
seq: 1
}

post {
url: {{host}}/api/echo/json
body: json
auth: none
}

body:json {
{
"hello": "bruno"
}
}

assert {
res.status: eq 200
}

tests {
test("should return json", function() {
const data = res.getBody();
expect(data).to.eql({
"hello": "bruno"
});
});

}
27 changes: 27 additions & 0 deletions .github/bruno-collection/echo/echo plaintext.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
meta {
name: echo plaintext
type: http
seq: 3
}

post {
url: {{host}}/api/echo/text
body: text
auth: none
}

body:text {
hello
}

assert {
res.status: eq 200
}

tests {
test("should return plain text", function() {
const data = res.getBody();
expect(data).to.eql("hello");
});

}
35 changes: 35 additions & 0 deletions .github/bruno-collection/echo/echo xml parsed.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
meta {
name: echo xml parsed
type: http
seq: 2
}

post {
url: {{host}}/api/echo/xml-parsed
body: xml
auth: none
}

body:xml {
<hello>
<world>bruno</world>
</hello>
}

assert {
res.status: eq 200
}

tests {
test("should return parsed xml", function() {
const data = res.getBody();
expect(data).to.eql({
"hello": {
"world": [
"bruno"
]
}
});
});

}
39 changes: 39 additions & 0 deletions .github/bruno-collection/echo/secret/echo secret.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
meta {
name: echo secret
type: http
seq: 1
}

post {
url: {{host}}/api/echo/json
body: json
auth: none
}

auth:basic {
username: asd
password: j
}

auth:bearer {
token:
}

body:json {
{
"{{secretKey}}": "{{secretMessage}}"
}
}

assert {
res.status: eq 200
}

tests {
test("should return secret message", () => {
expect(res.getBody()).to.eql({
"hello": "secret world!"
});
});

}
7 changes: 7 additions & 0 deletions .github/bruno-collection/environments/cicd.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
vars {
host: https://testbench-sanity.usebruno.com
}
vars:secret [
secretKey,
secretMessage
]
23 changes: 23 additions & 0 deletions .github/bruno-collection/ping.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
meta {
name: ping
type: http
seq: 1
}

get {
url: {{host}}/ping
body: none
auth: none
}

assert {
res.status: eq 200
~res.body: eq {{pong}}
}

tests {
test("should ping pong", function() {
const data = res.getBody();
expect(data).to.equal("pong");
});
}
21 changes: 21 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: 2
updates:
- package-ecosystem: docker
directory: /
schedule:
interval: weekly
groups:
docker-minor:
update-types:
- minor
- patch

- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
groups:
actions-minor:
update-types:
- minor
- patch
6 changes: 6 additions & 0 deletions .github/linters/.checkov.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
quiet: true
skip-check:
# Ensure that HEALTHCHECK instructions have been added to container images
- CKV_DOCKER_2
# Ensure that a user for the container has been created
- CKV_DOCKER_3
3 changes: 3 additions & 0 deletions .github/linters/.hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ignored:
- DL3018
- DL3059
10 changes: 10 additions & 0 deletions .github/linters/.yaml-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
rules:
document-end: disable
document-start:
level: warning
present: false
line-length:
level: warning
max: 100
allow-non-breakable-words: true
allow-non-breakable-inline-mappings: true
15 changes: 15 additions & 0 deletions .github/workflows/ci.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
BRUNO_ACTION_DRY_RUN=true
IN_BAIL=true
IN_CA_CERT=customcert.pem
IN_CSV_FILEPATH=.github/bruno-collection/dummy.csv
IN_ENV=cicd
IN_ENV_VARS=apikey=myPassword\nid=myId
IN_FILENAME=users/get-user.bru
IN_IGNORE_TRUSTSTORE=true
IN_INSECURE=true
IN_OUTPUT=output.html
IN_OUTPUT_FORMAT=html
IN_PATH=.
IN_RECURSIVE=true
IN_SANDBOX=safe
IN_TESTS_ONLY=true
129 changes: 129 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: Continuous Integration

on:
pull_request:
branches:
- main
push:
branches:
- main

permissions:
contents: read

jobs:
test-docker:
name: Docker Tests
runs-on: ubuntu-latest

# Run a local registry to push to
services:
registry:
image: registry:2
ports:
- 5001:5000

env:
TEST_TAG: localhost:5001/actions/bruno-run-action:latest
RUN_OUTPUT: run-output.log

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Setup Docker BuildX
id: setup-buildx
uses: docker/setup-buildx-action@v3
with:
install: true
driver-opts: network=host

- name: Build the Container
id: build
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.TEST_TAG }}

# prettier-ignore
- name: Run the Container
id: run
run: docker run --env-file .github/workflows/ci.env --rm ${{ env.TEST_TAG }} > ${{ env.RUN_OUTPUT }}

# prettier-ignore
- name: Assert output
id: assert
run: |
cat ${{ env.RUN_OUTPUT }}
grep -q 'run users/get-user.bru' ${{ env.RUN_OUTPUT }} || (echo '::error::incorrect collection path' && exit 1)
grep -q '\-r' ${{ env.RUN_OUTPUT }} || (echo '::error::-r was not supplied' && exit 1)
grep -q '\-\-ignore\-truststore' ${{ env.RUN_OUTPUT }} || (echo '::error::--ignore-truststore was not applied' && exit 1)
grep -q '\-\-env cicd' ${{ env.RUN_OUTPUT }} || (echo '::error::incorrect --env supplied' && exit 1)
grep -q '\-\-env\-var apikey=myPassword' ${{ env.RUN_OUTPUT }} || (echo '::error::incorrect --env-var for apikey' && exit 1)
grep -q '\-\-env\-var id=myId' ${{ env.RUN_OUTPUT }} || (echo '::error::incorrect --env-var for id' && exit 1)
grep -q '\-\-output /usr/src/output.html' ${{ env.RUN_OUTPUT }} || (echo '::error::incorrect --output path' && exit 1)
grep -q '\-\-format html' ${{ env.RUN_OUTPUT }} || (echo '::error::incorrect --format' && exit 1)
grep -q '\-\-cacert customcert.pem' ${{ env.RUN_OUTPUT }} || (echo '::error::incorrect --ca-cert path' && exit 1)
grep -q '\-\-insecure' ${{ env.RUN_OUTPUT }} || (echo '::error::--insecure was not applied' && exit 1)
grep -q '\-\-sandbox safe' ${{ env.RUN_OUTPUT }} || (echo '::error::--sandbox was not supplied' && exit 1)
grep -q '\-\-tests\-only' ${{ env.RUN_OUTPUT }} || (echo '::error::--tests-only was not supplied' && exit 1)
grep -q '\-\-csv\-file\-path' ${{ env.RUN_OUTPUT }} || (echo '::error::--csv-file-path was not supplied' && exit 1)
grep -q '\-\-bail' ${{ env.RUN_OUTPUT }} || (echo '::error::--bail was not supplied' && exit 1)

bru-run-successfully:
name: Action Successful Run
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Test Local Action
id: bru-run
uses: ./
with:
path: .github/bruno-collection
env: cicd
env-vars: |-
secretKey='${{ secrets.CI_TEST_SECRET_KEY }}'
secretMessage='${{ secrets.CI_TEST_SECRET_MESSAGE }}'
output: bru-run-output.json
output-format: json
insecure: true
tests-only: false
bail: false

- name: Succeed if run was successful
if: ${{ steps.bru-run.outputs.success == 'true' }}
run: exit 0

- name: Fail if run was not successful
if: ${{ steps.bru-run.outputs.success == 'false' }}
run: exit 1

bru-run-failure:
name: Action Failure Run
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Test Local Action
id: bru-run
continue-on-error: true
uses: ./
with:
path: .github/bruno-collection
tests-only: false
bail: true

- name: Succeed if run was not successful
if: ${{ steps.bru-run.outputs.success == 'false' }}
run: exit 0

- name: Fail if run was successful
if: ${{ steps.bru-run.outputs.success == 'true' }}
run: exit 1
Loading