|
| 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