Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/actions/archive/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-License-Identifier: GPL-2.0
---
name: Archive results
description: Archive kdevops results in https://github.com/linux-kdevops/kdevops-results-archive.git
inputs:
dir:
description: 'Directory'
required: true
default: 'workdir'
runs:
using: "composite"
steps:
- name: Get systemd journal files
working-directory: ${{ inputs.dir }}/kdevops
shell: bash
run: |
make journal-dump

- name: Build our kdevops archive results
working-directory: ${{ inputs.dir }}/kdevops
shell: bash
run: |
make ci-archive CI_WORKFLOW="${{ inputs.ci_workflow }}"

24 changes: 24 additions & 0 deletions .github/actions/cleanup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-License-Identifier: GPL-2.0
---
name: Cleanup kdevops VMs
description: Destroy VMs and cleanup workspace

inputs:
dir:
description: 'Directory'
required: true
default: 'workdir'

runs:
using: "composite"
steps:
- name: Run kdevops make destroy
working-directory: ${{ inputs.dir }}/kdevops
shell: bash
run: |
make destroy

- name: Remove working-directory
shell: bash
run: |
rm --recursive --force --verbose ${{ inputs.dir }}
181 changes: 181 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
# SPDX-License-Identifier: GPL-2.0
---
name: Setup kdevops
description: Setup kdevops workspace

inputs:
dir:
description: 'Directory'
required: true
default: 'workdir'
kernel_tree:
required: false
type: string
default: 'linux'
kernel_ref:
required: false
type: string
default: 'master'
ci_workflow:
required: false
type: string
default: 'demo'

runs:
using: "composite"
steps:
- name: Create workspace directory
shell: bash
run: |
pwd
rm --recursive --force --verbose ${{ inputs.dir }}
mkdir --parent --verbose ${{ inputs.dir }}
find .

- name: Configure git
shell: bash
run: |
git config --global --add safe.directory '*'
git config --global user.name "kdevops"
git config --global user.email "kdevops@lists.linux.dev"

- name: Checkout kdevops
working-directory: ${{ inputs.dir }}
shell: bash
run: |
rm --recursive --force --verbose kdevops/
git clone https://github.com/dkruces/kdevops.git --branch ci-workflow kdevops

- name: Checkout custom branch with delta on kdevops/linux
working-directory: ${{ inputs.dir }}/kdevops
shell: bash
run: |
set -euxo pipefail
LINUX_TREE="/mirror/${{ inputs.kernel_tree }}.git"
LINUX_TREE_REF="${{ inputs.kernel_ref }}"
git clone $LINUX_TREE linux
cd linux
git checkout $LINUX_TREE_REF
git log -1

- name: Make sure our repo kdevops defconfig exists
id: defconfig
working-directory: ${{ inputs.dir }}/kdevops
shell: bash
run: |
set -euxo pipefail
if [[ -z "${{ inputs.kdevops_defconfig }}" ]]; then
KDEVOPS_DEFCONFIG=${{ inputs.ci_workflow }}
else
KDEVOPS_DEFCONFIG="${{ inputs.kdevops_defconfig }}"
fi

if [[ ! -f defconfigs/$KDEVOPS_DEFCONFIG ]]; then
echo "kdevops lacks a defconfig for this repository, expected to find: defconfigs/$KDEVOPS_DEFCONFIG"
exit 1
fi

"${{ github.workspace }}/scripts/github_output.sh" KDEVOPS_DEFCONFIG "$KDEVOPS_DEFCONFIG"

- name: Initialize CI metadata for kdevops-results-archive for linux
id: metadata
working-directory: ${{ inputs.dir }}/kdevops/linux
shell: bash
run: |
set -euxo pipefail
echo "${{ inputs.kernel_tree }}" > ../ci.trigger
echo "testing" > ../ci.subject
echo "${{ inputs.kernel_ref }}" > ../ci.ref

RELEVANT_GIT_TAG=$(cat ../ci.ref)
RELEVANT_GIT_REF=$(git rev-parse --short=12 $RELEVANT_GIT_TAG)

