Skip to content

Commit fd08609

Browse files
author
Mcgrof Chamberlain
committed
adding ci files
1 parent 0af2f6b commit fd08609

File tree

9 files changed

+589
-0
lines changed

9 files changed

+589
-0
lines changed

.github/actions/archive/action.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
---
3+
name: Archive results
4+
description: Archive kdevops results in https://github.com/linux-kdevops/kdevops-results-archive.git
5+
inputs:
6+
dir:
7+
description: 'Directory'
8+
required: true
9+
default: 'workdir'
10+
runs:
11+
using: "composite"
12+
steps:
13+
- name: Get systemd journal files
14+
working-directory: ${{ inputs.dir }}/kdevops
15+
shell: bash
16+
run: |
17+
make journal-dump
18+
19+
- name: Build our kdevops archive results
20+
working-directory: ${{ inputs.dir }}/kdevops
21+
shell: bash
22+
run: |
23+
make ci-archive CI_WORKFLOW="${{ inputs.ci_workflow }}"
24+

.github/actions/cleanup/action.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
---
3+
name: Cleanup kdevops VMs
4+
description: Destroy VMs and cleanup workspace
5+
6+
inputs:
7+
dir:
8+
description: 'Directory'
9+
required: true
10+
default: 'workdir'
11+
12+
runs:
13+
using: "composite"
14+
steps:
15+
- name: Run kdevops make destroy
16+
working-directory: ${{ inputs.dir }}/kdevops
17+
shell: bash
18+
run: |
19+
make destroy
20+
21+
- name: Remove working-directory
22+
shell: bash
23+
run: |
24+
rm --recursive --force --verbose ${{ inputs.dir }}

