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

chore: run basic examples as tests #2006

Merged
merged 7 commits into from
Aug 11, 2023
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
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"es6": true
},
"globals": {
"expect": true
"expect": true,
"fetch": true
},
"parserOptions": {
"ecmaVersion": "latest",
Expand Down
88 changes: 88 additions & 0 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Examples

on:
push:
branches: [main]
pull_request:
workflow_dispatch:

kettanaito marked this conversation as resolved.
Show resolved Hide resolved
env:
ARTILLERY_BINARY_PATH: ${{ github.workspace }}/packages/artillery/bin/run

jobs:
http-metrics-by-endpoint:
runs-on: ubuntu-latest
timeout-minutes: 10
env:
CWD: ./examples/http-metrics-by-endpoint
defaults:
run:
working-directory: ${{ env.CWD }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install
run: npm ci

- name: Test
uses: artilleryio/action-cli@v1
with:
command: run ./endpoint-metrics.yml
working-directory: ${{ env.CWD }}
env:
ARTILLERY_BINARY_PATH: ${{ env.ARTILLERY_BINARY_PATH }}

multiple-scenarios-spec:
runs-on: ubuntu-latest
timeout-minutes: 10
env:
CWD: ./examples/multiple-scenario-specs
defaults:
run:
working-directory: ${{ env.CWD }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install
run: npm ci

- name: Run armadillo scenario
uses: artilleryio/action-cli@v1
with:
command: run --config ./common-config.yml ./scenarios/armadillo.yml
working-directory: ${{ env.CWD }}
env:
ARTILLERY_BINARY_PATH: ${{ env.ARTILLERY_BINARY_PATH }}

- name: Run dino scenario
uses: artilleryio/action-cli@v1
with:
command: run --config ./common-config.yml ./scenarios/dino.yml
working-directory: ${{ env.CWD }}
env:
ARTILLERY_BINARY_PATH: ${{ env.ARTILLERY_BINARY_PATH }}

using-data-from-csv:
runs-on: ubuntu-latest
timeout-minutes: 10
env:
CWD: ./examples/using-data-from-csv
defaults:
run:
working-directory: ${{ env.CWD }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install
run: npm ci

- name: Test
uses: artilleryio/action-cli@v1
with:
command: run ./website-test.yml
working-directory: ${{ env.CWD }}
env:
ARTILLERY_BINARY_PATH: ${{ env.ARTILLERY_BINARY_PATH }}
2 changes: 1 addition & 1 deletion examples/websockets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ npm install
After installing the dependencies, start the WebSockets server:

```
node app.js
npm run server
```

This command will start a WebSockets server listening at ws://localhost:8888.
Expand Down
16 changes: 10 additions & 6 deletions examples/websockets/package-lock.json

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

4 changes: 2 additions & 2 deletions examples/websockets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"description": "Artillery.io - WebSockets example",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"server": "node app.js",
"test": "artillery run test.yml"
},
"author": "",
"license": "ISC",
"dependencies": {
"artillery": "^1.7.2",
Expand Down
18 changes: 18 additions & 0 deletions examples/websockets/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
config:
target: 'ws://localhost:8888/'
processor: './my-functions.js'
phases:
- duration: 60
arrivalRate: 25

scenarios:
- name: 'Sending a string'
engine: ws
flow:
- send: 'Artillery'

- name: 'Sending an object from a function'
engine: ws
flow:
- function: 'createRandomScore'
- send: '{{ data }}'
18 changes: 0 additions & 18 deletions examples/websockets/websockets.yml

This file was deleted.