Skip to content

Commit 39f16b8

Browse files
author
KPD
committed
adding ci files
1 parent 4344748 commit 39f16b8

File tree

3 files changed

+284
-0
lines changed

3 files changed

+284
-0
lines changed

.github/workflows/kdevops-cleanup.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# SPDX-License-Identifier: GPL-2.0 OR copyleft-next-0.3.1
2+
#
3+
# This can be used towards the end of your action. All tasks here run even if
4+
# any of the previous tasks failed.
5+
6+
name: Kdevops cleanup workflow
7+
8+
on:
9+
workflow_call: # Makes this workflow reusable
10+
11+
jobs:
12+
cleanup:
13+
name: Archive results and cleanup
14+
runs-on: [self-hosted, Linux, X64]
15+
steps:
16+
- name: Set Linux kdevops development path
17+
if: ${{ job.status != 'cancelled' }}
18+
run: echo "LINUX_KDEVOPS_PATH=$GITHUB_WORKSPACE" >> $GITHUB_ENV
19+
20+
- name: Get systemd journal files
21+
if: ${{ job.status != 'cancelled' }}
22+
run: |
23+
if [[ ! -d kdevops ]]; then
24+
exit 0
25+
fi
26+
cd kdevops
27+
make journal-dump
28+
29+
- name: Start SSH Agent
30+
if: ${{ job.status != 'cancelled' }}
31+
uses: webfactory/[email protected]
32+
with:
33+
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
34+
35+
- name: Build our kdevops archive results
36+
if: ${{ job.status != 'cancelled' }}
37+
run: |
38+
if [[ ! -d kdevops ]]; then
39+
exit 0
40+
fi
41+
cd kdevops
42+
make ci-archive
43+
44+
- name: Upload our kdevops results archive
45+
if: ${{ job.status != 'cancelled' }}
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: kdevops-ci-results
49+
path: ${{ env.LINUX_KDEVOPS_PATH }}/kdevops/archive/*.zip
50+
51+
- name: Run kdevops make destroy
52+
if: always()
53+
run: |
54+
if [[ ! -d kdevops ]]; then
55+
exit 0
56+
fi
57+
cd kdevops
58+
make destroy
59+
cd ..
60+
rm -rf kdevops

.github/workflows/kdevops-generic.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# SPDX-License-Identifier: GPL-2.0 OR copyleft-next-0.3.1
2+
#
3+
# Most simple Linux kernel subsystems can be tested with this target
4+
# test setup. For more elaborates tests look for a topic branch under the
5+
# kdevops-ci tree. For example to test a filesystem look at the fstests
6+
# branch.
7+
8+
name: Run generic kdevops CI tests
9+
10+
on:
11+
push:
12+
branches: ['**']
13+
pull_request:
14+
branches: ['**']
15+
workflow_dispatch: # Allow manual triggering
16+
17+
jobs:
18+
setup:
19+
uses: ./.github/workflows/kdevops-init.yml
20+
secrets: inherit
21+
22+
run-tests:
23+
needs: setup
24+
name: Run CI tests
25+
runs-on: [self-hosted, Linux, X64]
26+
steps:
27+
- name: Run CI tests
28+
run: |
29+
cd kdevops
30+
make ci-test
31+
echo "ok" > ci.result
32+
33+
cleanup:
34+
needs: [run-tests, setup] # Add setup as a dependency to ensure proper ordering
35+
if: always() # This ensures cleanup runs even if run-tests fails
36+
uses: ./.github/workflows/kdevops-cleanup.yml
37+
secrets: inherit

.github/workflows/kdevops-init.yml

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
# SPDX-License-Identifier: GPL-2.0 OR copyleft-next-0.3.1
2+
#
3+
# This can be used as a initialization workflow for most Linux kernel
4+
# development environments. This takes care of:
5+
#
6+
# - Checks out and re-using a local mirror for your kernel tree
7+
# - Looks for a defconfig in kdevops to use for your kernel tree
8+
# - Sets up CI metadata for kdevops-results-archive
9+
# - Ensures your kernel tree at least builds with defconfig
10+
# - Brings up target DUTs nodes
11+
# - Installs your Linux kernel tree on them
12+
# - Builds all of your test requirements for your Linux kernel tree
13+
14+
name: Base kdevops workflow
15+
16+
on:
17+
workflow_call: # Makes this workflow reusable
18+
inputs:
19+
kdevops_defconfig:
20+
required: false
21+
type: string
22+
23+
jobs:
24+
setup:
25+
name: Setup kdevops environment
26+
runs-on: [self-hosted, Linux, X64]
27+
steps:
28+
- name: Verify we won't expect user input interactions on the host key
29+
run: |
30+
mkdir -p ~/.ssh
31+
if ! grep -q "StrictHostKeyChecking no" ~/.ssh/config 2>/dev/null; then
32+
echo "StrictHostKeyChecking no" >> ~/.ssh/config
33+
fi
34+
35+
- name: Start SSH Agent for initial test
36+
uses: webfactory/[email protected]
37+
with:
38+
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
39+
40+
# Modify the repo here if you have a custom or private URL for the archive
41+
# This can also just be a repo variable later.
42+
- name: Verify our ssh connection will work
43+
run: |
44+
if ! git ls-remote [email protected]:linux-kdevops/kdevops-results-archive.git HEAD; then
45+
echo "Cannot access kdevops-results-archive repository"
46+
exit 1
47+
fi
48+
49+
- name: Configure git
50+
run: |
51+
git config --global --add safe.directory '*'
52+
git config --global user.name "kdevops"
53+
git config --global user.email "[email protected]"
54+
55+
- name: Checkout kdevops
56+
run: |
57+
rm -rf kdevops
58+
git clone /mirror/kdevops.git kdevops
59+
60+
- name: Make sure our repo kdevops defconfig exists
61+
run: |
62+
cd kdevops
63+
if [[ -z "${{ inputs.kdevops_defconfig }}" ]]; then
64+
KDEVOPS_DEFCONFIG=$(basename ${{ github.repository }})
65+
else
66+
KDEVOPS_DEFCONFIG="${{ inputs.kdevops_defconfig }}"
67+
fi
68+
69+
if [[ ! -f defconfigs/$KDEVOPS_DEFCONFIG ]]; then
70+
echo "kdevops lacks a defconfig for this repository, expected to find: defconfigs/$KDEVOPS_DEFCONFIG"
71+
exit 1
72+
fi
73+
74+
echo "KDEVOPS_DEFCONFIG=$KDEVOPS_DEFCONFIG" >> $GITHUB_ENV
75+
76+
- name: Checkout custom branch with delta on kdevops/linux
77+
run: |
78+
LINUX_TREE="https://github.com/${{ github.repository }}"
79+
LINUX_TREE_REF="${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}"
80+
cd kdevops
81+
git clone $LINUX_TREE --reference /mirror/linux.git/ --depth=5 linux
82+
cd linux
83+
git fetch origin $LINUX_TREE_REF
84+
git checkout $LINUX_TREE_REF
85+
git log -1
86+
87+
- name: Initialize CI metadata for kdevops-results-archive for linux
88+
run: |
89+
cd kdevops/linux
90+
echo "$(basename ${{ github.repository }})" > ../ci.trigger
91+
92+
# This supports using kdevops github actions using two different
93+
# approaches:
94+
#
95+
# 1) Commit the .github/ directory onto a Linux tree before your
96+
# kernel changes. This approach is used for example for
97+
# testing patches posted on the mailing list with patchwork,
98+
# this is the strategy kernel-patch-deaemon uses. Since the
99+
# patches are ephemeral there is not important git history to
100+
# maintain.
101+
#
102+
# 2) Merge the .github/ directory at the end of your development
103+
# tree. This is useful for kernel developers wishing to test
104+
# existing trees.
105+
#
106+
# So this checks to see if the last commit (top of the tree) *added*
107+
# the .github directory. If the last commit added it, then we assume
108+
# the commit prior to it was the one we'd like to document as the main
109+
# test point.
110+
if git diff-tree --no-commit-id --name-only --diff-filter=A -r HEAD | grep -q "^\.github/"; then
111+
git log -2 --skip=1 --pretty=format:"%s" -1 > ../ci.subject
112+
git describe --exact-match --tags HEAD^ 2>/dev/null || git rev-parse --short HEAD^ > ../ci.ref
113+
else
114+
git log -1 --pretty=format:"%s" > ../ci.subject
115+
git describe --exact-match --tags HEAD 2>/dev/null || git rev-parse --short HEAD > ../ci.ref
116+
fi
117+
118+
RELEVANT_GIT_TAG=$(cat ../ci.ref)
119+
RELEVANT_GIT_REF=$(git rev-parse --short=12 $RELEVANT_GIT_TAG)
120+
121+
echo "LINUX_GIT_REF=$RELEVANT_GIT_REF" >> $GITHUB_ENV
122+
echo "LINUX_GIT_TAG=$RELEVANT_GIT_TAG" >> $GITHUB_ENV
123+
124+
# Start out pessimistic
125+
echo "unknown" > ../ci.result
126+
echo "Nothing to write home about." > ../ci.commit_extra
127+
128+
- name: Run a quick Linux kernel defconfig build test
129+
run: |
130+
cd kdevops/linux
131+
git reset --hard ${{ env.LINUX_GIT_TAG }}
132+
make defconfig
133+
make -j$(nproc)
134+
135+
- name: Run kdevops make defconfig-repo
136+
run: |
137+
LINUX_TREE="https://github.com/${{ github.repository }}"
138+
LINUX_TREE_REF="${{ env.LINUX_GIT_TAG }}"
139+
140+
# We make the compromise here to use a relevant git tag for the
141+
# host prefix so that folks can easily tell what exact kernel tree
142+
# is being tested by using the relevant git ref. That is, if you
143+
# pushed a tree with the .github/ directory as the top of the tree,
144+
# that commit will not be used, we'll use the last one as that is
145+
# the relevant git ref we want to annotate a test for.
146+
#
147+
# The compromise here we use special KDEVOPS to separete the
148+
# commit ID and github.run_id. Exotic things likes UTF characters
149+
# and dots have problems.
150+
KDEVOPS_HOSTS_PREFIX="${{ env.LINUX_GIT_REF }}KDEVOPS${{ github.run_id }}"
151+
152+
echo "Going to use defconfig-${{ env.KDEVOPS_DEFCONFIG }}"
153+
154+
echo "Linux tree: $LINUX_TREE"
155+
echo "Linux trigger ref: $LINUX_TREE_REF"
156+
echo "Linux tag: ${{ env.LINUX_GIT_TAG }}"
157+
echo "Runner ID: ${{ github.run_id }}"
158+
echo "kdevops host prefix: $KDEVOPS_HOSTS_PREFIX"
159+
echo "kdevops defconfig: defconfig-${{ env.KDEVOPS_DEFCONFIG }}"
160+
161+
KDEVOPS_ARGS="KDEVOPS_HOSTS_PREFIX=$KDEVOPS_HOSTS_PREFIX LINUX_TREE=$LINUX_TREE LINUX_TREE_REF=$LINUX_TREE_REF defconfig-${{ env.KDEVOPS_DEFCONFIG }}"
162+
echo "Going to run:"
163+
echo "make $KDEVOPS_ARGS"
164+
165+
cd kdevops
166+
make $KDEVOPS_ARGS
167+
168+
- name: Run kdevops make
169+
run: |
170+
cd kdevops
171+
make -j$(nproc)
172+
173+
- name: Run kdevops make bringup
174+
run: |
175+
cd kdevops
176+
ls -ld linux
177+
make bringup
178+
179+
- name: Build linux and boot test nodes on test kernel
180+
run: |
181+
cd kdevops
182+
make linux
183+
184+
- name: Build required ci tests
185+
run: |
186+
cd kdevops
187+
make ci-build-test

0 commit comments

Comments
 (0)