Skip to content

Commit dc10bbb

Browse files
committed
Add support for any command wrapper, not just strace
1 parent 12634ac commit dc10bbb

File tree

4 files changed

+308
-193
lines changed

4 files changed

+308
-193
lines changed

.github/workflows/test.yml

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ jobs:
2121
- name: Install dependencies
2222
run: npm ci
2323

24-
- name: Test wrapper with a simple action (no strace)
24+
- name: Test wrapper with a simple action (no wrapper)
2525
uses: ./
2626
with:
2727
action-ref: "actions/hello-world-javascript-action@main"
28-
enable-strace: "false"
28+
enable-wrapper: "false"
2929
input-who-to-greet: "World"
3030

3131
test-strace:
@@ -54,22 +54,59 @@ jobs:
5454
uses: ./
5555
with:
5656
action-ref: "actions/hello-world-javascript-action@main"
57-
enable-strace: "true"
58-
strace-options: "-f -v -s 256 -e trace=file,process,network,signal,ipc,desc,memory"
57+
wrapper-command: "strace -f -v -s 256 -e trace=file,process,network,signal,ipc,desc,memory"
5958
input-who-to-greet: "Strace"
6059

6160
- name: Check strace output
6261
run: |
63-
if [ -f "${{ steps.strace-test.outputs.strace-log }}" ]; then
64-
echo "Strace log file exists at ${{ steps.strace-test.outputs.strace-log }}"
65-
head -n 20 "${{ steps.strace-test.outputs.strace-log }}"
62+
if [ -f "${{ steps.strace-test.outputs.wrapper-log }}" ]; then
63+
echo "Wrapper log file exists at ${{ steps.strace-test.outputs.wrapper-log }}"
64+
head -n 20 "${{ steps.strace-test.outputs.wrapper-log }}"
6665
else
67-
echo "Strace log file not found!"
66+
echo "Wrapper log file not found!"
6867
exit 1
6968
fi
7069
7170
- name: Upload strace logs as artifact
7271
uses: actions/upload-artifact@v4
7372
with:
7473
name: strace-logs
75-
path: ${{ steps.strace-test.outputs.strace-log }}
74+
path: ${{ steps.strace-test.outputs.wrapper-log }}
75+
76+
test-time:
77+
runs-on: ubuntu-latest
78+
steps:
79+
- name: Checkout repository
80+
uses: actions/checkout@v3
81+
82+
- name: Setup Node.js
83+
uses: actions/setup-node@v3
84+
with:
85+
node-version: '16'
86+
87+
- name: Install dependencies
88+
run: npm ci
89+
90+
- name: Test wrapper with time command
91+
id: time-test
92+
uses: ./
93+
with:
94+
action-ref: "actions/hello-world-javascript-action@main"
95+
wrapper-command: "time -v"
96+
input-who-to-greet: "Time"
97+
98+
- name: Check time output
99+
run: |
100+
if [ -f "${{ steps.time-test.outputs.wrapper-log }}" ]; then
101+
echo "Time log file exists at ${{ steps.time-test.outputs.wrapper-log }}"
102+
cat "${{ steps.time-test.outputs.wrapper-log }}"
103+
else
104+
echo "Time log file not found!"
105+
exit 1
106+
fi
107+
108+
- name: Upload time logs as artifact
109+
uses: actions/upload-artifact@v4
110+
with:
111+
name: time-logs
112+
path: ${{ steps.time-test.outputs.wrapper-log }}

README.md

Lines changed: 67 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# TestifySec Action Wrapper
22

3-
A GitHub Action that downloads and executes another GitHub Action dynamically with optional strace instrumentation.
3+
A GitHub Action that downloads and executes another GitHub Action dynamically with optional command wrapping (strace, time, perf, etc.).
44

55
## Usage
66

