Skip to content

Commit

Permalink
add ci jobs
Browse files Browse the repository at this point in the history
fix missing clean

rename job name

stash
  • Loading branch information
mozillazg committed Mar 15, 2024
1 parent a7a2ca6 commit 2821d56
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: gomod
directory: /
open-pull-requests-limit: 10
schedule:
interval: monthly
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
38 changes: 38 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build programs

on:
push:
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'

- name: Install dependencies
run: |
set -e
sudo apt-get update
sudo apt-get install --yes build-essential pkgconf libelf-dev llvm-12 clang-12
for tool in "clang" "llc" "llvm-strip"; do
path=$(which $tool-12)
test $(which $tool) && sudo mv $(which $tool){,.bak}
sudo ln -sf $path ${path%-*}
done
git submodule update --init --recursive
- name: build programs
run: |
set -e
bash ci.sh
3 changes: 3 additions & 0 deletions chapter13/memfd-create/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

build:
go build

clean:
rm -rf ./memfd-create
3 changes: 3 additions & 0 deletions chapter14/inspect-ebpf-helpers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ build:

run:
sudo ./inspect-ebpf-helpers

clean:
rm -rf ./inspect-ebpf-helpers
38 changes: 38 additions & 0 deletions ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/env bash

set -e


function test_dir() {
if test -f Makefile; then
echo -e "\033[33m=== start build $1 ===\033[0;39m"
make clean && make
echo -e "\033[32m=== finish build $1 ===\033[0;39m"
fi
}

function test_multiple_dir() {
local dir=$1

for sub in $(ls ./); do
local subpath="$dir/$sub"
if test -d "$sub"; then
( cd "$sub" && test_multiple_dir "$subpath" )
elif test -f $sub; then
if [[ "$sub" == *Makefile ]]; then
test_dir "$dir"
fi
fi
done
}


function main() {
local dir="${1:-chapter*}"
echo $dir
for i in $(find $dir -maxdepth 0 -type d); do
( cd $i && test_multiple_dir "$i")
done
}

main "$@"
4 changes: 3 additions & 1 deletion common.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ CGO_EXTLDFLAGS_DYN = '-w'

PROGRAM = main

all:
build:
$(MAKE) -C . $(PROGRAM)

run:
sudo ./${PROGRAM}

# vmlinux header file
Expand Down

0 comments on commit 2821d56

Please sign in to comment.