Skip to content

Commit 48111c8

Browse files
committed
Commenter
Signed-off-by: apostasie <spam_blackhole@farcloser.world>
1 parent 57031b1 commit 48111c8

File tree

13 files changed

+399
-102
lines changed

13 files changed

+399
-102
lines changed

.github/actions/wax/action.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: "Wax: commenting component"
2+
3+
description: "A simple reporter adding or updating a comment on PRs."
4+
5+
inputs:
6+
body:
7+
default: "Body of the comment"
8+
description: "Body of the comment"
9+
github-token:
10+
description: "Auth token"
11+
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Commenting
16+
uses: actions/github-script@v7
17+
with:
18+
github-token: ${{inputs.github-token}}
19+
script: |
20+
let comments = await github.rest.issues.listComments({
21+
issue_number: context.issue.number,
22+
owner: context.repo.owner,
23+
repo: context.repo.repo,
24+
})
25+
26+
let found = 0
27+
let body = ""
28+
comments.data.forEach(function(comment){
29+
if (comment.user.login === context.repo.login) {
30+
found = comment.id
31+
body = comment.body
32+
}
33+
})
34+
35+
if (found === 0){
36+
github.rest.issues.createComment({
37+
issue_number: context.issue.number,
38+
owner: context.repo.owner,
39+
repo: context.repo.repo,
40+
body: "${{ inputs.body }}\n"
41+
})
42+
}else{
43+
github.rest.issues.updateComment({
44+
comment_id: found,
45+
owner: context.repo.owner,
46+
repo: context.repo.repo,
47+
body: body + "\n${{ inputs.body }}\n"
48+
})
49+
}

.github/matchers/tigron.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "tigron",
5+
"pattern": [
6+
{
7+
"regexp": "^([^:]+):(\\d+):(\\d+):\\s+(error|warning):\\s+(.*)$",
8+
"severity": 1,
9+
"file": 2,
10+
"line": 3,
11+
"column": 4,
12+
"message": 5
13+
}
14+
]
15+
}
16+
]
17+
}

.github/workflows/job-test-in-container.yml