@@ -15,22 +15,24 @@ jobs:
1515
- name: Checkout
1616
uses: actions/checkout@v3
1717
- name: Run Nested Action via Wrapper
18-
uses: testifysec/action-wrapper@v2
18+
uses: testifysec/action-wrapper@v3
1919
with:
2020
action-ref: "actions/hello-world-javascript-action@main"
2121
input-who-to-greet: "World" # Passed to the nested action as who-to-greet
22-
enable-strace: "true" # Enable strace instrumentation
22+
wrapper-command: "time -v" # Wrap with the 'time' command to measure performance
2323
```
2424
2525
## Inputs
2626
2727
| Input | Description | Required | Default |
2828
|-------|-------------|----------|---------|
2929
| `action-ref` | Reference to the nested action (e.g., owner/repo@ref) | Yes | |
30-
| `enable-strace` | Enable strace instrumentation | No | `true` |
31-
| `strace-options` | Options to pass to strace | No | `-f -v -s 256 -e trace=file,process,network,signal,ipc,desc,memory` |
30+
| `wrapper-command` | Command to wrap around the nested action execution (e.g., 'strace -f', 'time -v', etc.) | No | `strace -f -v -s 256 -e trace=file,process,network,signal,ipc,desc,memory` |
31+
| `enable-wrapper` | Enable command wrapping | No | `true` |
3232
| `input-*` | Any input with the prefix `input-` will be passed to the nested action | No | |
3333
| `extra-args` | Extra arguments to pass to the nested action (deprecated, use `input-*` instead) | No | |
34+
| `strace-options` | Options to pass to strace (deprecated, use `wrapper-command` instead) | No | |
35+
| `enable-strace` | Enable strace instrumentation (deprecated, use `enable-wrapper` instead) | No | |
3436

3537
### Passing Inputs to Nested Actions
3638

@@ -43,16 +45,18 @@ To pass inputs to the nested action, prefix them with `input-`. For example:
4345

4446
| Output | Description |
4547
|--------|-------------|
46-
| `strace-log` | Path to the strace output log file. The filename includes timestamp and action name for easy identification. |
48+
| `wrapper-log` | Path to the output log file for the wrapper command. The filename includes timestamp and action name for easy identification. |
49+
| `strace-log` | Path to the strace log file (deprecated, use `wrapper-log` instead). |
4750

4851
## Features
4952

53+
- **Any Command Wrapper**: Wrap actions with any command (strace, time, perf, ltrace, valgrind, etc.)
5054
- **Flexible Reference Handling**: Supports both tags (e.g., `v1.0.0`) and branch names (e.g., `main`)
5155
- **Smart Extraction**: Intelligently finds the extracted directory even if naming patterns change
5256
- **Format Flexibility**: Supports both `action.yml` and `action.yaml` metadata files
5357
- **Robust Error Handling**: Attempts alternative download URLs if the first one fails
5458
- **Dependency Management**: Automatically installs dependencies for the wrapped action
55-
- **Strace Integration**: Optionally traces system calls made by the wrapped action
59+
- **Command Output Logging**: Automatically captures command output to log files when appropriate
5660

5761
## How It Works
5862

@@ -68,77 +72,93 @@ To pass inputs to the nested action, prefix them with `input-`. For example:
6872
4. **Dependency Installation (Optional):**
6973
If a `package.json` is present in the nested action, it runs `npm install` to install dependencies.
7074

71-
5. **Strace Instrumentation (Optional):**
72-
If strace is enabled and available, the action runs the nested action with strace to trace system calls.
75+
5. **Command Wrapping (Optional):**
76+
If a wrapper command is enabled, the action runs the nested action with the specified command wrapped around it (e.g., strace, time, perf, etc.).
7377

7478
6. **Executing the Nested Action:**
75-
Finally, the wrapper runs the nested action's entry file using Node.js. Any extra arguments provided via the `extra-args` input are passed along.
79+
Finally, the wrapper runs the nested action's entry file using Node.js with any provided inputs.
7680

7781
## Examples
7882

79-
### Using with a Tagged Release
83+
### Using with a Performance Timer
8084

8185
```yaml
82-
- name: Run Release Version
83-
uses: testifysec/action-wrapper@v1
86+
- name: Run with Time Measurements
87+
id: time-action
88+
uses: testifysec/action-wrapper@v3
8489
with:
85-
action-ref: "actions/[email protected]"
90+
action-ref: "actions/hello-world-javascript-action@main"
91+
wrapper-command: "time -v"
92+
input-who-to-greet: "World"
93+
94+
- name: Upload Time Results
95+
uses: actions/upload-artifact@v4
96+
with:
97+
name: time-logs
98+
path: ${{ steps.time-action.outputs.wrapper-log }}
8699
```
87100

88-
### Using with a Branch
101+
### Using with System Call Tracing (Strace)
89102

90103
```yaml
91-
- name: Run Latest Version
92-
uses: testifysec/action-wrapper@v1
104+
- name: Run with Strace
105+
id: strace-action
106+
uses: testifysec/action-wrapper@v3
93107
with:
94108
action-ref: "actions/hello-world-javascript-action@main"
109+
wrapper-command: "strace -f -v -s 256 -e trace=file,process,network,signal,ipc,desc,memory"
110+
input-who-to-greet: "World"
111+
112+
- name: Upload Strace Results
113+
uses: actions/upload-artifact@v4
114+
with:
115+
name: strace-logs
116+
path: ${{ steps.strace-action.outputs.wrapper-log }}
95117
```
96118

97-
### Passing Inputs to the Nested Action
119+
### Using with Memory Profiling (Valgrind)
98120

99121
```yaml
100-
- name: Run with Inputs
101-
uses: testifysec/action-wrapper@v2
122+
- name: Run with Valgrind
123+
id: valgrind-action
124+
uses: testifysec/action-wrapper@v3
102125
with:
103-
action-ref: "some/action@v1"
104-
input-username: "octocat"
105-
input-token: ${{ secrets.GITHUB_TOKEN }}
106-
input-repository: ${{ github.repository }}
126+
action-ref: "actions/hello-world-javascript-action@main"
127+
wrapper-command: "valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all"
128+
input-who-to-greet: "World"
129+
130+
- name: Upload Valgrind Results
131+
uses: actions/upload-artifact@v4
132+
with:
133+
name: valgrind-logs
134+
path: ${{ steps.valgrind-action.outputs.wrapper-log }}
107135
```
108136

109-
### Using with Strace
137+
### Using with Linux Performance Counters (Perf)
110138

111139
```yaml
112-
- name: Run with Strace
113-
id: strace-action
114-
uses: testifysec/action-wrapper@v2.1.2
140+
- name: Run with Perf
141+
id: perf-action
142+
uses: testifysec/action-wrapper@v3
115143
with:
116144
action-ref: "actions/hello-world-javascript-action@main"
117-
enable-strace: "true"
118-
# Comprehensive tracing with improved verbosity
119-
strace-options: "-f -v -s 256 -e trace=file,process,network,signal,ipc,desc,memory"
120-
input-who-to-greet: "World" # Passed to the nested action as who-to-greet
145+
wrapper-command: "perf stat -e cycles,instructions,cache-references,cache-misses"
146+
input-who-to-greet: "World"
121147
122-
- name: Upload Strace Results
148+
- name: Upload Perf Results
123149
uses: actions/upload-artifact@v4
124150
with:
125-
name: strace-logs
126-
path: ${{ steps.strace-action.outputs.strace-log }}
151+
name: perf-logs
152+
path: ${{ steps.perf-action.outputs.wrapper-log }}
127153
```
128154

129-
The strace log will include a helpful header with:
130-
- Action reference
131-
- Timestamp
132-
- Command executed
133-
- Strace options used
134-
135-
### Disabling Strace
155+
### Running Without Any Wrapper
136156

137157
```yaml
138-
- name: Run Without Strace
139-
uses: testifysec/action-wrapper@v2
158+
- name: Run Direct (No Wrapper)
159+
uses: testifysec/action-wrapper@v3
140160
with:
141161
action-ref: "actions/hello-world-javascript-action@main"
142-
enable-strace: "false"
143-
input-who-to-greet: "World" # Passed to the nested action as who-to-greet
144-
```
162+
enable-wrapper: "false"
163+
input-who-to-greet: "World"
164+
```

