|
| 1 | +# SPDX-License-Identifier: GPL-2.0 |
| 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: Configure git |
| 29 | + run: | |
| 30 | + git config --global --add safe.directory '*' |
| 31 | + git config --global user.name "kdevops" |
| 32 | + git config --global user.email "[email protected]" |
| 33 | +
|
| 34 | + - name: Checkout kdevops |
| 35 | + run: | |
| 36 | + rm -rf kdevops |
| 37 | + git clone /mirror/kdevops.git kdevops |
| 38 | +
|
| 39 | + - name: Make sure our repo kdevops defconfig exists |
| 40 | + run: | |
| 41 | + cd kdevops |
| 42 | + if [[ -z "${{ inputs.kdevops_defconfig }}" ]]; then |
| 43 | + KDEVOPS_DEFCONFIG=$(basename ${{ github.repository }}) |
| 44 | + else |
| 45 | + KDEVOPS_DEFCONFIG="${{ inputs.kdevops_defconfig }}" |
| 46 | + fi |
| 47 | +
|
| 48 | + if [[ ! -f defconfigs/$KDEVOPS_DEFCONFIG ]]; then |
| 49 | + echo "kdevops lacks a defconfig for this repository, expected to find: defconfigs/$KDEVOPS_DEFCONFIG" |
| 50 | + exit 1 |
| 51 | + fi |
| 52 | +
|
| 53 | + echo "KDEVOPS_DEFCONFIG=$KDEVOPS_DEFCONFIG" >> $GITHUB_ENV |
| 54 | +
|
| 55 | + - name: Checkout custom branch with delta on kdevops/linux |
| 56 | + run: | |
| 57 | + LINUX_TREE="https://github.com/${{ github.repository }}" |
| 58 | + LINUX_TREE_REF="${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}" |
| 59 | + cd kdevops |
| 60 | + git clone $LINUX_TREE --reference /mirror/linux.git/ --depth=5 linux |
| 61 | + cd linux |
| 62 | + git fetch origin $LINUX_TREE_REF |
| 63 | + git checkout $LINUX_TREE_REF |
| 64 | + git log -1 |
| 65 | +
|
| 66 | + - name: Initialize CI metadata for kdevops-results-archive for linux |
| 67 | + run: | |
| 68 | + cd kdevops/linux |
| 69 | + echo "$(basename ${{ github.repository }})" > ../ci.trigger |
| 70 | +
|
| 71 | + # This supports using kdevops github actions using two different |
| 72 | + # approaches: |
| 73 | + # |
| 74 | + # 1) Commit the .github/ directory onto a Linux tree before your |
| 75 | + # kernel changes. This approach is used for example for |
| 76 | + # testing patches posted on the mailing list with patchwork, |
| 77 | + # this is the strategy kernel-patch-deaemon uses. Since the |
| 78 | + # patches are ephemeral there is not important git history to |
| 79 | + # maintain. |
| 80 | + # |
| 81 | + # 2) Merge the .github/ directory at the end of your development |
| 82 | + # tree. This is useful for kernel developers wishing to test |
| 83 | + # existing trees. |
| 84 | + # |
| 85 | + # So this checks to see if the last commit (top of the tree) *added* |
| 86 | + # the .github directory. If the last commit added it, then we assume |
| 87 | + # the commit prior to it was the one we'd like to document as the main |
| 88 | + # test point. |
| 89 | + if git diff-tree --no-commit-id --name-only --diff-filter=A -r HEAD | grep -q "^\.github/"; then |
| 90 | + git log -2 --skip=1 --pretty=format:"%s" -1 > ../ci.subject |
| 91 | + git describe --exact-match --tags HEAD^ 2>/dev/null || git rev-parse --short HEAD^ > ../ci.ref |
| 92 | + else |
| 93 | + git log -1 --pretty=format:"%s" > ../ci.subject |
| 94 | + git describe --exact-match --tags HEAD 2>/dev/null || git rev-parse --short HEAD > ../ci.ref |
| 95 | + fi |
| 96 | +
|
| 97 | + RELEVANT_GIT_TAG=$(cat ../ci.ref) |
| 98 | + RELEVANT_GIT_REF=$(git rev-parse --short=12 $RELEVANT_GIT_TAG) |
| 99 | +
|
| 100 | + echo "LINUX_GIT_REF=$RELEVANT_GIT_REF" >> $GITHUB_ENV |
| 101 | + echo "LINUX_GIT_TAG=$RELEVANT_GIT_TAG" >> $GITHUB_ENV |
| 102 | +
|
| 103 | + # Start out pessimistic |
| 104 | + echo "unknown" > ../ci.result |
| 105 | + echo "Nothing to write home about." > ../ci.commit_extra |
| 106 | +
|
| 107 | + - name: Run a quick Linux kernel defconfig build test |
| 108 | + run: | |
| 109 | + cd kdevops/linux |
| 110 | + git reset --hard ${{ env.LINUX_GIT_TAG }} |
| 111 | + make defconfig |
| 112 | + make -j$(nproc) |
| 113 | +
|
| 114 | + - name: Run kdevops make defconfig-repo |
| 115 | + run: | |
| 116 | + LINUX_TREE="https://github.com/${{ github.repository }}" |
| 117 | + LINUX_TREE_REF="${{ env.LINUX_GIT_TAG }}" |
| 118 | +
|
| 119 | + # We make the compromise here to use a relevant git tag for the |
| 120 | + # host prefix so that folks can easily tell what exact kernel tree |
| 121 | + # is being tested by using the relevant git ref. That is, if you |
| 122 | + # pushed a tree with the .github/ directory as the top of the tree, |
| 123 | + # that commit will not be used, we'll use the last one as that is |
| 124 | + # the relevant git ref we want to annotate a test for. |
| 125 | + # |
| 126 | + # The compromise here is that we expect no two same identical tests |
| 127 | + # on the same self-hosted server. We could extend this with something |
| 128 | + # like github.run_id but its not yet clear if we can have kdevops |
| 129 | + # hosts with a bundled prefix ID like that ref-runid-testname. Tests |
| 130 | + # have been done with the full lenght sha1sum though and we know that |
| 131 | + # does work. |
| 132 | + KDEVOPS_HOSTS_PREFIX="${{ env.LINUX_GIT_REF }}" |
| 133 | +
|
| 134 | + echo "Going to use defconfig-${{ env.KDEVOPS_DEFCONFIG }}" |
| 135 | +
|
| 136 | + echo "Linux tree: $LINUX_TREE" |
| 137 | + echo "Linux trigger ref: $LINUX_TREE_REF" |
| 138 | + echo "Linux tag: ${{ env.LINUX_GIT_TAG }}" |
| 139 | + echo "Runner ID: ${{ github.run_id }}" |
| 140 | + echo "kdevops host prefix: $KDEVOPS_HOSTS_PREFIX" |
| 141 | + echo "kdevops defconfig: defconfig-${{ env.KDEVOPS_DEFCONFIG }}" |
| 142 | +
|
| 143 | + KDEVOPS_ARGS="KDEVOPS_HOSTS_PREFIX=$KDEVOPS_HOSTS_PREFIX LINUX_TREE=$LINUX_TREE LINUX_TREE_REF=$LINUX_TREE_REF defconfig-${{ env.KDEVOPS_DEFCONFIG }}" |
| 144 | + echo "Going to run:" |
| 145 | + echo "make $KDEVOPS_ARGS" |
| 146 | +
|
| 147 | + cd kdevops |
| 148 | + make $KDEVOPS_ARGS |
| 149 | +
|
| 150 | + - name: Run kdevops make |
| 151 | + run: | |
| 152 | + cd kdevops |
| 153 | + make -j$(nproc) |
| 154 | +
|
| 155 | + - name: Run kdevops make bringup |
| 156 | + run: | |
| 157 | + cd kdevops |
| 158 | + ls -ld linux |
| 159 | + make bringup |
| 160 | +
|
| 161 | + - name: Build linux and boot test nodes on test kernel |
| 162 | + run: | |
| 163 | + cd kdevops |
| 164 | + make linux |
| 165 | +
|
| 166 | + - name: Build required ci tests |
| 167 | + run: | |
| 168 | + cd kdevops |
| 169 | + make ci-build-test |
0 commit comments