Improved github actions

Added step to detect misuse of USB_VENDOR_ID_REALTEK
Added check for duplicated USB IDs
Check for .deb files before download it
Move git checkout before build step
This commit is contained in:
Carlos Garces 2021-03-06 17:48:54 +01:00
parent 059e06a51b
commit e6df6a1436

View File

@ -1,25 +1,35 @@
name: Build name: Build
on: [push, pull_request] on: [pull_request]
jobs: jobs:
fetchKernelData:
commontasks:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }} matrix: ${{ steps.set-matrix.outputs.matrix }}
steps: steps:
- id: set-matrix - uses: actions/checkout@v2
- name: Avoid 0x0BDA
#Find devices that not use 0x0BDA instead of const USB_VENDOR_ID_REALTEK
run: grep -c -i "0x0BDA" os_dep/linux/usb_intf.c | grep -w 1
- name: Find duplicates
#Find devices that not use 0x0BDA instead of const USB_VENDOR_ID_REALTEK
run: grep -i "{USB_DEVICE(" os_dep/linux/usb_intf.c | cut -d ')' -f1 | sort | uniq -cd | wc -c | grep -w 0
- name: Get kernel matrix
id: set-matrix
run: | run: |
JSON=$(curl https://www.kernel.org/releases.json) JSON=$(curl -s https://www.kernel.org/releases.json)
VERSIONSARRAY=$(echo $JSON | jq -c '[.releases[] | {version: .version, moniker: .moniker} | select(.moniker != "linux-next") | .version]') VERSIONSARRAY=$(echo $JSON | jq -c '[.releases[] | {version: .version, moniker: .moniker} | select(.moniker != "linux-next") | .version]')
echo ::set-output name=matrix::${VERSIONSARRAY} echo ::set-output name=matrix::${VERSIONSARRAY}
build: build:
needs: fetchKernelData needs: commontasks
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
fail-fast: false
matrix: matrix:
version: ${{fromJson(needs.fetchKernelData.outputs.matrix)}} version: ${{fromJson(needs.commontasks.outputs.matrix)}}
#version: [4.9.248, 4.4.248] #version: [4.9.248, 4.4.248]
include: include:
#Version 4.15.x requested to test Ubuntu 18.04 LTS version #Version 4.15.x requested to test Ubuntu 18.04 LTS version
@ -28,8 +38,7 @@ jobs:
use_apt: true use_apt: true
steps: steps:
- uses: actions/checkout@v2 - name: install deb packages
- name: download-Kernel
env: env:
VERSION: ${{matrix.version }} VERSION: ${{matrix.version }}
if: ${{ !matrix.use_apt }} if: ${{ !matrix.use_apt }}
@ -37,17 +46,18 @@ jobs:
KERNEL_URL=https://kernel.ubuntu.com/~kernel-ppa/mainline/ KERNEL_URL=https://kernel.ubuntu.com/~kernel-ppa/mainline/
KERNEL_URL_DETAILS=$(wget --quiet -O - ${KERNEL_URL}v${VERSION}/ | grep -A8 "Build for amd64\|Test amd64") KERNEL_URL_DETAILS=$(wget --quiet -O - ${KERNEL_URL}v${VERSION}/ | grep -A8 "Build for amd64\|Test amd64")
ALL_DEB=$(echo "$KERNEL_URL_DETAILS" | grep -m1 'all.deb' | cut -d '"' -f 2) ALL_DEB=$(echo "$KERNEL_URL_DETAILS" | grep -m1 'all.deb' | cut -d '"' -f 2)
KVER=$(echo $ALL_DEB | cut -d '_' -f 2 | rev | cut -c14- | rev)-generic AMD64_DEB=$(echo "$KERNEL_URL_DETAILS" | grep -m1 "amd64.deb" | cut -d '"' -f 2)
wget ${KERNEL_URL}v${VERSION}/$(echo "$KERNEL_URL_DETAILS" | grep -m1 "amd64.deb" | cut -d '"' -f 2) [ -z "$ALL_DEB" ] && exit 1
wget ${KERNEL_URL}v${VERSION}/$ALL_DEB [ -z "$AMD64_DEB" ] && exit 2
wget -nv ${KERNEL_URL}v${VERSION}/$AMD64_DEB
wget -nv ${KERNEL_URL}v${VERSION}/$ALL_DEB
sudo dpkg --force-all -i *.deb sudo dpkg --force-all -i *.deb
sudo wget https://raw.githubusercontent.com/torvalds/linux/master/scripts/module.lds.S -O /usr/src/linux-headers-$KVER/scripts/module.lds echo "KVER=$(echo $ALL_DEB | cut -d '_' -f 2 | rev | cut -c14- | rev)-generic" >> $GITHUB_ENV
sudo sed -i '$ d' /usr/src/linux-headers-$KVER/scripts/module.lds
echo "KVER=$KVER" >> $GITHUB_ENV
- name: apt-linux-headers - name: apt-linux-headers
if: ${{ matrix.use_apt }} if: ${{ matrix.use_apt }}
run: | run: |
sudo apt-get install linux-headers-${{matrix.version }} sudo apt-get install linux-headers-${{matrix.version }}
echo "KVER=${{matrix.version }}" >> $GITHUB_ENV echo "KVER=${{matrix.version }}" >> $GITHUB_ENV
- uses: actions/checkout@v2
- name: build - name: build
run: make KVER=$KVER run: make KVER=$KVER