action.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
11
name: "TestifySec Action Wrapper"
2-
description: "Downloads and executes another GitHub Action with optional strace instrumentation"
2+
description: "Downloads and executes another GitHub Action with optional command wrapping (strace, time, etc.)"
33
inputs:
44
action-ref:
55
description: "Reference to the nested action (e.g., owner/repo@ref)"
66
required: true
77
extra-args:
88
description: "Extra arguments to pass to the nested action (deprecated, use input-* instead)"
99
required: false
10+
wrapper-command:
11+
description: "Command to wrap around the nested action execution (e.g., 'strace -f', 'time -v', etc.)"
12+
required: false
13+
enable-wrapper:
14+
description: "Enable command wrapping (default: true)"
15+
required: false
16+
default: "true"
17+
# For backward compatibility
1018
strace-options:
11-
description: "Options to pass to strace (default: '-f -v -s 256 -e trace=file,process,network,signal,ipc,desc,memory')"
19+
description: "Options to pass to strace (deprecated, use wrapper-command instead)"
1220
required: false
1321
enable-strace:
14-
description: "Enable strace instrumentation (default: true)"
22+
description: "Enable strace instrumentation (deprecated, use enable-wrapper instead)"
1523
required: false
16-
default: "true"
1724
# Any input with the prefix 'input-' will be passed to the nested action
1825
# For example, input-who-to-greet will be passed as who-to-greet to the nested action
1926
outputs:
27+
wrapper-log:
28+
description: "Path to the output log file for the wrapper command (if enabled and applicable)"
29+
# For backward compatibility
2030
strace-log:
21-
description: "Path to the strace output log file (if strace was enabled and successful)"
31+
description: "Path to the strace log file (deprecated, use wrapper-log instead)"
2232
runs:
2333
using: "node16"
2434
main: "index.js"

0 commit comments

Comments
 (0)