Skip to content

Commit d6db826

Browse files
authored
Merge pull request #13 from bugout-dev/locust-update
Aded locust.yml and lint.yml to work with new app
2 parents 4299736 + a03937d commit d6db826

2 files changed

Lines changed: 68 additions & 0 deletions

File tree

.github/workflows/lint.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Lint Bugout python
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-20.04
8+
steps:
9+
- uses: actions/checkout@v2
10+
- uses: actions/setup-python@v2
11+
with:
12+
python-version: "3.8"
13+
- name: Install test requirements
14+
run: pip install -r requirements.dev.txt
15+
- name: Mypy type check
16+
run: mypy bugout/
17+
- name: Black syntax check
18+
run: black --check bugout/

.github/workflows/locust.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Locust summary
2+
3+
on: [pull_request_target]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-20.04
8+
steps:
9+
- name: PR head repo
10+
id: head_repo_name
11+
run: |
12+
HEAD_REPO_NAME=$(jq -r '.pull_request.head.repo.full_name' "$GITHUB_EVENT_PATH")
13+
echo "PR head repo: $HEAD_REPO_NAME"
14+
echo "::set-output name=repo::$HEAD_REPO_NAME"
15+
- name: Checkout git repo
16+
uses: actions/checkout@v2
17+
with:
18+
repository: ${{ steps.head_repo_name.outputs.repo }}
19+
fetch-depth: 0
20+
- name: Install python
21+
uses: actions/setup-python@v2
22+
with:
23+
python-version: "3.8"
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip setuptools
27+
pip install bugout-locust
28+
- name: Generate Locust summary
29+
run: |
30+
COMMENTS_URL=$(python -c 'import json; import os; event = os.environ.get("GITHUB_EVENT_PATH"); raw = open(event); inp_json = json.load(raw); print(inp_json.get("pull_request").get("_links").get("comments").get("href")); raw.close();')
31+
INITIAL_REF=$(locust.github initial)
32+
TERMINAL_REF=$(locust.github terminal)
33+
REPO_URL=$(locust.github repo)
34+
locust --format json $INITIAL_REF $TERMINAL_REF --github $REPO_URL --metadata "{\"comments_url\": \"${COMMENTS_URL}\", \"terminal_hash\": \"$TERMINAL_REF\"}" | tee summary
35+
- name: Cleaning summary
36+
id: clean_summary
37+
run: |
38+
summary=$(cat summary)
39+
summary="${summary//'%'/'%25'}"
40+
summary="${summary//$'\n'/'%0A'}"
41+
summary="${summary//$'\r'/'%0D'}"
42+
echo "::set-output name=summary::$summary"
43+
- name: Upload locust results to Bugout
44+
env:
45+
BUGOUT_SECRET: ${{ secrets.BUGOUT_SECRET }}
46+
run: |
47+
curl -k -X POST "https://spire.bugout.dev/github/summary" \
48+
-H "Content-Type: application/json" \
49+
-H "Authorization: Bearer $BUGOUT_SECRET" \
50+
--data '${{ steps.locust.outputs.summary }}'

0 commit comments

Comments
 (0)