Skip to content

Commit 456fc3a

Browse files
authored
add check verb and tests (#200)
* add check verb and tests Signed-off-by: kpenfound <kyle@dagger.io> * enable calling dagger with check and pass check args through Signed-off-by: kpenfound <kyle@dagger.io> * checkout the repo with checks in it Signed-off-by: kpenfound <kyle@dagger.io> * fix checkout repo format Signed-off-by: kpenfound <kyle@dagger.io> * we still need to checkout the action Signed-off-by: kpenfound <kyle@dagger.io> * dont use check with -m Signed-off-by: kpenfound <kyle@dagger.io> * enable summary for check test Signed-off-by: kpenfound <kyle@dagger.io> * simplify should-run conditionals Signed-off-by: kpenfound <kyle@dagger.io> * safely quote inputs to check if they are set Signed-off-by: kpenfound <kyle@dagger.io> * fix output test Signed-off-by: kpenfound <kyle@dagger.io> * link to dagger/checks in readme Signed-off-by: kpenfound <kyle@dagger.io> * remove module from check example. This is not valid Signed-off-by: kpenfound <kyle@dagger.io> --------- Signed-off-by: kpenfound <kyle@dagger.io>
1 parent 662d9b6 commit 456fc3a

3 files changed

Lines changed: 70 additions & 10 deletions

File tree

.github/workflows/test.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,27 @@ jobs:
236236
exit 1
237237
fi
238238
239+
check:
240+
runs-on: "ubuntu-latest"
241+
steps:
242+
- uses: actions/checkout@v4
243+
- uses: actions/checkout@v6
244+
with:
245+
repository: "kpenfound/dag"
246+
ref: "3ea64a3711c2d785db3133dd380ae74ac1440f79"
247+
path: "./dag"
248+
- name: "Test check"
249+
uses: ./
250+
with:
251+
check: "**"
252+
workdir: "./dag/hello"
253+
enable-github-summary: true
254+
- name: "Test check"
255+
uses: ./
256+
with:
257+
verb: "check"
258+
workdir: "./dag/hello"
259+
239260
shell:
240261
runs-on: "ubuntu-latest"
241262
steps:

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,23 @@
22

33
## Usage Examples
44

5+
### `dagger check`
6+
7+
```yaml
8+
- name: Hello
9+
uses: dagger/dagger-for-github@v8.3.0
10+
with:
11+
check: "**"
12+
version: "latest" # semver vX.Y.Z
13+
```
14+
15+
Note: As a convenience for `dagger check` you can use the [dagger/checks](https://github.com/dagger/checks) action instead.
16+
517
### `dagger call`
618

719
```yaml
820
- name: Hello
9-
uses: dagger/dagger-for-github@v8.2.0
21+
uses: dagger/dagger-for-github@v8.3.0
1022
with:
1123
module: github.com/shykes/daggerverse/hello
1224
call: hello --greeting Hola --name Jeremy
@@ -18,7 +30,7 @@
1830

1931
```yaml
2032
- name: Hello
21-
uses: dagger/dagger-for-github@v8.2.0
33+
uses: dagger/dagger-for-github@v8.3.0
2234
with:
2335
shell: container | from alpine | with-exec echo,"hello, world!" | stdout
2436
cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN }}
@@ -28,7 +40,7 @@
2840

