-
Notifications
You must be signed in to change notification settings - Fork 0
171 lines (155 loc) · 7.57 KB
/
test_kernels.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will rrun.
on:
# Triggers the workflow on push or pull requeest events but only for the main branch
push:
branches:
- main
pull_request:
branches:
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains two jobs. The first one will create a dynamic matrix to use as strategy for the second job
generate-matrix:
name: Generate matrix for build
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check changed files
id: folders
run: |
export folders=$( ls -1d */ )
echo "$folders"
# Escape newlines (replace \n with %0A)
echo "::set-output name=folders::$( echo "$folders" | sed ':a;N;$!ba;s/\n/%0A/g' )"
- name: Set matrix for build
id: set-matrix
run: |
folders="${{ steps.folders.outputs.folders }}"
JSON="{\"versions\":["
# Loop by lines
while read path; do
# Add item to the matrix only if it is not already included and remove /
path=${path%?}
JSONline="\"$path\","
if [[ "$JSON" != *"$JSONline"* ]]; then
JSON="$JSON$JSONline"
fi
done <<< "$folders"
# Remove last "," and add closing brackets
if [[ $JSON == *, ]]; then
JSON="${JSON%?}"
fi
JSON="$JSON], \"architecture\":[\"x86_64\", \"arm64\"]}"
echo $JSON
# Set output
echo "::set-output name=matrix::$( echo "$JSON" )"
Patch-Linux:
#tries to apply the patch to each version
needs: [generate-matrix]
runs-on: ["${{ matrix.architecture }}", "gcc", "2004"]
#strategy matrix to run jobs in parallel for each version
strategy:
matrix:
${{fromJson(needs.generate-matrix.outputs.matrix)}}
fail-fast: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINUX_VERSION: ${{ matrix.versions }}
ARCHITECTURE: ${{ matrix.architecture }}
steps:
- name: Cleanup previous runs
run: |
sudo rm -rf ${{ github.workspace }}/*
sudo rm -rf ${{ github.workspace }}/.??*
- uses: actions/checkout@v2
- name: install necessary packages
run: |
sudo apt-get -y update
sudo apt-get -y install build-essential libncurses-dev bc bison flex libssl-dev libelf-dev
sudo apt-get -y install fakeroot rsync git kmod cpio liblz4-tool
- name: Clone linux
run: |
cd $LINUX_VERSION
git clone https://github.com/torvalds/linux -b $LINUX_VERSION --depth 1 linux-$LINUX_VERSION
cd linux-$LINUX_VERSION
- name: Apply patches
id: apply-patch
#working-directory: linux-$LINUX_VERSION
run: |
echo ::set-output name=patch_exit_code::1
echo "MYMSG=Patching failed for version $LINUX_VERSION, architecture $ARCHITECTURE" >> $GITHUB_ENV
cd $LINUX_VERSION/linux-$LINUX_VERSION
for i in ../*.patch
do
git config user.name "CI Bot"
git config user.email "[email protected]"
git am $i
done
echo ::set-output name=patch_exit_code::0
#build the linux kernel for this version. will run only if patching has succeeded
- name: Build Kernel
id: build-kernel
if: steps.apply-patch.outputs.patch_exit_code == 0
#working-directory: linux-$LINUX_VERSION
run: |
echo ::set-output name=build_exit_code::1
deliverypath=$PWD
echo "MYMSG=Building failed for version $LINUX_VERSION, architecture $ARCHITECTURE" >> $GITHUB_ENV
cd $LINUX_VERSION/linux-$LINUX_VERSION
sudo mkdir -p artifacts/$ARCHITECTURE/$LINUX_VERSION
if [[ $ARCHITECTURE == "arm64" ]]
then
wget https://gist.githubusercontent.com/ananos/dc2e2323f1b9bcb93c24f307e367ae80/raw/a001e5dd3b02fb79001296b1f9ae39270288f8d9/aarch64_config -O arch/arm64/configs/hedge.config
else
#wget https://gist.githubusercontent.com/ananos/4749c77111a560503bd9725409d82800/raw/3e65dec157a7a19d965675054ef85ce8bc06c74b/basic%2520kernel%2520config -O arch/x86/configs/hedge.config
#wget https://gist.githubusercontent.com/ananos/1031c91aa16b2be8098d5d386b625c7e/raw/dd0d170ebd3480b420e715ce85da8d3c4b096fce/hedge-x86.config -O arch/x86/configs/hedge.config
wget https://gist.githubusercontent.com/ananos/1031c91aa16b2be8098d5d386b625c7e/raw/9df4f61e0bb60fecad2308def2835a9ed5cbfcda/hedge-x86.config -O arch/x86/configs/hedge.config
fi
touch .config
make hedge.config
make deb-pkg -j $(nproc)
echo ::set-output name=build_exit_code::$?
sudo mv ../*linux-headers*.deb artifacts/$ARCHITECTURE/$LINUX_VERSION/linux-headers-$LINUX_VERSION-latest.deb
if [[ $ARCHITECTURE == "arm64" ]]
then
sudo mv ../*linux-image*-dbg*.deb artifacts/$ARCHITECTURE/$LINUX_VERSION/linux-image-$LINUX_VERSION-dbg-latest.deb
fi
sudo mv ../*linux-image*.deb artifacts/$ARCHITECTURE/$LINUX_VERSION/linux-image-$LINUX_VERSION-latest.deb
sudo mv ../*linux-libc-dev*.deb artifacts/$ARCHITECTURE/$LINUX_VERSION/linux-libc-dev_$LINUX_VERSION-latest.deb
#If build was successful, upload the kernel deb artifacts for the hedge module builder to have available
- name: Upload Kernel artifact
id: upload-artifact
if: steps.build-kernel.outputs.build_exit_code == 0
uses: cloudkernels/minio-upload@master
with:
url: https://s3.nubificus.co.uk
access-key: ${{ secrets.AWS_ACCESS_KEY }}
secret-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
local-path: ${{ matrix.versions }}/linux-${{ matrix.versions }}/artifacts/${{ matrix.architecture }}/${{ matrix.versions }}
remote-path: nbfc-assets/github/linux_kernel_debs/${{ matrix.architecture }}/
#some (safe) shenanigans to access this specific job's logs.
- name: Set logs link
if: ${{ failure() }}
run: |
curl -i -u ${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs > json.txt
idparser=$(awk '/${{ matrix.versions }}, ${{ matrix.architecture }}/{ print NR; exit }' json.txt)
idparser=$((idparser-11))
idparser=$(sed "$idparser q;d" json.txt)
idparser=$(echo $idparser | cut -c 7-)
echo "LOGLINK=https://github.com/${{ github.repository }}/runs/$idparser?check_suite_focus=true" >> $GITHUB_ENV
env:
REPO: ${{ github.repository }}
JID: ${{ github.run_id }}
- name: Create Issue
if: ${{ failure() && (steps.apply-patch.outputs.patch_exit_code != 0 || steps.build-kernel.outputs.build_exit_code != 0) }}
uses: JasonEtco/create-an-issue@v2