Skip to content

Commit

Permalink
chore: bump ubuntu images, go, clang, actions...
Browse files Browse the repository at this point in the history
clang-format-12 is only available up to Ubuntu 22.04, so a little hack
is needed to install it in Ubuntu 24.04.
  • Loading branch information
geyslan committed May 23, 2024
1 parent 7b0db19 commit 85bc882
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 29 deletions.
18 changes: 12 additions & 6 deletions .github/actions/build-dependencies/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ description: |
inputs:
go-version:
description: go version
default: "1.21"
default: "1.22.3"
runs:
using: composite
steps:
- name: Setup Go
uses: actions/setup-go@v5
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version: "${{ inputs.go-version }}"
- name: Install Compilers & Formatters
Expand All @@ -18,12 +18,18 @@ runs:
sudo apt-get install --yes bsdutils
sudo apt-get install --yes build-essential
sudo apt-get install --yes pkgconf
sudo apt-get install --yes llvm-12 clang-12
sudo apt-get install --yes clang-format-12
sudo apt-get install --yes llvm-14 clang-14
sudo apt-get install --yes zlib1g-dev libelf-dev
for tool in "clang" "llc" "llvm-strip" "clang-format"
for tool in "clang" "llc" "llvm-strip"
do
sudo rm -f /usr/bin/$tool
sudo ln -s /usr/bin/$tool-12 /usr/bin/$tool
sudo ln -s /usr/bin/$tool-14 /usr/bin/$tool
done
# clang-format-12 is not available in noble archive so get it from jammy
echo "deb http://cz.archive.ubuntu.com/ubuntu jammy main universe" | sudo -E tee /etc/apt/sources.list.d/jammy.list
sudo apt-get update
sudo apt-get install -y clang-format-12
sudo rm /etc/apt/sources.list.d/jammy.list
sudo apt-get update
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-12 100
shell: bash
22 changes: 11 additions & 11 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ on:
jobs:
analyze-code:
name: Analyze Code
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Checkout Code
uses: actions/checkout@v4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Install Dependencies
uses: ./.github/actions/build-dependencies
- name: Lint
Expand Down Expand Up @@ -54,13 +54,13 @@ jobs:
shell: bash
libbpfgo-unit-tests:
name: libbpfgo Unit Tests
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
matrix:
go-version: [ 1.18, 1.19, '1.20', '1.21', 'stable' ]
go-version: [ '1.21', '1.22', 'stable' ]
steps:
- name: Checkout Code
uses: actions/checkout@v4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Install Dependencies
uses: ./.github/actions/build-dependencies
with:
Expand All @@ -70,13 +70,13 @@ jobs:
make libbpfgo-static-test
helpers-unit-tests:
name: Helpers Unit Tests
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
matrix:
go-version: [ 1.18, 1.19, '1.20', '1.21', 'stable' ]
go-version: [ '1.21', '1.22', 'stable' ]
steps:
- name: Checkout Code
uses: actions/checkout@v4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Install Dependencies
uses: ./.github/actions/build-dependencies
with:
Expand All @@ -86,13 +86,13 @@ jobs:
make helpers-test-static-run
self-tests:
name: Selftests
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
matrix:
go-version: [ 1.18, 1.19, '1.20', '1.21', 'stable' ]
go-version: [ '1.21', '1.22', 'stable' ]
steps:
- name: Checkout Code
uses: actions/checkout@v4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Install Dependencies
uses: ./.github/actions/build-dependencies
with:
Expand Down
4 changes: 2 additions & 2 deletions builder/Vagrantfile-ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ VM_SOURCE = "/vagrant"
Vagrant.configure("2") do |config|
case ARCH
when "amd64"
config.vm.box = "ubuntu/jammy64"
config.vm.box = "bento/ubuntu-24.04"
when "arm64"
config.vm.box = "bento/ubuntu-22.04-arm64"
config.vm.box = "bento/ubuntu-24.04"
end

case HOSTOS
Expand Down
37 changes: 32 additions & 5 deletions builder/prepare-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,21 @@

# variables

[ -z "${GO_VERSION}" ] && GO_VERSION="1.21"
[ -z "${CLANG_VERSION}" ] && CLANG_VERSION="12"
[ -z "${ARCH}" ] && ARCH="amd64"
[ -z "${GO_VERSION}" ] && GO_VERSION="1.22"
[ -z "${CLANG_VERSION}" ] && CLANG_VERSION="14"
[ -z "${ARCH}" ] && ARCH=$(uname -m)

case "${ARCH}" in
x86_64|amd64)
ARCH="amd64"
;;
aarch64|arm64)
ARCH="arm64"
;;
*)
die "unsupported architecture ${ARCH}"
;;
esac


# functions
Expand Down Expand Up @@ -44,6 +56,19 @@ install_pkgs() {
done
}

install_clang_format_12() {
info "Installing clang-format-12"

echo "deb http://cz.archive.ubuntu.com/ubuntu jammy main universe" | sudo -E tee /etc/apt/sources.list.d/jammy.list
sudo -E apt-get update
sudo -E apt-get install -y clang-format-12 || die "could not install clang-format-12"
sudo -E rm /etc/apt/sources.list.d/jammy.list || die "could not remove jammy.list"
sudo -E apt-get update
sudo -E update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-12 100

info "clang-format-12 installed"
}

setup_go() {
info "Setting Go ${GO_VERSION} as default"

Expand All @@ -59,7 +84,7 @@ setup_go() {
setup_clang() {
info "Setting Clang ${CLANG_VERSION} as default"

local tools="clang llc llvm-strip clang-format"
local tools="clang llc llvm-strip"
for tool in ${tools}
do
sudo -E update-alternatives --install "/usr/bin/${tool}" "${tool}" "/usr/bin/${tool}-${CLANG_VERSION}" 100
Expand All @@ -79,11 +104,13 @@ install_pkgs \
coreutils bsdutils findutils \
build-essential pkgconf \
golang-"${GO_VERSION}"-go \
llvm-"${CLANG_VERSION}" clang-"${CLANG_VERSION}" clang-format-"${CLANG_VERSION}" \
llvm-"${CLANG_VERSION}" clang-"${CLANG_VERSION}" \
linux-headers-generic \
linux-tools-generic linux-tools-"$(uname -r)" \
libbpf-dev libelf-dev libzstd-dev zlib1g-dev

install_clang_format_12

setup_go
setup_clang

Expand Down
9 changes: 4 additions & 5 deletions docs/Vagrantfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

## Boxes

Currently there are two boxes available in [Vagrantfile-ubuntu](./../builder/Vagrantfile-ubuntu):
Currently there is one box available in [Vagrantfile-ubuntu](./../builder/Vagrantfile-ubuntu):

| Box | Providers |
|----------------------------------------------------------------------------------------------|--------------------------|
| [generic/ubuntu2204](https://app.vagrantup.com/generic/boxes/ubuntu2204) (amd64) | virtualbox, parallels |
| [jharoian3/ubuntu-22.04-arm64](https://app.vagrantup.com/jharoian3/boxes/ubuntu-22.04-arm64) | parallels |
| Box | Providers |
|--------------------------------------------------------------------------|--------------------------|
| [bento/ubuntu-24.04](https://app.vagrantup.com/bento/boxes/ubuntu-24.04) | virtualbox (amd64), parallels (arm64,amd64), ...|

It is recommended to use them through the respective [Makefile rules](../Readme.md#contributing) as they are or overriding the `ARCH` environment variable if your architecture and provider allow such virtualization. E.g.: `make vagrant-up ARCH=amd64`.

Expand Down

0 comments on commit 85bc882

Please sign in to comment.