Skip to content

Commit fc8bcb9

Browse files
authored
use as a setup action (#1)
1 parent 64674f3 commit fc8bcb9

File tree

4 files changed

+78
-14
lines changed

4 files changed

+78
-14
lines changed

.github/workflows/ci.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
push:
5+
jobs:
6+
monkey-help:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v1
10+
- uses: ./
11+
with:
12+
command: help
13+
14+
monkey-update:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v1
18+
- uses: ./
19+
with:
20+
command: update
21+
args: -vv
22+
workdir: .github/workflows
23+
api_key: ${{ secrets.FUZZYMONKEY_API_KEY }}
24+
github_token: ${{ secrets.github_token }}
25+
26+
setup-monkey:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v1
30+
- uses: ./
31+
- run: monkey version

README.md

+31-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
# GitHub Action: Run [@FuzzyMonkeyCo](https://github.com/FuzzyMonkeyCo)'s [`monkey`](https://github.com/FuzzyMonkeyCo/monkey)
22

3-
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/FuzzyMonkeyCo/action-monkey?logo=github&sort=semver)](https://github.com/FuzzyMonkeyCo/action-monkey/releases)
3+
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/FuzzyMonkeyCo/setup-monkey?logo=github&sort=semver)](https://github.com/FuzzyMonkeyCo/setup-monkey/releases)
44

5-
This action fetches & runs [`monkey`](https://github.com/FuzzyMonkeyCo/monkey) on GitHub workflows to run `monkey` tests.
5+
This action installs [`monkey`](https://github.com/FuzzyMonkeyCo/monkey) on GitHub workflows to run `monkey` tests.
6+
7+
```yml
8+
name: fuzzymonkey
9+
on: [pull_request]
10+
jobs:
11+
monkey-lint:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v1
15+
- uses: FuzzyMonkeyCo/setup-monkey@v1
16+
- run: monkey lint
17+
```
618
719
## Inputs
820
### `command`
9-
**Required.** `monkey` command to run (e.g. `fuzz` or `fmt`).
21+
Optional. `monkey` command to run (e.g. `fuzz` or `fmt`).
1022
### `args`
1123
Optional. Arguments to the command.
1224
### `workdir`
@@ -28,14 +40,27 @@ Seed returned by `monkey pastseed`. Non-empty when just ran `monkey fuzz` & foun
2840
```yml
2941
name: fuzzymonkey
3042
on: [pull_request]
43+
jobs:
44+
monkey-lint:
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v1
48+
- uses: FuzzyMonkeyCo/setup-monkey@v1
49+
- run: monkey lint
50+
```
51+
52+
### Run a command
53+
```yml
54+
name: fuzzymonkey
55+
on: [pull_request]
3156
jobs:
3257
monkey-fuzz:
3358
name: Run monkey fuzz
3459
runs-on: ubuntu-latest
3560
steps:
3661
- uses: actions/checkout@v1
3762
- name: Monkey fuzz
38-
uses: FuzzyMonkeyCo/action-monkey@v1
63+
uses: FuzzyMonkeyCo/setup-monkey@v1
3964
with:
4065
command: fuzz
4166
```
@@ -54,7 +79,7 @@ jobs:
5479
steps:
5580
- uses: actions/checkout@v1
5681
- name: Monkey fmt
57-
uses: FuzzyMonkeyCo/action-monkey@v1
82+
uses: FuzzyMonkeyCo/setup-monkey@v1
5883
with:
5984
command: fmt
6085
workdir: ./subdirectory/
@@ -66,7 +91,7 @@ jobs:
6691
steps:
6792
- uses: actions/checkout@v1
6893
- name: Monkey fuzz
69-
uses: FuzzyMonkeyCo/action-monkey@v1
94+
uses: FuzzyMonkeyCo/setup-monkey@v1
7095
with:
7196
command: fuzz
7297
args: --time-budget-overall=30m

action.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: fuzzy-monkey
1+
name: setup-monkey
22
description: 🐵 Run @FuzzyMonkeyCo's monkey command
33
author: fenollp (Pierre Fenoll)
44

@@ -9,7 +9,7 @@ branding:
99
inputs:
1010
command:
1111
description: '`monkey` command to run (ex. `fuzz` or `fmt`)'
12-
required: true
12+
required: false
1313
args:
1414
description: Arguments to the command
1515
required: false
@@ -22,7 +22,7 @@ inputs:
2222
required: false
2323
github_token:
2424
description: GITHUB_TOKEN, to tame download rate-limiting
25-
required: true
25+
required: false
2626
default: ${{ github.token }}
2727

2828
outputs:

script.sh

+13-5
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,30 @@ set -o pipefail
66
cd "$GITHUB_WORKSPACE"
77
cd "$INPUT_WORKDIR"
88

9-
TMPATH="$(mktemp -d)"
9+
TMPATH="$RUNNER_TEMP/.fuzzymonkey"
10+
mkdir -p "$TMPATH"
11+
echo "$TMPATH" >>"$GITHUB_PATH"
1012
PATH="$TMPATH:$PATH"
1113

1214
echo '::group:: Installing monkey ... https://github.com/FuzzyMonkeyCo/monkey'
1315
curl -sfL https://raw.githubusercontent.com/FuzzyMonkeyCo/monkey/master/.godownloader.sh | BINDIR="$TMPATH" sh
1416
monkey --version
1517
echo '::endgroup::'
1618

17-
if [[ -n "$INPUT_APIKEY" ]]; then
18-
export FUZZYMONKEY_API_KEY="$INPUT_APIKEY"
19+
if [[ -z "$INPUT_COMMAND" ]]; then
20+
# No command given: this is a setup action
21+
exit 0
1922
fi
2023

2124
echo "::group:: $ cd $INPUT_WORKDIR && monkey $INPUT_COMMAND $INPUT_ARGS"
2225
set +e
23-
# shellcheck disable=SC2086
24-
monkey "$INPUT_COMMAND" $INPUT_ARGS; code=$?
26+
if [[ -n "$INPUT_APIKEY" ]]; then
27+
# shellcheck disable=SC2086
28+
FUZZYMONKEY_API_KEY="$INPUT_APIKEY" monkey "$INPUT_COMMAND" $INPUT_ARGS; code=$?
29+
else
30+
# shellcheck disable=SC2086
31+
monkey "$INPUT_COMMAND" $INPUT_ARGS; code=$?
32+
fi
2533
set -e
2634
echo "::set-output name=code::$code"
2735
if [[ $code -eq 6 ]]; then

0 commit comments

Comments
 (0)