"${{ github.workspace }}/scripts/github_output.sh" LINUX_GIT_REF "$RELEVANT_GIT_REF"
"${{ github.workspace }}/scripts/github_output.sh" LINUX_GIT_TAG "$RELEVANT_GIT_TAG"

# Start out pessimistic
echo "unknown" > ../ci.result
echo "Nothing to write home about." > ../ci.commit_extra

- name: Run a quick Linux kernel defconfig build test
working-directory: ${{ inputs.dir }}/kdevops/linux
env:
LINUX_GIT_TAG: ${{ steps.metadata.outputs.LINUX_GIT_TAG }}
shell: bash
run: |
set -euxo pipefail
git reset --hard "$LINUX_GIT_TAG"
make defconfig
make -j$(nproc)

- name: Run kdevops make defconfig-repo
working-directory: ${{ inputs.dir }}/kdevops
env:
LINUX_GIT_TAG: ${{ steps.metadata.outputs.LINUX_GIT_TAG }}
LINUX_GIT_REF: ${{ steps.metadata.outputs.LINUX_GIT_REF }}
KDEVOPS_DEFCONFIG: ${{ steps.defconfig.outputs.KDEVOPS_DEFCONFIG }}
shell: bash
run: |
LINUX_TREE="/mirror/${{ inputs.kernel_tree }}.git"
LINUX_TREE_REF="$LINUX_GIT_TAG"

# We make the compromise here to use a relevant git tag for the
# host prefix so that folks can easily tell what exact kernel tree
# is being tested by using the relevant git ref. That is, if you
# pushed a tree with the .github/ directory as the top of the tree,
# that commit will not be used, we'll use the last one as that is
# the relevant git ref we want to annotate a test for.
#
# The compromise here is that we expect no two same identical tests
# on the same self-hosted server. We could extend this with something
# like github.run_id but its not yet clear if we can have kdevops
# hosts with a bundled prefix ID like that ref-runid-testname. Tests
# have been done with the full lenght sha1sum though and we know that
# does work.
KDEVOPS_HOSTS_PREFIX="$LINUX_GIT_REF"

echo "Going to use defconfig-$KDEVOPS_DEFCONFIG"

echo "Linux tree: $LINUX_TREE"
echo "Linux trigger ref: $LINUX_TREE_REF"
echo "Linux tag: $LINUX_GIT_TAG"
echo "Runner ID: ${{ github.run_id }}"
echo "kdevops host prefix: $KDEVOPS_HOSTS_PREFIX"
echo "kdevops defconfig: defconfig-$KDEVOPS_DEFCONFIG"

KDEVOPS_ARGS="\
KDEVOPS_HOSTS_PREFIX=$KDEVOPS_HOSTS_PREFIX \
LINUX_TREE=$LINUX_TREE \
LINUX_TREE_REF=$LINUX_TREE_REF \
ANSIBLE_CFG_CALLBACK_PLUGIN="debug" \
defconfig-$KDEVOPS_DEFCONFIG"
echo "Going to run:"
echo "make $KDEVOPS_ARGS"

make $KDEVOPS_ARGS

- name: Run kdevops make
working-directory: ${{ inputs.dir }}/kdevops
shell: bash
run: |
make -j$(nproc)

- name: Run kdevops make bringup
working-directory: ${{ inputs.dir }}/kdevops
shell: bash
run: |
ls -ld linux
make destroy
make bringup

- name: Build linux and boot test nodes on test kernel
working-directory: ${{ inputs.dir }}/kdevops
shell: bash
run: |
make linux

- name: Build required ci tests
working-directory: ${{ inputs.dir }}/kdevops
shell: bash
run: |
make ci-build-test CI_WORKFLOW=${{ inputs.ci_workflow }}
44 changes: 44 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# SPDX-License-Identifier: GPL-2.0
---
name: Setup kdevops
description: Setup kdevops workspace