.github/actions/setup/action.yml

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
---
3+
name: Setup kdevops
4+
description: Setup kdevops workspace
5+
6+
inputs:
7+
dir:
8+
description: 'Directory'
9+
required: true
10+
default: 'workdir'
11+
kernel_tree:
12+
required: false
13+
type: string
14+
default: 'linux'
15+
kernel_ref:
16+
required: false
17+
type: string
18+
default: 'master'
19+
ci_workflow:
20+
required: false
21+
type: string
22+
default: 'demo'
23+
24+
runs:
25+
using: "composite"
26+
steps:
27+
- name: Create workspace directory
28+
shell: bash
29+
run: |
30+
pwd
31+
rm --recursive --force --verbose ${{ inputs.dir }}
32+
mkdir --parent --verbose ${{ inputs.dir }}
33+
find .
34+
35+
- name: Configure git
36+
shell: bash
37+
run: |
38+
git config --global --add safe.directory '*'
39+
git config --global user.name "kdevops"
40+
git config --global user.email "kdevops@lists.linux.dev"
41+
42+
- name: Checkout kdevops
43+
working-directory: ${{ inputs.dir }}
44+
shell: bash
45+
run: |
46+
rm --recursive --force --verbose kdevops/
47+
git clone https://github.com/dkruces/kdevops.git --branch ci-workflow kdevops
48+
49+
- name: Checkout custom branch with delta on kdevops/linux
50+
working-directory: ${{ inputs.dir }}/kdevops
51+
shell: bash
52+
run: |
53+
set -euxo pipefail
54+
LINUX_TREE="/mirror/${{ inputs.kernel_tree }}.git"
55+
LINUX_TREE_REF="${{ inputs.kernel_ref }}"
56+
git clone $LINUX_TREE linux
57+
cd linux
58+
git checkout $LINUX_TREE_REF
59+
git log -1
60+
61+
- name: Make sure our repo kdevops defconfig exists
62+
id: defconfig
63+
working-directory: ${{ inputs.dir }}/kdevops
64+
shell: bash
65+
run: |
66+
set -euxo pipefail
67+
if [[ -z "${{ inputs.kdevops_defconfig }}" ]]; then
68+
KDEVOPS_DEFCONFIG=${{ inputs.ci_workflow }}
69+
else
70+
KDEVOPS_DEFCONFIG="${{ inputs.kdevops_defconfig }}"
71+
fi
72+
73+
if [[ ! -f defconfigs/$KDEVOPS_DEFCONFIG ]]; then
74+
echo "kdevops lacks a defconfig for this repository, expected to find: defconfigs/$KDEVOPS_DEFCONFIG"
75+
exit 1
76+
fi
77+
78+
"${{ github.workspace }}/scripts/github_output.sh" KDEVOPS_DEFCONFIG "$KDEVOPS_DEFCONFIG"
79+
80+
- name: Initialize CI metadata for kdevops-results-archive for linux
81+
id: metadata
82+
working-directory: ${{ inputs.dir }}/kdevops/linux
83+
shell: bash
84+
run: |
85+
set -euxo pipefail
86+
echo "${{ inputs.kernel_tree }}" > ../ci.trigger
87+
echo "testing" > ../ci.subject
88+
echo "${{ inputs.kernel_ref }}" > ../ci.ref
89+
90+
RELEVANT_GIT_TAG=$(cat ../ci.ref)
91+
RELEVANT_GIT_REF=$(git rev-parse --short=12 $RELEVANT_GIT_TAG)
92+
93+
"${{ github.workspace }}/scripts/github_output.sh" LINUX_GIT_REF "$RELEVANT_GIT_REF"
94+
"${{ github.workspace }}/scripts/github_output.sh" LINUX_GIT_TAG "$RELEVANT_GIT_TAG"
95+
96+
# Start out pessimistic
97+
echo "unknown" > ../ci.result
98+
echo "Nothing to write home about." > ../ci.commit_extra
99+
100+
- name: Run a quick Linux kernel defconfig build test
101+
working-directory: ${{ inputs.dir }}/kdevops/linux
102+
env:
103+
LINUX_GIT_TAG: ${{ steps.metadata.outputs.LINUX_GIT_TAG }}
104+
shell: bash
105+
run: |
106+
set -euxo pipefail
107+
git reset --hard "$LINUX_GIT_TAG"
108+
make defconfig
109+
make -j$(nproc)
110+
111+
- name: Run kdevops make defconfig-repo
112+
working-directory: ${{ inputs.dir }}/kdevops
113+
env:
114+
LINUX_GIT_TAG: ${{ steps.metadata.outputs.LINUX_GIT_TAG }}
115+
LINUX_GIT_REF: ${{ steps.metadata.outputs.LINUX_GIT_REF }}
116+
KDEVOPS_DEFCONFIG: ${{ steps.defconfig.outputs.KDEVOPS_DEFCONFIG }}
117+
shell: bash
118+
run: |
119+
LINUX_TREE="/mirror/${{ inputs.kernel_tree }}.git"
120+
LINUX_TREE_REF="$LINUX_GIT_TAG"
121+
122+
# We make the compromise here to use a relevant git tag for the
123+
# host prefix so that folks can easily tell what exact kernel tree
124+
# is being tested by using the relevant git ref. That is, if you
125+
# pushed a tree with the .github/ directory as the top of the tree,
126+
# that commit will not be used, we'll use the last one as that is
127+
# the relevant git ref we want to annotate a test for.
128+
#
129+
# The compromise here is that we expect no two same identical tests
130+
# on the same self-hosted server. We could extend this with something
131+
# like github.run_id but its not yet clear if we can have kdevops
132+
# hosts with a bundled prefix ID like that ref-runid-testname. Tests
133+
# have been done with the full lenght sha1sum though and we know that
134+
# does work.
135+
KDEVOPS_HOSTS_PREFIX="$LINUX_GIT_REF"
136+
137+
echo "Going to use defconfig-$KDEVOPS_DEFCONFIG"
138+
139+
echo "Linux tree: $LINUX_TREE"
140+
echo "Linux trigger ref: $LINUX_TREE_REF"
141+
echo "Linux tag: $LINUX_GIT_TAG"
142+
echo "Runner ID: ${{ github.run_id }}"
143+
echo "kdevops host prefix: $KDEVOPS_HOSTS_PREFIX"
144+
echo "kdevops defconfig: defconfig-$KDEVOPS_DEFCONFIG"
145+
146+
KDEVOPS_ARGS="\
147+
KDEVOPS_HOSTS_PREFIX=$KDEVOPS_HOSTS_PREFIX \
148+
LINUX_TREE=$LINUX_TREE \
149+
LINUX_TREE_REF=$LINUX_TREE_REF \
150+
ANSIBLE_CFG_CALLBACK_PLUGIN="debug" \
151+
defconfig-$KDEVOPS_DEFCONFIG"
152+
echo "Going to run:"
153+
echo "make $KDEVOPS_ARGS"
154+
155+
make $KDEVOPS_ARGS
156+
157+
- name: Run kdevops make
158+
working-directory: ${{ inputs.dir }}/kdevops
159+
shell: bash
160+
run: |
161+
make -j$(nproc)
162+
163+
- name: Run kdevops make bringup
164+
working-directory: ${{ inputs.dir }}/kdevops
165+
shell: bash
166+
run: |
167+
ls -ld linux
168+
make destroy
169+
make bringup
170+
171+
- name: Build linux and boot test nodes on test kernel
172+
working-directory: ${{ inputs.dir }}/kdevops
173+
shell: bash
174+
run: |
175+
make linux
176+
177+
- name: Build required ci tests
178+
working-directory: ${{ inputs.dir }}/kdevops
179+
shell: bash
180+
run: |
181+
make ci-build-test CI_WORKFLOW=${{ inputs.ci_workflow }}

