youtubeUnblock/.github/workflows/test.yml

203 lines
6.4 KiB
YAML
Raw Normal View History

2024-09-28 09:03:24 +00:00
# Tests whether the youtubeUnblock builds properly
name: "youtubeUnblock build test"
on:
push:
branches: [ "main" ]
paths-ignore:
- '.editorconfig'
- '.gitignore'
- 'LICENSE'
- 'README.md'
pull_request:
branches: [ "main" ]
paths-ignore:
- '.editorconfig'
- '.gitignore'
- 'LICENSE'
- 'README.md'
workflow_dispatch:
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.gh.outputs.version }}
sha: ${{ steps.gh.outputs.sha }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: 'openwrt'
- name: GH
id: gh
env:
REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
echo "version=$(cat youtubeUnblock/Makefile | grep PKG_VERSION | sed 's/PKG_VERSION:=//')" >> $GITHUB_OUTPUT
if [[ "${{ github.event_name }}" != "pull_request" ]]; then
echo "sha=$(echo ${GITHUB_SHA::7})" >> $GITHUB_OUTPUT
else
echo "sha=$(gh api repos/$REPO/commits/main --jq '.sha[:7]')" >> $GITHUB_OUTPUT
fi
build-static:
needs: prepare
name: build-static ${{ matrix.arch }}
runs-on: ubuntu-latest
strategy:
matrix:
arch: [x86_64]
branch: [latest-stable]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build
id: build
env:
ARCH: ${{ matrix.arch }}
VERSION: ${{ needs.prepare.outputs.version }}
SHA: ${{ needs.prepare.outputs.sha }}
shell: bash
run: |
make -j$(nproc)
strip -s build/youtubeUnblock
cp -va build/youtubeUnblock .
tar -czvf static-youtubeUnblock-$VERSION-$SHA-$PLATFORM.tar.gz youtubeUnblock youtubeUnblock.service README.md
- name: Upload artifacts
if: steps.build.outcome == 'success'
uses: actions/upload-artifact@v4
with:
name: static-youtubeUnblock-${{ matrix.arch }}
2024-09-28 17:23:31 +00:00
path: ./**/static-youtubeUnblock*.tar.gz
2024-09-28 09:03:24 +00:00
build-kmod:
needs: prepare
2024-09-28 17:23:31 +00:00
name: build-kmod ${{ matrix.kernel_version }}
2024-09-28 09:03:24 +00:00
runs-on: ubuntu-latest
strategy:
matrix:
2024-09-28 17:23:31 +00:00
include:
- kernel_version: "6.6.52"
source: "https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.6.52.tar.xz"
container_version: "24.04"
- kernel_version: "5.15.167"
source: "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.167.tar.xz"
container_version: "24.04"
- kernel_version: "5.4.284"
source: "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.4.284.tar.xz"
container_version: "24.04"
- kernel_version: "4.19.322"
source: "https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.19.322.tar.xz"
container_version: "24.04"
- kernel_version: "4.4.302"
source: "https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.4.302.tar.xz"
container_version: "24.04"
- kernel_version: "3.10.108"
source: "https://cdn.kernel.org/pub/linux/kernel/v3.x/linux-3.10.108.tar.xz"
container_version: "16.04"
- kernel_version: "3.0.101"
source: "https://cdn.kernel.org/pub/linux/kernel/v3.x/linux-3.0.101.tar.xz"
container_version: "14.04"
2024-09-28 09:03:24 +00:00
steps:
- name: Checkout
uses: actions/checkout@v4
2024-09-28 17:23:31 +00:00
- name: Restore builder from cache
id: cache-restore
uses: actions/cache/restore@v4
2024-09-28 09:03:24 +00:00
with:
2024-09-28 17:23:31 +00:00
path: ~/builder.tar
key: builder-${{ matrix.kernel_version }}
2024-09-28 09:03:24 +00:00
2024-09-28 17:23:31 +00:00
- name: Load builder from cache
if: steps.cache-restore.outputs.cache-hit == 'true'
run: |
docker import - builder < ~/builder.tar
2024-09-28 09:03:24 +00:00
2024-09-28 17:23:31 +00:00
- name: Prepare build env
if: steps.cache-restore.outputs.cache-hit != 'true'
2024-09-28 09:03:24 +00:00
run: |
2024-09-28 17:23:31 +00:00
mkdir ~/linux
pwd
ls /
ls ~
- name: Obtain kernel
if: steps.cache-restore.outputs.cache-hit != 'true'
2024-09-28 09:03:24 +00:00
run: |
2024-09-28 17:23:31 +00:00
cd ~/linux
wget ${{ matrix.source }} -O kernel.tar.xz -q
tar -xf kernel.tar.xz
rm -f kernel.tar.xz
/bin/bash -c "mv linux-* linux"
ls
ls linux
- name: Install docker
if: steps.cache-restore.outputs.cache-hit != 'true'
run: |
cd ~/linux
docker pull ubuntu:${{ matrix.container_version }}
docker container create --name ubu_builder -w / ubuntu:${{ matrix.container_version }} tail -f /dev/null
docker container start ubu_builder
docker container exec ubu_builder bash -c "apt update && apt install -y build-essential flex bc bison libelf-dev elfutils libssl-dev"
docker cp ./linux ubu_builder:/linux
- name: Build kernel
if: steps.cache-restore.outputs.cache-hit != 'true'
run: |
cd ~/linux
docker container exec -w /linux ubu_builder bash -c 'make defconfig'
docker container exec -w /linux ubu_builder bash -c 'make -j $(nproc)'
2024-09-28 09:03:24 +00:00
2024-09-28 17:23:31 +00:00
- name: Export container
if: steps.cache-restore.outputs.cache-hit != 'true'
run: |
cd ~/linux
docker container kill ubu_builder
docker container export ubu_builder > ubu_builder.tar
docker container rm ubu_builder
mv ./ubu_builder.tar ~/builder.tar
docker import - builder < ~/builder.tar
- name: Save kernel image to cache
if: steps.cache-restore.outputs.cache-hit != 'true'
id: cache-save
uses: actions/cache/save@v4
with:
path: ~/builder.tar
key: builder-${{ matrix.kernel_version }}
2024-09-28 09:03:24 +00:00
2024-09-28 17:23:31 +00:00
- name: Build kernel module
2024-09-28 09:03:24 +00:00
id: build
env:
VERSION: ${{ needs.prepare.outputs.version }}
SHA: ${{ needs.prepare.outputs.sha }}
shell: bash
run: |
2024-09-28 17:23:31 +00:00
docker run --rm -v ./:/youtubeUnblock -w /youtubeUnblock builder make kmake KERNEL_BUILDER_MAKEDIR:=/linux
tar -czvf kmod-youtubeUnblock-$VERSION-$SHA-linux-${{ matrix.kernel_version }}.tar.gz kyoutubeUnblock.ko
2024-09-28 09:03:24 +00:00
- name: Upload artifacts
if: steps.build.outcome == 'success'
uses: actions/upload-artifact@v4
with:
2024-09-28 17:23:31 +00:00
name: kmod-youtubeUnblock-linux-${{ matrix.kernel_version }}
2024-09-28 09:03:24 +00:00
path: ./**/kmod-youtubeUnblock*.tar.gz