From 85bc88280b6b7446d8f1edcdbd1f710e3b1c4108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geyslan=20Greg=C3=B3rio?= Date: Wed, 22 May 2024 18:00:00 -0300 Subject: [PATCH] chore: bump ubuntu images, go, clang, actions... clang-format-12 is only available up to Ubuntu 22.04, so a little hack is needed to install it in Ubuntu 24.04. --- .../actions/build-dependencies/action.yaml | 18 ++++++--- .github/workflows/pr.yaml | 22 +++++------ builder/Vagrantfile-ubuntu | 4 +- builder/prepare-ubuntu.sh | 37 ++++++++++++++++--- docs/Vagrantfile.md | 9 ++--- 5 files changed, 61 insertions(+), 29 deletions(-) diff --git a/.github/actions/build-dependencies/action.yaml b/.github/actions/build-dependencies/action.yaml index 8cf58bb0..a57ff84e 100644 --- a/.github/actions/build-dependencies/action.yaml +++ b/.github/actions/build-dependencies/action.yaml @@ -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 @@ -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 diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 98757df1..21601cde 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -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 @@ -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: @@ -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: @@ -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: diff --git a/builder/Vagrantfile-ubuntu b/builder/Vagrantfile-ubuntu index 960c87b5..6f73184c 100644 --- a/builder/Vagrantfile-ubuntu +++ b/builder/Vagrantfile-ubuntu @@ -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 diff --git a/builder/prepare-ubuntu.sh b/builder/prepare-ubuntu.sh index c132b220..d3a4bdbd 100755 --- a/builder/prepare-ubuntu.sh +++ b/builder/prepare-ubuntu.sh @@ -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 @@ -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" @@ -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 @@ -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 diff --git a/docs/Vagrantfile.md b/docs/Vagrantfile.md index c20876de..88e4f832 100644 --- a/docs/Vagrantfile.md +++ b/docs/Vagrantfile.md @@ -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`.