Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
geyslan committed Apr 26, 2024
1 parent 4b7bed8 commit bf87090
Show file tree
Hide file tree
Showing 4 changed files with 350 additions and 133 deletions.
77 changes: 4 additions & 73 deletions .github/actions/build-dependencies/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,75 +2,16 @@ name: Build Dependencies
description: |
Install build dependencies to test and compile btfhub artifacts
inputs:
# set default versions in a single place (as default)
go-version:
description: go version
install-deps-opt:
description: 'Install dependencies script option (pr, cron)'
required: true
default: "1.19.5"
default: 'pr'
runs:
using: composite
steps:
- name: Install ubuntu packages
run: |
export DEBIAN_FRONTEND=noninteractive
sudo dpkg --purge unattended-upgrades
sudo apt-get update
sudo apt-get install -y bsdutils build-essential pkgconf
sudo apt-get install -y zlib1g-dev libelf-dev
sudo apt-get install -y software-properties-common
sudo apt-get install -y devscripts ubuntu-dev-tools
shell: bash
- name: Install golang
run: |
rm -rf /usr/local/go
curl -L -o /tmp/go.tar.xz https://go.dev/dl/go${{ inputs.go-version }}.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf /tmp/go.tar.xz
sudo update-alternatives --remove-all go || true
sudo update-alternatives --remove-all gofmt || true
sudo update-alternatives --install /usr/bin/go go /usr/local/go/bin/go 1
sudo update-alternatives --install /usr/bin/gofmt gofmt /usr/local/go/bin/gofmt 1
shell: bash
- name: Install llvm
run: |
export DEBIAN_FRONTEND=noninteractive
cd /tmp
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 14
sudo apt-get install -y clang-14 clangd-14 clang-tools-14 clang-format-14
sudo apt-get install -y llvm-14 llvm-14-runtime llvm-14-tools
sudo update-alternatives --remove-all cc || true
sudo update-alternatives --remove-all clang || true
sudo update-alternatives --remove-all clang++ || true
sudo update-alternatives --remove-all llc || true
sudo update-alternatives --remove-all lld || true
sudo update-alternatives --remove-all clangd || true
sudo update-alternatives --remove-all clang-format || true
sudo update-alternatives --remove-all llvm-strip || true
sudo update-alternatives --remove-all llvm-config || true
sudo update-alternatives --remove-all ld.lld || true
sudo update-alternatives --remove-all llvm-ar || true
sudo update-alternatives --remove-all llvm-nm || true
sudo update-alternatives --remove-all llvm-objcopy || true
sudo update-alternatives --remove-all llvm-objdump || true
sudo update-alternatives --remove-all llvm-readelf || true
sudo update-alternatives --remove-all opt || true
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-14 140 \
--slave /usr/bin/clang++ clang++ /usr/bin/clang++-14 \
--slave /usr/bin/clangd clangd /usr/bin/clangd-14 \
--slave /usr/bin/clang-format clang-format /usr/bin/clang-format-14 \
--slave /usr/bin/lld lld /usr/bin/lld-14 \
--slave /usr/bin/llc llc /usr/bin/llc-14 \
--slave /usr/bin/llvm-strip llvm-strip /usr/bin/llvm-strip-14 \
--slave /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-14 \
--slave /usr/bin/ld.lld ld.lld /usr/bin/ld.lld-14 \
--slave /usr/bin/llvm-ar llvm-ar /usr/bin/llvm-ar-14 \
--slave /usr/bin/llvm-nm llvm-nm /usr/bin/llvm-nm-14 \
--slave /usr/bin/llvm-objcopy llvm-objcopy /usr/bin/llvm-objcopy-14 \
--slave /usr/bin/llvm-objdump llvm-objdump /usr/bin/llvm-objdump-14 \
--slave /usr/bin/llvm-readelf llvm-readelf /usr/bin/llvm-readelf-14 \
--slave /usr/bin/opt opt /usr/bin/opt-14 \
--slave /usr/bin/cc cc /usr/bin/clang-14
./tests/install-deps.sh ${{ inputs.install-deps-opt }}
shell: bash
- name: Install pahole
run: |
Expand All @@ -80,13 +21,3 @@ runs:
run: |
./3rdparty/bpftool.sh
shell: bash
- name: Install staticchecker
run: |
GOROOT=/usr/local/go GOPATH=$HOME/go go install honnef.co/go/tools/cmd/staticcheck@latest
sudo cp $HOME/go/bin/staticcheck /usr/bin/
shell: bash
- name: Install goimports-reviser
run: |
GOROOT=/usr/local/go GOPATH=$HOME/go go install github.com/incu6us/goimports-reviser/v3@latest
sudo cp $HOME/go/bin/goimports-reviser /usr/bin/
shell: bash
77 changes: 17 additions & 60 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,60 +24,17 @@ jobs:
swapon /swapfile
shell: bash
#
- name: Install needed ubuntu packages
run: |
export DEBIAN_FRONTEND=noninteractive
dpkg --purge unattended-upgrades
apt-get update
apt-get install -y bsdutils build-essential pkgconf
apt-get install -y zlib1g-dev libelf-dev
apt-get install -y software-properties-common
apt-get install -y devscripts ubuntu-dev-tools
shell: bash
#
- name: Update alternatives for LLVM
run: |
export DEBIAN_FRONTEND=noninteractive
update-alternatives --remove-all cc || true
update-alternatives --remove-all clang || true
update-alternatives --remove-all clang++ || true
update-alternatives --remove-all llc || true
update-alternatives --remove-all lld || true
update-alternatives --remove-all clangd || true
update-alternatives --remove-all clang-format || true
update-alternatives --remove-all llvm-strip || true
update-alternatives --remove-all llvm-config || true
update-alternatives --remove-all ld.lld || true
update-alternatives --remove-all llvm-ar || true
update-alternatives --remove-all llvm-nm || true
update-alternatives --remove-all llvm-objcopy || true
update-alternatives --remove-all llvm-objdump || true
update-alternatives --remove-all llvm-readelf || true
update-alternatives --remove-all opt || true
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-14 140 \
--slave /usr/bin/clang++ clang++ /usr/bin/clang++-14 \
--slave /usr/bin/clangd clangd /usr/bin/clangd-14 \
--slave /usr/bin/clang-format clang-format /usr/bin/clang-format-14 \
--slave /usr/bin/lld lld /usr/bin/lld-14 \
--slave /usr/bin/llc llc /usr/bin/llc-14 \
--slave /usr/bin/llvm-strip llvm-strip /usr/bin/llvm-strip-14 \
--slave /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-14 \
--slave /usr/bin/ld.lld ld.lld /usr/bin/ld.lld-14 \
--slave /usr/bin/llvm-ar llvm-ar /usr/bin/llvm-ar-14 \
--slave /usr/bin/llvm-nm llvm-nm /usr/bin/llvm-nm-14 \
--slave /usr/bin/llvm-objcopy llvm-objcopy /usr/bin/llvm-objcopy-14 \
--slave /usr/bin/llvm-objdump llvm-objdump /usr/bin/llvm-objdump-14 \
--slave /usr/bin/llvm-readelf llvm-readelf /usr/bin/llvm-readelf-14 \
--slave /usr/bin/opt opt /usr/bin/opt-14 \
--slave /usr/bin/cc cc /usr/bin/clang-14
shell: bash
#
- name: Check out BTFHub
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: aquasecurity/btfhub
path: ./btfhub
#
- name: "Prepare Image (Fix AMI)"
uses: ./.github/actions/build-dependencies
with:
install-deps-opt: cron
#
- name: Checkout BTFHub Archive
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
Expand All @@ -86,18 +43,18 @@ jobs:
persist-credentials: false
fetch-depth: 1
path: ./btfhub-archive
#
- name: Install pahole
run: |
cd btfhub
./3rdparty/pahole.sh
shell: bash
#
- name: Install bpftool
run: |
cd btfhub
./3rdparty/bpftool.sh
shell: bash
# #
# - name: Install pahole
# run: |
# cd btfhub
# ./3rdparty/pahole.sh
# shell: bash
# #
# - name: Install bpftool
# run: |
# cd btfhub
# ./3rdparty/bpftool.sh
# shell: bash
#
- name: Bring current BTFHub Archive
run: |
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,29 @@ jobs:
name: Verify and Analyze Code
runs-on: ubuntu-latest
steps:
#
- name: Checkout Code
uses: actions/checkout@v2
with:
submodules: true
#
- name: Install Dependencies
uses: ./.github/actions/build-dependencies
with:
install-deps-opt: pr
#
- name: Install staticchecker
run: |
GOROOT=/usr/local/go GOPATH=$HOME/go go install honnef.co/go/tools/cmd/staticcheck@latest
sudo cp $HOME/go/bin/staticcheck /usr/bin/
shell: bash
#
- name: Install goimports-reviser
run: |
GOROOT=/usr/local/go GOPATH=$HOME/go go install github.com/incu6us/goimports-reviser/v3@latest
sudo cp $HOME/go/bin/goimports-reviser /usr/bin/
shell: bash
#
- name: Lint
run: |
if test -z "$(gofmt -l .)"; then
Expand All @@ -45,9 +62,11 @@ jobs:
gofmt -s -d .
exit 1
fi
#
- name: Check Golang Vet
run: |
make check-vet
#
- name: Check with StaticCheck
run: |
make check-staticcheck
Expand All @@ -60,12 +79,17 @@ jobs:
- verify-analyze-code
runs-on: ubuntu-latest
steps:
#
- name: Checkout Code
uses: actions/checkout@v2
with:
submodules: true
#
- name: Install Dependencies
uses: ./.github/actions/build-dependencies
with:
install-deps-opt: pr
#
- name: Run Unit Tests
run: |
make test-unit
Loading

0 comments on commit bf87090

Please sign in to comment.