2941
```yaml
3042
- name: Integration Test
31-
uses: dagger/dagger-for-github@v8.2.0
43+
uses: dagger/dagger-for-github@v8.3.0
3244
with:
3345
workdir: db-service
3446
verb: run
@@ -55,6 +67,7 @@ By setting the version to `latest`, this action will install the latest version
5567
| `args` | Arguments to pass to CLI | false | '' |
5668
| `call` | Arguments to pass to CLI (Alias for args with verb:call) | false | '' |
5769
| `shell` | Arguments to pass to CLI (Alias for args with verb:shell) | false | '' |
70+
| `check` | Arguments to pass to CLI (Alias for args with verb:check) | false | '' |
5871
| `summary-path` | File path to write the job summary to | false | '' |
5972
| `enable-github-summary` | Whether to automatically write a GitHub Actions job summary | false | 'false' |
6073

action.yml

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ inputs:
1414
required: false
1515
default: "--progress plain"
1616
verb:
17-
description: "CLI verb (call, run, download, up, functions, shell, query)"
17+
description: "CLI verb (check, call, run, download, up, functions, shell, query)"
1818
required: false
1919
default: "call"
2020
workdir:
@@ -45,6 +45,10 @@ inputs:
4545
description: "Function and arguments for dagger shell"
4646
required: false
4747
default: ""
48+
check:
49+
description: "Function and arguments for dagger check"
50+
required: false
51+
default: ""
4852
summary-path:
4953
description: "File path to write the job summary"
5054
required: false
@@ -104,8 +108,25 @@ runs:
104108
BIN_DIR=${prefix_dir}/bin DAGGER_VERSION="$VERSION" DAGGER_COMMIT="$COMMIT" sh
105109
echo "::endgroup::"
106110
111+
- id: should-exec
112+
shell: bash
113+
env:
114+
INPUT_CALL: ${{ inputs.call }}
115+
INPUT_SHELL: ${{ inputs.shell }}
116+
INPUT_ARGS: ${{ inputs.args }}
117+
INPUT_CHECK: ${{ inputs.check }}
118+
INPUT_VERB: ${{ inputs.verb }}
119+
run: |
120+
# Determine if the user wants to execute a dagger command or just install
121+
if [[ -n "$INPUT_CALL" ]] || \
122+
[[ -n "$INPUT_SHELL" ]] || \
123+
[[ -n "$INPUT_ARGS" ]] || \
124+
[[ -n "$INPUT_CHECK" ]] || \
125+
[[ "$INPUT_VERB" != "call" ]]; then
126+
echo "result=true" >> "$GITHUB_OUTPUT"
127+
fi
107128
- id: assemble
108-
if: inputs.call != '' || inputs.shell != '' || inputs.args != ''
129+
if: steps.should-exec.outputs.result == 'true'
109130
shell: bash
110131
env:
111132
INPUT_MODULE: ${{ inputs.module }}
@@ -115,8 +136,13 @@ runs:
115136
dagger_flags=$(echo '${{ toJSON(inputs.dagger-flags) }}' | jq -rj .)
116137
args=$(echo '${{ toJSON(inputs.args) }}' | jq -rj .)
117138
call=$(echo '${{ toJSON(inputs.call) }}' | jq -rj .)
139+
check=$(echo '${{ toJSON(inputs.check) }}' | jq -rj .)
118140
if [[ -n "${{ inputs.call }}" ]]; then
119141
verb="call"
142+
elif [[ -n "$check" ]]; then
143+
verb="check"
144+
# check input is used as a trigger; don't pass glob patterns as args
145+
check=""
120146
elif [[ "$shell" != "" ]]; then
121147
verb=""
122148
script=$(mktemp)
@@ -127,13 +153,13 @@ runs:
127153
echo "dagger-flags=$dagger_flags" >> "$GITHUB_OUTPUT"
128154
echo "args=$args" >> "$GITHUB_OUTPUT"
129155
echo "call=$call" >> "$GITHUB_OUTPUT"
156+
echo "check=$check" >> "$GITHUB_OUTPUT"
130157
- id: exec
131-
if: inputs.call != '' || inputs.shell != '' || inputs.args != ''
158+
if: steps.should-exec.outputs.result == 'true'
132159
shell: bash
133160
env:
134161
INPUT_MODULE: ${{ inputs.module }}
135162
VERB: ${{ steps.assemble.outputs.verb }}
136-
CMD: ${{ steps.assemble.outputs.args || steps.assemble.outputs.call || steps.assemble.outputs.script }}
137163
SCRIPT: ${{ steps.assemble.outputs.script }}
138164
run: |
139165
tmpout=$(mktemp)
@@ -142,9 +168,9 @@ runs:
142168
DAGGER_CLOUD_TOKEN=${{ inputs.cloud-token }} \
143169
dagger \
144170
${{ steps.assemble.outputs.dagger-flags }} \
145-
${{ steps.assemble.outputs.verb }} \
171+
${VERB} \
146172
${INPUT_MODULE:+-m $INPUT_MODULE} \
147-
${{ steps.assemble.outputs.args || steps.assemble.outputs.call || steps.assemble.outputs.script }}; } 1> >(tee "${tmpout}") 2> >(tee "${tmperr}" >&2)
173+
${{ steps.assemble.outputs.args || steps.assemble.outputs.call || steps.assemble.outputs.script || steps.assemble.outputs.check }}; } 1> >(tee "${tmpout}") 2> >(tee "${tmperr}" >&2)
148174
149175
{
150176
# we need a delim that doesn't appear in the output - a hash of the
@@ -167,7 +193,7 @@ runs:
167193
summary_content(){
168194
echo -e "## Command\n"
169195
echo '```bash'
170-
cmd="dagger $VERB $CMD"
196+
cmd="dagger $VERB ${{ steps.assemble.outputs.args || steps.assemble.outputs.call || steps.assemble.outputs.script || steps.assemble.outputs.check }}"
171197
if [[ -n "$INPUT_MODULE" ]]; then
172198
echo -e -E "DAGGER_MODULE=\"$INPUT_MODULE\" $cmd"
173199
else

0 commit comments

Comments
 (0)