inputs:
dir:
description: 'Directory'
required: true
default: 'workdir'
ci_workflow:
required: false
type: string
default: 'demo'

runs:
using: "composite"
steps:
- name: Run CI tests
working-directory: ${{ inputs.dir }}/kdevops
shell: bash
run: |
make ci-test CI_WORKFLOW="${{ inputs.ci_workflow }}"

echo -e "Kernel tests results:\n" > ci.commit_extra

- name: Generate CI commit info
working-directory: ${{ inputs.dir }}/kdevops
shell: bash
run: |
find workflows/blktests/results/last-run/ -name '*.dmesg.log' \
-exec tail -n 1 {} + >> ci.commit_extra

echo -e "\n\n" >> ci.commit_extra
echo -e "Userspace test results:\n" >> ci.commit_extra
find workflows/blktests/results/last-run/ -name '*.userspace.log' \
-exec tail -n 1 {} + >> ci.commit_extra
echo -e "\n\n" >> ci.commit_extra

if grep -i -q "fail" ci.commit_extra ; then
echo "fail" > ci.result
else
echo "ok" > ci.result
fi
107 changes: 107 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# SPDX-License-Identifier: GPL-2.0
---
name: Run kdevops CI Workflow - Reusable

on:
workflow_call:
inputs:
ci_workflow:
description: "CI Workflow"
required: true
default: 'blktests_nvme'
type: string
kernel_tree:
description: "Linux kernel tree to use"
required: true
default: 'linux'
type: string
kernel_ref:
description: "Linux tree git reference (branch/tag/commit-id)"
required: true
default: 'master'
type: string

jobs:
check_ref:
name: Check Linux kernel Git Reference
runs-on: [self-hosted]
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Check kernel_ref exists
id: check_kernel_ref
run: |
set -euxo pipefail

ref="${{ github.event.inputs.kernel_ref }}"
tree="${{ github.event.inputs.kernel_tree }}"
mirror="/mirror/${tree}.git"
ls_remote="$(git ls-remote "$mirror" "refs/*/${ref}" || true)"
contains_branch="$(git -C "$mirror" branch --contains "${ref}" || true)"
contains_tag="$(git -C "$mirror" branch --contains "${ref}" || true)"

if [ -z "$ls_remote" ] && [ -z "$contains_branch" ] && [ -z "$contains_tag" ]; then
echo "Linux kernel ${ref} does not exist."
exit 1
fi

setup:
name: Setup kdevops workspace
runs-on: [self-hosted]
needs: [check_ref]
steps:
- name: Checkout kdevops-ci
uses: actions/checkout@v4

- name: kdevops setup
uses: ./.github/actions/setup
with:
dir: ${{ inputs.ci_workflow }}
kernel_tree: ${{ inputs.kernel_tree }}
kernel_ref: ${{ inputs.kernel_ref }}
ci_workflow: ${{ inputs.ci_workflow }}

test:
name: Run kdevops ci-test
runs-on: [self-hosted]
needs: [setup]
steps:
- name: kdevops ci-test
uses: ./.github/actions/test
with:
dir: ${{ inputs.ci_workflow }}
ci_workflow: ${{ inputs.ci_workflow }}

archive:
name: Archive kdevops
runs-on: [self-hosted]
needs: [setup, test]
steps:
- name: Start SSH Agent
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Archive ci-test results
uses: ./.github/actions/archive
with:
dir: ${{ inputs.ci_workflow }}

- name: Upload our kdevops results archive
uses: actions/upload-artifact@v4
with:
name: kdevops-ci-results
path: ${{ inputs.ci_workflow }}/kdevops/archive/*.zip

cleanup:
name: Cleanup kdevops workspace
runs-on: [self-hosted]
needs: [setup, test, archive]
if: always()
steps:
- name: kdevops cleanup
uses: ./.github/actions/cleanup
with:
dir: ${{ inputs.ci_workflow }}
ci_workflow: ${{ inputs.ci_workflow }}
Loading