Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Scolaro <[email protected]>
  • Loading branch information
therealbobo committed Dec 10, 2024
1 parent 4918c7b commit cfd8853
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 133 deletions.
55 changes: 55 additions & 0 deletions .github/actions/install-zig/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: 'install-zig'
description: 'Install zig compiler and make it available in PATH.'

runs:
using: "composite"
steps:
- name: Store zig version as local output
shell: bash
id: store
env:
ZIG_VERSION: '0.14.0-dev.2424+7cd2c1ce8'
run: |
echo "zig_version=${ZIG_VERSION}" >> "$GITHUB_OUTPUT"
# TODO: this is only needed because we are using a development version of zig,
# since we need https://github.com/ziglang/zig/pull/21253 to be included.
# Development versions of zig are not kept alive forever, but get overridden.
# We cache it to keep it alive.
- name: Download zig (cached)
id: cache-zig
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: zig
key: zig-${{ runner.os }}-${{ runner.arch }}-${{ steps.store.outputs.zig_version }}

- name: Download zig
if: steps.cache-zig.outputs.cache-hit != 'true'
shell: bash
run: |
curl -L -o zig.tar.xz https://ziglang.org/builds/zig-linux-$(uname -m)-${{ steps.store.outputs.zig_version }}.tar.xz
tar -xvf zig.tar.xz
cat > zig-linux-$(uname -m)-${{ steps.store.outputs.zig_version }}/zig-cc <<EOF
#!/bin/bash
exec zig cc -target $(uname -m)-linux-gnu.2.17 -mcpu=baseline "\$@"
EOF
chmod +x zig-linux-$(uname -m)-${{ steps.store.outputs.zig_version }}/zig-cc
cat > zig-linux-$(uname -m)-${{ steps.store.outputs.zig_version }}/zig-c++ <<EOF
#!/bin/bash
exec zig c++ -target $(uname -m)-linux-gnu.2.17 -mcpu=baseline "\$@"
EOF
chmod +x zig-linux-$(uname -m)-${{ steps.store.outputs.zig_version }}/zig-c++
mv zig-linux-$(uname -m)-${{ steps.store.outputs.zig_version }}/ zig
- name: Setup zig
shell: bash
id: zig
run: |
echo "$(pwd)/zig" >> $GITHUB_PATH
echo "CC=zig-cc" >> $GITHUB_ENV
echo "CXX=zig-c++" >> $GITHUB_ENV
echo "AR=zig ar" >> $GITHUB_ENV
echo "RANLIB=zig ranlib" >> $GITHUB_ENV
166 changes: 33 additions & 133 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,167 +8,67 @@ on:


jobs:
builder:
env:
REGISTRY: ghcr.io
BUILDER_IMAGE_BASE: ghcr.io/draios/sysdig-builder-pr
SKEL_BUILDER_IMAGE_BASE: ghcr.io/draios/sysdig-skel-builder-pr
BUILDER_DEV: ghcr.io/draios/sysdig-builder:dev
SKEL_BUILDER_DEV: ghcr.io/draios/sysdig-skel-builder:dev

