Skip to content

Commit 3f8759f

Browse files
committed
Add Bash support
1 parent bcfbeb2 commit 3f8759f

File tree

5 files changed

+29
-9
lines changed

5 files changed

+29
-9
lines changed

.github/workflows/test_run_funcs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ jobs:
4141
ruby_second.json
4242
4343
test_pre_hook
44+
45+
bash_string
46+
bash.json
4447
)
4548
4649
status=0

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ more languages' examples you can find [here](https://github.com/gitx-io/ActionSe
3838
| Haskell | ⬜️ not supported yet |
3939
| Elixir | ⬜️ not supported yet |
4040
| PHP | ⬜️ not supported yet |
41+
| Bash | - |
4142

4243
## Documents
4344

parse_funcs.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
'.hs': 'haskell',
1515
'.exs': 'elixir',
1616
'.php': 'php',
17+
'.sh': 'bash',
1718
}
1819

1920
COMMENT_PREFIX = {
@@ -24,7 +25,8 @@
2425
'node': '//',
2526
'haskell': '--',
2627
'elixir': '#',
27-
'php': '//'
28+
'php': '//',
29+
'bash': '#',
2830
}
2931

3032

@@ -61,7 +63,8 @@ def parse(path):
6163
glob('*.pl') + \
6264
glob('*.hs') + \
6365
glob('*.exs') + \
64-
glob('*.php')
66+
glob('*.php') + \
67+
glob('*.sh')
6568

6669
for f in files:
6770
ext_name = os.path.splitext(f)[1]

run_funcs.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
'elixir',
1717
'haskell',
1818
'php',
19+
'bash',
1920
]
2021

2122
RUN_CMDS = {
@@ -59,13 +60,16 @@ def run_fun(func_path, func):
5960
'node': '[ -f package.json ] && npm install --only=prod >/dev/null 2>&1',
6061
'perl': '[ -f cpanfile ] && cpanm --installdeps . >/dev/null 2>&1'}
6162

62-
cmd = ['docker', 'run', '--rm', '--workdir', '/github/workspace',
63-
'-v', ROOT_DIR + ':/github/workspace',
64-
docker_image(func_lang) + ':latest', 'sh', '-c',
65-
"cd " + os.path.relpath(func_path, ROOT_DIR) + ";" +
66-
deps_install.get(func_lang, ':') + ";" +
67-
run_pre_hook + ";" +
68-
RUN_CMDS[func_lang] + " " + func_file_name]
63+
if func_lang == 'bash':
64+
cmd = ["bash", os.path.join(func_path, func_file_name)]
65+
else:
66+
cmd = ['docker', 'run', '--rm', '--workdir', '/github/workspace',
67+
'-v', ROOT_DIR + ':/github/workspace',
68+
docker_image(func_lang) + ':latest', 'sh', '-c',
69+
"cd " + os.path.relpath(func_path, ROOT_DIR) + ";" +
70+
deps_install.get(func_lang, ':') + ";" +
71+
run_pre_hook + ";" +
72+
RUN_CMDS[func_lang] + " " + func_file_name]
6973

7074
output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
7175
return output.decode("utf8")

test/func_samples/function.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
# GET /test/result/bash_string
4+
5+
echo "hello, world"
6+
7+
# GET /test/result/bash.json
8+
9+
echo '{"hello": "bash"}'

0 commit comments

Comments
 (0)