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 5, 2024
1 parent 6d6058c commit 3668f63
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 198 deletions.
60 changes: 60 additions & 0 deletions .github/actions/install-zig/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: 'install-zig'
description: 'Install zig compiler and make it available in PATH.'
inputs:
arch:
description: 'The arch of the build'
required: true
default: 'x86_64'

runs:
using: "composite"
steps:
- name: Store zig version as local output
shell: bash
id: store
env:
ZIG_VERSION: '0.14.0-dev.1952+9f84f7f92'
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 ${{ github.event.inputs.arch }}-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 ${{ github.event.inputs.arch }}-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
238 changes: 40 additions & 198 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,228 +8,70 @@ 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

runs-on: ubuntu-latest
build-libs-linux:
name: build-libs-linux-${{ matrix.arch }}
runs-on: 'ubuntu-22.04'
strategy:
fail-fast: false
matrix:
arch: [x86_64, aarch64]
container:
image: debian:buster
steps:
- name: Checkout Sysdig
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install deps ⛓️
run: |

Check failure on line 22 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:175: Quote this to prevent word splitting [shellcheck] Raw Output: .github/workflows/ci.yaml:22:9: shellcheck reported issue in this script: SC2046:warning:1:175: Quote this to prevent word splitting [shellcheck]

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

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2006:style:1:175: Use $(...) notation instead of legacy backticks `...` [shellcheck] Raw Output: .github/workflows/ci.yaml:22:9: shellcheck reported issue in this script: SC2006:style:1:175: Use $(...) notation instead of legacy backticks `...` [shellcheck]
apt update && apt install -y --no-install-recommends curl ca-certificates build-essential git clang llvm pkg-config autoconf automake libtool libelf-dev wget rpm linux-tools-`uname -r`
- name: Check if builder is modified
id: builder-files
uses: tj-actions/changed-files@v34
with:
files: |
docker/builder/**
- name: Install a recent version of CMake ⛓️
run: |

Check failure on line 26 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:26:9: shellcheck reported issue in this script: SC2046:warning:1:108: Quote this to prevent word splitting [shellcheck]

Check failure on line 26 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:26:9: shellcheck reported issue in this script: SC2046:warning:4:31: Quote this to prevent word splitting [shellcheck]

Check failure on line 26 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:26:9: shellcheck reported issue in this script: SC2046:warning:5:32: Quote this to prevent word splitting [shellcheck]
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: Set up QEMU
if: steps.builder-files.outputs.any_changed == 'true'
uses: docker/setup-qemu-action@v2
- name: Checkout Libs ⤵️
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
platforms: 'amd64,arm64'

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

- name: Login to Github Packages
if: steps.builder-files.outputs.any_changed == 'true'
uses: docker/login-action@v2
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'
run: |
echo "name=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'
- name: Git safe directory
run: |

Check failure on line 39 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:1:42: Double quote to prevent globbing and word splitting [shellcheck] Raw Output: .github/workflows/ci.yaml:39:9: shellcheck reported issue in this script: SC2086:info:1:42: Double quote to prevent globbing and word splitting [shellcheck]
echo "name=builder_image::${{ (github.event.pull_request.number != '') && format('{0}:{1}', env.BUILDER_IMAGE_BASE, github.event.pull_request.number) || env.BUILDER_DEV }}" >> $GITHUB_OUTPUT
git config --global --add safe.directory $GITHUB_WORKSPACE
- name: Build new skeleton builder
id: skeleton-builder
if: steps.builder-files.outputs.any_changed == 'true'
uses: docker/build-push-action@v3
- name: Install zig
if: matrix.name == 'zig'

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

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 property "name" is not defined in object type {arch: string} [expression] Raw Output: .github/workflows/ci.yaml:43:13: property "name" is not defined in object type {arch: string} [expression]
uses: ./.github/actions/install-zig
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
arch: ${{ matrix.arch }}

- name: Build new builder
id: build-builder
if: steps.builder-files.outputs.any_changed == 'true'
uses: docker/build-push-action@v3
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@v3
with:
path: sysdig
- name: Link paths
- name: Build
env:
UBSAN_OPTIONS: print_stacktrace=1
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 }}
mkdir -p build
cd build && cmake -DUSE_BUNDLED_DEPS=ON ..
KERNELDIR=/lib/modules/$(ls /lib/modules)/build make -j4 package
build-sysdig-linux-amd64:
needs: [builder,build-skeleton-sysdig-linux-amd64]
runs-on: ubuntu-latest
container:
image: ${{ needs.builder.outputs.builder_image }}
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
steps:
- name: Checkout Sysdig
uses: actions/checkout@v3
with:
path: sysdig
- name: Link paths
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
- name: Upload rpm package
uses: actions/upload-artifact@v3

Check failure on line 57 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:57: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
name: sysdig-dev-linux-${{ matrix.arch }}.rpm
path: |
/build/release/sysdig-*.rpm
${{ github.workspace }}/build/release/sysdig-*.rpm
- name: Upload deb package
uses: actions/upload-artifact@v3

Check failure on line 63 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:63: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
- name: Upload tar.gz package
uses: actions/upload-artifact@v3
with:
name: sysdig-dev-linux-x86_64.tar.gz
name: sysdig-dev-linux-${{ matrix.arch }}.deb
path: |
/build/release/sysdig-*.tar.gz
build-sysdig-linux-arm64:
needs: 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
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
runs-on: ubuntu-latest
steps:
- name: Checkout Sysdig
uses: actions/checkout@v3
with:
path: sysdig
- name: Create build dir
run: |
mkdir -p ${{ github.workspace }}/sysdig-build-aarch64
- name: Login to Github Packages
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
${{ github.workspace }}/build/release/sysdig-*.deb
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: 'amd64,arm64'
- name: Run the build skeleton process with Docker
uses: addnab/docker-run-action@v3
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ${{ env.REGISTRY }}
image: ${{ needs.builder.outputs.skeleton_builder_image }}
options: --platform=linux/arm64 -v ${{ github.workspace }}/sysdig:/source/sysdig -v ${{ github.workspace }}/sysdig-build-aarch64:/build/dev-packages -v ${{ github.workspace }}/skeleton-build:/build-skeleton
run: |
mkdir -p /build/dev-packages && \
build cmake-skeleton && \
build make-skeleton
- name: Run the build process with Docker
uses: addnab/docker-run-action@v3
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ${{ env.REGISTRY }}
image: ${{ needs.builder.outputs.builder_image }}
options: --platform=linux/arm64 -v ${{ github.workspace }}/sysdig:/source/sysdig -v ${{ github.workspace }}/sysdig-build-aarch64:/build/dev-packages -v ${{ github.workspace }}/skeleton-build:/build-skeleton
run: |
mkdir -p /build/dev-packages && \
build cmake && \
build package && \
cp /build/release/sysdig-* /build/dev-packages
- name: Upload deb package
uses: actions/upload-artifact@v3
with:
name: sysdig-dev-linux-aarch64.deb
path: |
${{ github.workspace }}/sysdig-build-aarch64/sysdig-*.deb
- name: Upload rpm package
uses: actions/upload-artifact@v3
with:
name: sysdig-dev-linux-aarch64.rpm
path: |
${{ github.workspace }}/sysdig-build-aarch64/sysdig-*.rpm
- name: Upload tar.gz package
uses: actions/upload-artifact@v3
with:
name: sysdig-dev-linux-aarch64.tar.gz
name: sysdig-dev-linux-${{ matrix.arch }}.tar.gz
path: |
${{ github.workspace }}/sysdig-build-aarch64/sysdig-*.tar.gz
${{ github.workspace }}/build/release/sysdig-*.tar.gz
build-sysdig-others-amd64:
name: build-sysdig-other-amd64
Expand Down

0 comments on commit 3668f63

Please sign in to comment.