build-sysdig-linux-amd64:
runs-on: ubuntu-latest
container:
image: debian:buster
steps:
- name: Checkout Sysdig
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Check if builder is modified
id: builder-files
uses: tj-actions/changed-files@v34
with:
files: |
docker/builder/**
- name: Set up QEMU
if: steps.builder-files.outputs.any_changed == 'true'
uses: docker/setup-qemu-action@v3
with:
platforms: 'amd64,arm64'

- name: Set up Docker Buildx
if: steps.builder-files.outputs.any_changed == 'true'
uses: docker/setup-buildx-action@v2

- name: Login to Github Packages
if: steps.builder-files.outputs.any_changed == 'true'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get new skeleton builder image tag
id: get-new-skeleton-builder
if: steps.builder-files.outputs.any_changed == 'true'
- name: Install deps ⛓️
run: |

Check failure on line 17 in .github/workflows/ci.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2086:info:9:4: Double quote to prevent globbing and word splitting [shellcheck] Raw Output: .github/workflows/ci.yaml:17:9: shellcheck reported issue in this script: SC2086:info:9:4: Double quote to prevent globbing and word splitting [shellcheck]
echo "skeleton_builder_image=${{ (github.event.pull_request.number != '') && format('{0}:{1}', env.SKEL_BUILDER_IMAGE_BASE, github.event.pull_request.number) || env.SKEL_BUILDER_DEV }}" >> $GITHUB_OUTPUT
- name: Get new builder image tag
id: get-new-builder
if: steps.builder-files.outputs.any_changed == 'true'
apt update && apt install -y --no-install-recommends ninja-build curl ca-certificates build-essential git clang llvm pkg-config autoconf automake libtool libelf-dev wget libc-ares-dev libcurl4-openssl-dev libssl-dev libtbb-dev libjq-dev libjsoncpp-dev libgrpc++-dev protobuf-compiler-grpc libgtest-dev libprotobuf-dev linux-headers-amd64
DIR=$(pwd)
cd /tmp
git clone https://github.com/libbpf/bpftool.git --branch v7.3.0 --single-branch
cd bpftool
git submodule update --init
cd src
make install
cd ${DIR}
- name: Install a recent version of CMake ⛓️
run: |

Check failure on line 29 in .github/workflows/ci.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2046:warning:1:108: Quote this to prevent word splitting [shellcheck] Raw Output: .github/workflows/ci.yaml:29:9: shellcheck reported issue in this script: SC2046:warning:1:108: Quote this to prevent word splitting [shellcheck]

Check failure on line 29 in .github/workflows/ci.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2046:warning:4:31: Quote this to prevent word splitting [shellcheck] Raw Output: .github/workflows/ci.yaml:29:9: shellcheck reported issue in this script: SC2046:warning:4:31: Quote this to prevent word splitting [shellcheck]

Check failure on line 29 in .github/workflows/ci.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2046:warning:5:32: Quote this to prevent word splitting [shellcheck] Raw Output: .github/workflows/ci.yaml:29:9: shellcheck reported issue in this script: SC2046:warning:5:32: Quote this to prevent word splitting [shellcheck]
echo "builder_image=${{ (github.event.pull_request.number != '') && format('{0}:{1}', env.BUILDER_IMAGE_BASE, github.event.pull_request.number) || env.BUILDER_DEV }}" >> $GITHUB_OUTPUT
curl -L -o /tmp/cmake.tar.gz https://github.com/Kitware/CMake/releases/download/v3.22.5/cmake-3.22.5-linux-$(uname -m).tar.gz
gzip -d /tmp/cmake.tar.gz
tar -xpf /tmp/cmake.tar --directory=/tmp
cp -R /tmp/cmake-3.22.5-linux-$(uname -m)/* /usr
rm -rf /tmp/cmake-3.22.5-linux-$(uname -m)/
- name: Build new skeleton builder
id: skeleton-builder
if: steps.builder-files.outputs.any_changed == 'true'
uses: docker/build-push-action@v6
with:
context: docker/builder
file: docker/builder/modern_bpf_probe.Dockerfile
platforms: linux/amd64,linux/arm64
tags: ${{ steps.get-new-skeleton-builder.outputs.skeleton_builder_image }}
push: true

- name: Build new builder
id: build-builder
if: steps.builder-files.outputs.any_changed == 'true'
uses: docker/build-push-action@v6
with:
context: docker/builder
platforms: linux/amd64,linux/arm64
tags: ${{ steps.get-new-builder.outputs.builder_image }}
push: true

outputs:
builder_image: ${{ (steps.builder-files.outputs.any_changed == 'true') && steps.get-new-builder.outputs.builder_image || env.BUILDER_DEV }}
skeleton_builder_image: ${{ (steps.builder-files.outputs.any_changed == 'true') && steps.get-new-skeleton-builder.outputs.skeleton_builder_image || env.SKEL_BUILDER_DEV }}

build-skeleton-sysdig-linux-amd64:
needs: builder
runs-on: ubuntu-latest
container:
image: ${{ needs.builder.outputs.skeleton_builder_image }}
steps:
- name: Checkout Sysdig
uses: actions/checkout@v4
with:
path: sysdig
- name: Link paths
run: |
mkdir -p /source
ln -s "$GITHUB_WORKSPACE/sysdig" /source/sysdig
- name: Prepare build skeleton
run: build cmake-skeleton
- name: Build skeleton
run: build make-skeleton
- name: Cache build skeleton
uses: actions/cache/save@v3
if: always()
id: cache
with:
path: /build-skeleton
key: build-skeleton-${{ github.run_id }}
fetch-depth: 0

build-sysdig-linux-amd64:
needs: [builder,build-skeleton-sysdig-linux-amd64]
runs-on: ubuntu-latest
container:
image: ${{ needs.builder.outputs.builder_image }}
volumes:
- '/node20217:/node20217:rw,rshared'
- '/node20217:/__e/node20:ro,rshared'
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
steps:
- name: install nodejs20glibc2.17
run: |
yum install curl -yyq
curl -LO https://unofficial-builds.nodejs.org/download/release/v20.9.0/node-v20.9.0-linux-x64-glibc-217.tar.xz
tar -xf node-v20.9.0-linux-x64-glibc-217.tar.xz --strip-components 1 -C /node20217
ldd /__e/node20/bin/node
- name: Install zig
uses: ./.github/actions/install-zig

- name: Checkout Sysdig
uses: actions/checkout@v4
with:
path: sysdig
- name: Link paths
- name: Build Sysdig
run: |
mkdir -p /source
ln -s "$GITHUB_WORKSPACE/sysdig" /source/sysdig
- name: Restore build skeleton
id: cache
uses: actions/cache/restore@v3
with:
path: /build-skeleton
key: build-skeleton-${{ github.run_id }}
restore-keys: build-skeleton-
- name: Build
run: build cmake
- name: Build packages
run: build package
cmake -DUSE_BUNDLED_DEPS=ON -DBUILD_BPF=ON -DBUILD_SYSDIG_MODERN_BPF=ON -DBUILD_DRIVER=ON -DCMAKE_BUILD_TYPE=Release -S . -B build -G Ninja
cd build
ninja package
- name: Upload rpm package
uses: actions/upload-artifact@v3

Check failure on line 51 in .github/workflows/ci.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 the runner of "actions/upload-artifact@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue [action] Raw Output: .github/workflows/ci.yaml:51:15: the runner of "actions/upload-artifact@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue [action]
with:
name: sysdig-dev-linux-x86_64.rpm
path: |
/build/release/sysdig-*.rpm
build/release/sysdig-*.rpm
- name: Upload deb package
uses: actions/upload-artifact@v3

Check failure on line 58 in .github/workflows/ci.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 the runner of "actions/upload-artifact@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue [action] Raw Output: .github/workflows/ci.yaml:58:15: the runner of "actions/upload-artifact@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue [action]
with:
name: sysdig-dev-linux-x86_64.deb
path: |
/build/release/sysdig-*.deb
build/release/sysdig-*.deb
- name: Upload tar.gz package
uses: actions/upload-artifact@v3

Check failure on line 65 in .github/workflows/ci.yaml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 the runner of "actions/upload-artifact@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue [action] Raw Output: .github/workflows/ci.yaml:65:15: the runner of "actions/upload-artifact@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue [action]
with:
name: sysdig-dev-linux-x86_64.tar.gz
path: |
/build/release/sysdig-*.tar.gz
build/release/sysdig-*.tar.gz
build-sysdig-linux-arm64:
needs: builder
env:
REGISTRY: ghcr.io
BUILDER_IMAGE_BASE: ghcr.io/draios/sysdig-builder-pr
Expand Down

0 comments on commit cfd8853

Please sign in to comment.