forked from dagger/dagger
-
Notifications
You must be signed in to change notification settings - Fork 0
191 lines (154 loc) · 6.19 KB
/
github.gen.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# This file was generated. See https://daggerverse.dev/mod/github.com/dagger/dagger/modules/gha
name: Github
"on":
push:
branches:
- main
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
workflow_dispatch: {}
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
github:
runs-on:
- ${{ github.repository == 'dagger/dagger' && 'dagger-g2-v0-15-0-4c' || 'ubuntu-latest' }}
name: Github
steps:
- name: Checkout
uses: actions/checkout@v4
- name: scripts/install-dagger.sh
id: install-dagger
run: |
#!/bin/bash
set -o pipefail
# Fallback to /usr/local for backwards compatability
prefix_dir="${RUNNER_TEMP:-/usr/local}"
# Ensure the dir is writable otherwise fallback to tmpdir
if [[ ! -d "$prefix_dir" ]] || [[ ! -w "$prefix_dir" ]]; then
prefix_dir="$(mktemp -d)"
fi
printf '%s/bin' "$prefix_dir" >> $GITHUB_PATH
# If the dagger version is 'latest', set the version back to an empty
# string. This allows the install script to detect and install the latest
# version itself
if [[ "$DAGGER_VERSION" == "latest" ]]; then
DAGGER_VERSION=
fi
# The install.sh script creates path ${prefix_dir}/bin
curl -fsS https://dl.dagger.io/dagger/install.sh | BIN_DIR=${prefix_dir}/bin sh
env:
DAGGER_VERSION: v0.15.0
shell: bash
- name: scripts/warm-engine.sh
id: warm-engine
run: |
#!/bin/bash
# Make sure not to load any implicit module
cd $(mktemp -d)
# Run a simple query to "warm up" the engine
echo '{directory{id}}' | dagger query
shell: bash
- name: scripts/exec.sh
id: exec
run: |
#!/bin/bash --noprofile --norc -e -o pipefail
if [[ -n "$DEBUG" && "$DEBUG" != "0" ]]; then
set -x
env
which dagger
pwd
ls -l
ps aux
fi
# Detect if a dev engine is available, if so: use that
# We don't rely on PATH because the GHA runner messes with that
if [[ -n "$_EXPERIMENTAL_DAGGER_CLI_BIN" ]]; then
export PATH=$(dirname "$_EXPERIMENTAL_DAGGER_CLI_BIN"):$PATH
fi
GITHUB_STEP_SUMMARY="${GITHUB_STEP_SUMMARY:=github-summary.md}"
export NO_COLOR="${NO_COLOR:=1}" # Disable colors in dagger logs
# Ensure the command is provided as an environment variable
if [ -z "$COMMAND" ]; then
echo "Error: Please set the COMMAND environment variable."
exit 1
fi
tmp=$(mktemp -d)
(
cd $tmp
# Create named pipes (FIFOs) for stdout and stderr
mkfifo stdout.fifo stderr.fifo
# Set up tee to capture and display stdout and stderr
tee stdout.txt < stdout.fifo &
tee stderr.txt < stderr.fifo >&2 &
)
# Run the command, capturing stdout and stderr in the FIFOs
set +e
eval "$COMMAND" > $tmp/stdout.fifo 2> $tmp/stderr.fifo
EXIT_CODE=$?
set -e
# Wait for all background jobs to finish
wait
# Extra trace URL
TRACE_URL=$(sed -En 's/^Full trace at (.*)/\1/p' < $tmp/stderr.txt)
{
cat <<'.'
## Dagger trace
.
if [[ "$TRACE_URL" == *"rotate dagger.cloud token for full url"* ]]; then
cat <<.
Cloud token must be rotated. Please follow these steps:
1. Go to [Dagger Cloud](https://dagger.cloud)
2. Click on your profile icon in the bottom left corner
3. Click on "Organization Settings"
4. Click on "Regenerate token"
5. Update the [\`DAGGER_CLOUD_TOKEN\` secret in your GitHub repository settings](https://github.com/${GITHUB_REPOSITORY:?Error: GITHUB_REPOSITORY is not set}/settings/secrets/actions/DAGGER_CLOUD_TOKEN)
.
elif [ -n "$TRACE_URL" ]; then
echo "[$TRACE_URL]($TRACE_URL)"
else
echo "No trace available. To setup: [https://dagger.cloud/traces/setup](https://dagger.cloud/traces/setup)"
fi
cat <<'.'
## Dagger version
```
.
dagger version
cat <<'.'
```
## Pipeline command
```bash
.
echo "DAGGER_MODULE=$DAGGER_MODULE \\"
echo " $COMMAND"
cat <<'.'
```
## Pipeline output
```
.
cat $tmp/stdout.txt
cat <<'.'
```
## Pipeline logs
```
.
tail -n 1000 $tmp/stderr.txt
cat <<'.'
```
.
} >"${GITHUB_STEP_SUMMARY}"
exit $EXIT_CODE
env:
_EXPERIMENTAL_DAGGER_CLOUD_TOKEN: dag_dagger_sBIv6DsjNerWvTqt2bSFeigBUqWxp9bhh3ONSSgeFnw
COMMAND: dagger call -q check
DAGGER_CLOUD_TOKEN: dag_dagger_sBIv6DsjNerWvTqt2bSFeigBUqWxp9bhh3ONSSgeFnw
DAGGER_MODULE: .github
shell: bash
timeout-minutes: 10