|
| 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