Lines changed: 80 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ jobs:
158158
# Besides, each job is running on a different instance, which means using host network here
159159
# is safe and has no side effects on others.
160160
[ "${{ inputs.target }}" == "rootful" ] \
161-
&& args=(test-integration ./hack/test-integration.sh -test.allow-modify-users=true) \
162-
|| args=(test-integration-${{ inputs.target }} /test-integration-rootless.sh ./hack/test-integration.sh)
161+
&& args=(test-integration ./hack/testing/integration.sh -test.allow-modify-users=true) \
162+
|| args=(test-integration-${{ inputs.target }} /test-integration-rootless.sh ./hack/testing/integration.sh)
163163
if [ "${{ inputs.ipv6 }}" == true ]; then
164-
docker run --network host -t --rm --privileged -e GITHUB_STEP_SUMMARY="$GITHUB_STEP_SUMMARY" -v "$GITHUB_STEP_SUMMARY":"$GITHUB_STEP_SUMMARY" -e WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622:-} "${args[@]}" -test.only-flaky=false -test.only-ipv6 -test.target=${{ inputs.binary }}
164+
docker run --name test-runner --network host -t --privileged -e GITHUB_STEP_SUMMARY="$GITHUB_STEP_SUMMARY" -v "$GITHUB_STEP_SUMMARY":"$GITHUB_STEP_SUMMARY" -e WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622:-} "${args[@]}" -test.only-flaky=false -test.only-ipv6 -test.target=${{ inputs.binary }}
165165
else
166-
docker run -t --rm --privileged -e GITHUB_STEP_SUMMARY="$GITHUB_STEP_SUMMARY" -v "$GITHUB_STEP_SUMMARY":"$GITHUB_STEP_SUMMARY" -e WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622:-} "${args[@]}" -test.only-flaky=false -test.target=${{ inputs.binary }}
166+
docker run --name test-runner -t --privileged -e GITHUB_STEP_SUMMARY="$GITHUB_STEP_SUMMARY" -v "$GITHUB_STEP_SUMMARY":"$GITHUB_STEP_SUMMARY" -e WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622:-} "${args[@]}" -test.only-flaky=false -test.target=${{ inputs.binary }}
167167
fi
168168
# FIXME: this NEEDS to go away
169169
- name: "Run: integration tests (flaky)"
@@ -172,18 +172,87 @@ jobs:
172172
github::md::h2 "flaky" >> "$GITHUB_STEP_SUMMARY"
173173
174174
[ "${{ inputs.target }}" == "rootful" ] \
175-
&& args=(test-integration ./hack/test-integration.sh) \
176-
|| args=(test-integration-${{ inputs.target }} /test-integration-rootless.sh ./hack/test-integration.sh)
175+
&& args=(test-integration ./hack/testing/integration.sh) \
176+
|| args=(test-integration-${{ inputs.target }} /test-integration-rootless.sh ./hack/testing/integration.sh)
177177
if [ "${{ inputs.ipv6 }}" == true ]; then
178-
docker run --network host -t --rm --privileged -e GITHUB_STEP_SUMMARY="$GITHUB_STEP_SUMMARY" -v "$GITHUB_STEP_SUMMARY":"$GITHUB_STEP_SUMMARY" -e WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622:-} "${args[@]}" -test.only-flaky=true -test.only-ipv6 -test.target=${{ inputs.binary }}
178+
docker run --name test-runner-flaky --network host -t --privileged -e GITHUB_STEP_SUMMARY="$GITHUB_STEP_SUMMARY" -v "$GITHUB_STEP_SUMMARY":"$GITHUB_STEP_SUMMARY" -e WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622:-} "${args[@]}" -test.only-flaky=true -test.only-ipv6 -test.target=${{ inputs.binary }}
179179
else
180-
docker run -t --rm --privileged -e GITHUB_STEP_SUMMARY="$GITHUB_STEP_SUMMARY" -v "$GITHUB_STEP_SUMMARY":"$GITHUB_STEP_SUMMARY" -e WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622:-} "${args[@]}" -test.only-flaky=true -test.target=${{ inputs.binary }}
180+
docker run --name test-runner-flaky -t --privileged -e GITHUB_STEP_SUMMARY="$GITHUB_STEP_SUMMARY" -v "$GITHUB_STEP_SUMMARY":"$GITHUB_STEP_SUMMARY" -e WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622:-} "${args[@]}" -test.only-flaky=true -test.target=${{ inputs.binary }}
181181
fi
182182
183183
- name: Logs
184-
if: ${{ failure() }}
184+
if: ${{ failure() || success() }}
185+
run: |
186+
# Get the reports from inside the containers
187+
[ "${{ inputs.target }}" == "rootful" ] && src=/root || src=/home/rootless
188+
mkdir -p ~/report
189+
docker cp test-runner:$src/nerdctl-test-report ~/report/main || true
190+
# Flaky may not have run
191+
docker cp test-runner-flaky:$src/nerdctl-test-report ~/report/flaky 2>/dev/null || true
192+
- name: Logs
193+
id: artifact-upload
194+
if: ${{ failure() || success() }}
185195
uses: actions/upload-artifact@v4
186196
with:
187-
name: "System logs"
188-
path: ~/debug-logs.tar.gz
197+
name: logs-${{ inputs.binary }}-${{ inputs.target }}-${{ inputs.runner }}-${{ inputs.ipv6 }}-${{ inputs.canary }}-${{ inputs.containerd-version }}-${{ inputs.rootlesskit-version }}
198+
path: ~/report/*
189199
retention-days: 1
200+
201+
- name: Annotate
202+
if: ${{ failure() || success() }}
203+
run: |
204+
echo "::add-matcher::.github/matchers/tigron.json"
205+
echo "::error title=ErrorReport::MEH .github/workflows/job-test-in-host.yml${{steps.artifact-upload-step.outputs.artifact-url}}"
206+
echo "::notice title=NoticeReport::SHEESH ${{steps.artifact-upload-step.outputs.artifact-url}}"
207+
echo "::error file=cmd/nerdctl/main_test_test.go,line=1,endLine=10,title=AgainErrorReport::FOO ${{steps.artifact-upload-step.outputs.artifact-url}}"
208+
echo "::error file=cmd/nerdctl/main_test.go,line=38,endLine=41,title=AgainErrorReport::BLA ${{steps.artifact-upload-step.outputs.artifact-url}}"
209+
echo "Error: TestFooFoo "
210+
pwd
211+
ls -lA cmd/nerdctl/main_test_test.go || true
212+
# ::workflow-command parameter1={data},parameter2={data}::{command value}
213+
echo "::remove-matcher owner=tigron::"
214+
215+
# - name: "Comment report"
216+
# if: ${{ failure() }}
217+
# uses: ./.github/actions/wax
218+
# with:
219+
# body: "body test (in-container)"
220+
# github-token: ${{ secrets.GITHUB_TOKEN }}
221+
# steps.artifact-upload-step.outputs.artifact-url
222+
223+
# - name: Commenting
224+
# if: ${{ failure() || success() }}
225+
# uses: actions/github-script@v7
226+
# with:
227+
# github-token: ${{ secrets.GITHUB_TOKEN }}
228+
# script: |
229+
# let comments = await github.rest.issues.listComments({
230+
# issue_number: context.issue.number,
231+
# owner: context.repo.owner,
232+
# repo: context.repo.repo,
233+
# })
234+
#
235+
# let found = 0
236+
# let body = ""
237+
# comments.data.forEach(function(comment){
238+
# if (comment.user.login === context.repo.login) {
239+
# found = comment.id
240+
# body = comment.body
241+
# }
242+
# })
243+
#
244+
# if (found === 0){
245+
# github.rest.issues.createComment({
246+
# issue_number: context.issue.number,
247+
# owner: context.repo.owner,
248+
# repo: context.repo.repo,
249+
# body: "${{steps.artifact-upload-step.outputs.artifact-url}}\n"
250+
# })
251+
# }else{
252+
# github.rest.issues.updateComment({
253+
# comment_id: found,
254+
# owner: context.repo.owner,
255+
# repo: context.repo.repo,
256+
# body: body + "${{steps.artifact-upload-step.outputs.artifact-url}}\n"
257+
# })
258+
# }

.github/workflows/job-test-in-host.yml

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,22 +183,33 @@ jobs:
183183
make install-dev-tools
184184
echo "::endgroup::"
185185
186+
187+
- if: ${{ env.SHOULD_RUN == 'yes' }}
188+
name: "Init: prepare artifacts repo"
189+
run: |
190+
mkdir -p ~/report/main
191+
mkdir -p ~/report/ipv6
192+
mkdir -p ~/report/flaky
193+
186194
# ipv6 is tested only on linux
187-
- if: ${{ contains(inputs.runner, 'ubuntu') && env.SHOULD_RUN == 'yes' }}
195+
- if: ${{ env.SHOULD_RUN == 'yes' && contains(inputs.runner, 'ubuntu' )}}
188196
name: "Run (linux): integration tests (IPv6)"
189197
run: |
190198
. ./hack/github/action-helpers.sh
191199
github::md::h2 "ipv6" >> "$GITHUB_STEP_SUMMARY"
192200
193-
./hack/test-integration.sh -test.target=${{ inputs.binary }} -test.only-ipv6
201+
ln -s ~/report/ipv6 ~/debug
202+
./hack/testing/integration.sh -test.target=${{ inputs.binary }} -test.only-ipv6
194203
195204
- if: ${{ env.SHOULD_RUN == 'yes' }}
196205
name: "Run: integration tests"
197206
run: |
198207
. ./hack/github/action-helpers.sh
199208
github::md::h2 "non-flaky" >> "$GITHUB_STEP_SUMMARY"
200209
201-
./hack/test-integration.sh -test.target=${{ inputs.binary }} -test.only-flaky=false
210+
rm -f ~/debug
211+
ln -s ~/report/main ~/debug
212+
./hack/testing/integration.sh -test.target=${{ inputs.binary }} -test.only-flaky=false
202213
203214
# FIXME: this must go
204215
- if: ${{ env.SHOULD_RUN == 'yes' }}
@@ -207,4 +218,40 @@ jobs:
207218
. ./hack/github/action-helpers.sh
208219
github::md::h2 "flaky" >> "$GITHUB_STEP_SUMMARY"
209220
210-
./hack/test-integration.sh -test.target=${{ inputs.binary }} -test.only-flaky=true
221+
rm -f ~/debug
222+
ln -s ~/report/flaky ~/debug
223+
./hack/testing/integration.sh -test.target=${{ inputs.binary }} -test.only-flaky=true
224+
225+
- name: "DEBUG"
226+
if: ${{ env.SHOULD_RUN == 'yes' && (failure() || success()) }}
227+
run: |
228+
ls -lAR ~/report
229+
230+
- name: "Run: upload logs"
231+
if: ${{ env.SHOULD_RUN == 'yes' && (failure() || success()) }}
232+
uses: actions/upload-artifact@v4
233+
with:
234+
name: logs-${{ inputs.binary }}-${{ inputs.runner }}-${{ inputs.canary }}
235+
path: ~/report/*
236+
retention-days: 1
237+
238+
- name: Annotate
239+
if: ${{ failure() || success() }}
240+
run: |
241+
echo "::add-matcher::.github/matchers/tigron.json"
242+
echo "::error title=ErrorReport::MEH .github/workflows/job-test-in-host.yml${{steps.artifact-upload-step.outputs.artifact-url}}"
243+
echo "::notice title=NoticeReport::SHEESH ${{steps.artifact-upload-step.outputs.artifact-url}}"
244+
echo "::error file=cmd/nerdctl/main_test_test.go,line=1,endLine=10,title=AgainErrorReport::FOO ${{steps.artifact-upload-step.outputs.artifact-url}}"
245+
echo "::error file=cmd/nerdctl/main_test.go,line=38,endLine=41,title=AgainErrorReport::BLA ${{steps.artifact-upload-step.outputs.artifact-url}}"
246+
echo "Error: TestFooFoo "
247+
pwd
248+
ls -lA cmd/nerdctl/main_test_test.go || true
249+
# ::workflow-command parameter1={data},parameter2={data}::{command value}
250+
echo "::remove-matcher owner=tigron::"
251+
252+
# - name: "Comment report"
253+
# if: ${{ env.SHOULD_RUN == 'yes' && (failure() || success()) }}
254+
# uses: ./.github/actions/wax
255+
# with:
256+
# body: "body test (docker)"
257+
# github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/job-test-in-lima.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,18 @@ jobs:
104104
set -eux
105105
if [ "$TARGET" = "rootless" ]; then
106106
echo "rootless"
107-
docker run -t -v /dev:/dev --rm --privileged test-integration /test-integration-rootless.sh ./hack/test-integration.sh -test.only-flaky=false
107+
docker run -t -v /dev:/dev --rm --privileged test-integration /test-integration-rootless.sh ./hack/testing/integration.sh -test.only-flaky=false
108108
else
109109
echo "rootful"
110-
docker run -t -v /dev:/dev --rm --privileged test-integration ./hack/test-integration.sh -test.only-flaky=false
110+
docker run -t -v /dev:/dev --rm --privileged test-integration ./hack/testing/integration.sh -test.only-flaky=false
111111
fi
112112
- name: "Run: integration tests (flaky)"
113113
run: |
114114
set -eux
115115
if [ "$TARGET" = "rootless" ]; then
116116
echo "rootless"
117-
docker run -t -v /dev:/dev --rm --privileged test-integration /test-integration-rootless.sh ./hack/test-integration.sh -test.only-flaky=true
117+
docker run -t -v /dev:/dev --rm --privileged test-integration /test-integration-rootless.sh ./hack/testing/integration.sh -test.only-flaky=true
118118
else
119119
echo "rootful"
120-
docker run -t -v /dev:/dev --rm --privileged test-integration ./hack/test-integration.sh -test.only-flaky=true
120+
docker run -t -v /dev:/dev --rm --privileged test-integration ./hack/testing/integration.sh -test.only-flaky=true
121121
fi

.github/workflows/workflow-test.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,20 @@ jobs:
111111
ipv6: ${{ matrix.ipv6 && true || false }}
112112
canary: ${{ matrix.canary && true || false }}
113113

114+
reporter:
115+
needs: test-integration-container
116+
runs-on: ubuntu-24.04
117+
steps:
118+
- name: Download all workflow run artifacts
119+
uses: actions/download-artifact@v4
120+
with:
121+
path: ~/debug
122+
- name: Process
123+
run: |
124+
ls -lA ~/debug
125+
exit 1
126+
127+
114128
test-integration-host:
115129
name: "in-host${{ inputs.hack }}"
116130
uses: ./.github/workflows/job-test-in-host.yml

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ RUN curl -o nydus-static.tgz -fsSL --proto '=https' --tlsv1.2 "https://github.co
350350
tar xzf nydus-static.tgz && \
351351
mv nydus-static/nydus-image nydus-static/nydusd nydus-static/nydusify /usr/bin/ && \
352352
rm nydus-static.tgz
353-
CMD ["./hack/test-integration.sh"]
353+
CMD ["./hack/testing/integration.sh"]
354354

355355
FROM test-integration AS test-integration-rootless
356356
# Install SSH for creating systemd user session.
@@ -373,7 +373,7 @@ RUN systemctl disable test-integration-ipfs-offline
373373
VOLUME /home/rootless/.local/share
374374
COPY ./Dockerfile.d/test-integration-rootless.sh /
375375
RUN chmod a+rx /test-integration-rootless.sh
376-
CMD ["/test-integration-rootless.sh", "./hack/test-integration.sh"]
376+
CMD ["/test-integration-rootless.sh", "./hack/testing/integration.sh"]
377377

378378
# test for CONTAINERD_ROOTLESS_ROOTLESSKIT_PORT_DRIVER=slirp4netns
379379
FROM test-integration-rootless AS test-integration-rootless-port-slirp4netns

cmd/nerdctl/issues/main_linux_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ package issues
1919
import (
2020
"testing"
2121

22+
"gotest.tools/v3/assert"
23+
2224
"github.com/containerd/nerdctl/mod/tigron/expect"
2325
"github.com/containerd/nerdctl/mod/tigron/test"
2426

@@ -58,3 +60,19 @@ func TestIssue108(t *testing.T) {
5860

5961
testCase.Run(t)
6062
}
63+
64+
func TestFail(t *testing.T) {
65+
assert.Assert(t, false, "boo")
66+
}
67+
68+
func TestSkip(t *testing.T) {
69+
t.Skip("skip this test is likely to fail")
70+
}
71+
72+
func TestFlaky(t *testing.T) {
73+
testCase := nerdtest.Setup()
74+
testCase.Require = nerdtest.IsFlaky("glndkjnf")
75+
testCase.Run(t)
76+
77+
assert.Assert(t, true, "boo")
78+
}

cmd/nerdctl/main_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import (
2020
"errors"
2121
"testing"
2222

23+
"gotest.tools/v3/assert"
24+
2325
"github.com/containerd/containerd/v2/defaults"
2426
"github.com/containerd/nerdctl/mod/tigron/expect"
2527
"github.com/containerd/nerdctl/mod/tigron/require"
@@ -33,6 +35,10 @@ func TestMain(m *testing.M) {
3335
testutil.M(m)
3436
}
3537

38+
func TestBlanketFailure(t *testing.T) {
39+
assert.Assert(t, false, "This is a blanket failure to test logs capture and reporting")
40+
}
41+
3642
// TestUnknownCommand tests https://github.com/containerd/nerdctl/issues/487
3743
func TestUnknownCommand(t *testing.T) {
3844
testCase := nerdtest.Setup()

0 commit comments

Comments
 (0)