Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dpkg lock on CI actions #114

Merged
merged 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 14 additions & 73 deletions .github/actions/build-dependencies/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,91 +2,32 @@ 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
from:
description: 'Install dependencies script option (pr, cron)'
required: true
default: "1.19.5"
default: 'pr'
run-on:
description: 'Set working-directory to run'
required: false
default: '.'
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.from }}
shell: bash
working-directory: ${{ inputs.run-on }}
#
- name: Install pahole
run: |
./3rdparty/pahole.sh
shell: bash
working-directory: ${{ inputs.run-on }}
#
- name: Install bpftool
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
working-directory: ${{ inputs.run-on }}
67 changes: 6 additions & 61 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,60 +24,18 @@ 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: ./btfhub/.github/actions/build-dependencies
with:
run-on: ./btfhub
from: cron
#
- name: Checkout BTFHub Archive
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
Expand All @@ -86,19 +44,6 @@ 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: Bring current BTFHub Archive
run: |
cd btfhub
Expand Down
48 changes: 27 additions & 21 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,35 @@ concurrency:
group: ${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
#
# CODE VERIFICATION
#
verify-analyze-code:
name: Verify and Analyze Code
verify-and-test:
name: Verify and Test
runs-on: ubuntu-latest
steps:
#
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: true
#
- name: Install Dependencies
uses: ./.github/actions/build-dependencies
with:
from: pr
#
# CODE VERIFICATION
#
- name: Install staticchecker
run: |
GOROOT=/usr/local/go GOPATH=$HOME/go go install honnef.co/go/tools/cmd/staticcheck@a093f7c2d3d45d5104fb3414ae939a98be37be02 # v0.4.7
sudo cp $HOME/go/bin/staticcheck /usr/bin/
shell: bash
#
- name: Install goimports-reviser
run: |
go install github.com/incu6us/goimports-reviser/v3@38044e6cb02749195e5384d9d9535ed00a10fc1f # v3.6.4
sudo cp $HOME/go/bin/goimports-reviser /usr/bin/
shell: bash
#
- name: Lint
run: |
if test -z "$(gofmt -l .)"; then
Expand All @@ -45,27 +61,17 @@ jobs:
gofmt -s -d .
exit 1
fi
#
- name: Check Golang Vet
run: |
make check-vet
#
- name: Check with StaticCheck
run: |
make check-staticcheck
#
# CODE TESTS
#
unit-tests:
name: Unit Tests
needs:
- 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
#
# CODE TESTING
#
- name: Run Unit Tests
run: |
make test-unit
Loading