.github/actions/test/action.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
---
3+
name: Setup kdevops
4+
description: Setup kdevops workspace
5+
6+
inputs:
7+
dir:
8+
description: 'Directory'
9+
required: true
10+
default: 'workdir'
11+
ci_workflow:
12+
required: false
13+
type: string
14+
default: 'demo'
15+
16+
runs:
17+
using: "composite"
18+
steps:
19+
- name: Run CI tests
20+
working-directory: ${{ inputs.dir }}/kdevops
21+
shell: bash
22+
run: |
23+
make ci-test CI_WORKFLOW="${{ inputs.ci_workflow }}"
24+
25+
echo -e "Kernel tests results:\n" > ci.commit_extra
26+
27+
- name: Generate CI commit info
28+
working-directory: ${{ inputs.dir }}/kdevops
29+
shell: bash
30+
run: |
31+
find workflows/blktests/results/last-run/ -name '*.dmesg.log' \
32+
-exec tail -n 1 {} + >> ci.commit_extra
33+
34+
echo -e "\n\n" >> ci.commit_extra
35+
echo -e "Userspace test results:\n" >> ci.commit_extra
36+
find workflows/blktests/results/last-run/ -name '*.userspace.log' \
37+
-exec tail -n 1 {} + >> ci.commit_extra
38+
echo -e "\n\n" >> ci.commit_extra
39+
40+
if grep -i -q "fail" ci.commit_extra ; then
41+
echo "fail" > ci.result
42+
else
43+
echo "ok" > ci.result
44+
fi

.github/workflows/main.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
---
3+
name: Run kdevops CI Workflow - Reusable
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
ci_workflow:
9+
description: "CI Workflow"
10+
required: true
11+
default: 'blktests_nvme'
12+
type: string
13+
kernel_tree:
14+
description: "Linux kernel tree to use"
15+
required: true
16+
default: 'linux'
17+
type: string
18+
kernel_ref:
19+
description: "Linux tree git reference (branch/tag/commit-id)"
20+
required: true
21+
default: 'master'
22+
type: string
23+
24+
jobs:
25+
check_ref:
26+
name: Check Linux kernel Git Reference
27+
runs-on: [self-hosted]
28+
steps:
29+
- name: Checkout repo
30+
uses: actions/checkout@v4
31+
32+
- name: Check kernel_ref exists
33+
id: check_kernel_ref
34+
run: |
35+
set -euxo pipefail
36+
37+
ref="${{ github.event.inputs.kernel_ref }}"
38+
tree="${{ github.event.inputs.kernel_tree }}"
39+
mirror="/mirror/${tree}.git"
40+
ls_remote="$(git ls-remote "$mirror" "refs/*/${ref}" || true)"
41+
contains_branch="$(git -C "$mirror" branch --contains "${ref}" || true)"
42+
contains_tag="$(git -C "$mirror" branch --contains "${ref}" || true)"
43+
44+
if [ -z "$ls_remote" ] && [ -z "$contains_branch" ] && [ -z "$contains_tag" ]; then
45+
echo "Linux kernel ${ref} does not exist."
46+
exit 1
47+
fi
48+
49+
setup:
50+
name: Setup kdevops workspace
51+
runs-on: [self-hosted]
52+
needs: [check_ref]
53+
steps:
54+
- name: Checkout kdevops-ci
55+
uses: actions/checkout@v4
56+
57+
- name: kdevops setup
58+
uses: ./.github/actions/setup
59+
with:
60+
dir: ${{ inputs.ci_workflow }}
61+
kernel_tree: ${{ inputs.kernel_tree }}
62+
kernel_ref: ${{ inputs.kernel_ref }}
63+
ci_workflow: ${{ inputs.ci_workflow }}
64+
65+
test:
66+
name: Run kdevops ci-test
67+
runs-on: [self-hosted]
68+
needs: [setup]
69+
steps:
70+
- name: kdevops ci-test
71+
uses: ./.github/actions/test
72+
with:
73+
dir: ${{ inputs.ci_workflow }}
74+
ci_workflow: ${{ inputs.ci_workflow }}
75+
76+
archive:
77+
name: Archive kdevops
78+
runs-on: [self-hosted]
79+
needs: [setup, test]
80+
steps:
81+
- name: Start SSH Agent
82+
uses: webfactory/ssh-agent@v0.9.0
83+
with:
84+
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
85+
86+
- name: Archive ci-test results
87+
uses: ./.github/actions/archive
88+
with:
89+
dir: ${{ inputs.ci_workflow }}
90+
91+
- name: Upload our kdevops results archive
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: kdevops-ci-results
95+
path: ${{ inputs.ci_workflow }}/kdevops/archive/*.zip
96+
97+
cleanup:
98+
name: Cleanup kdevops workspace
99+
runs-on: [self-hosted]
100+
needs: [setup, test, archive]
101+
if: always()
102+
steps:
103+
- name: kdevops cleanup
104+
uses: ./.github/actions/cleanup
105+
with:
106+
dir: ${{ inputs.ci_workflow }}
107+
ci_workflow: ${{ inputs.ci_workflow }}

0 commit comments

Comments
 (0)