Skip to content

Commit 54c4b07

Browse files
committed
u
Signed-off-by: Joe Isaacs <[email protected]>
1 parent ecdd7c0 commit 54c4b07

File tree

6 files changed

+314
-153
lines changed

6 files changed

+314
-153
lines changed

.github/actions/build-ami/action.yml

Lines changed: 0 additions & 120 deletions
This file was deleted.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Variables (passed from Packer)
5+
RUST_TOOLCHAIN="${RUST_TOOLCHAIN:-1.89}"
6+
PROTOC_VERSION="${PROTOC_VERSION:-29.3}"
7+
FLATC_VERSION="${FLATC_VERSION:-25.9.23}"
8+
9+
echo "=== Installing Vortex CI dependencies ==="
10+
11+
# Install build dependencies
12+
echo "Installing system packages..."
13+
sudo apt-get update
14+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
15+
cmake \
16+
ninja-build \
17+
clang \
18+
lld \
19+
llvm \
20+
pkg-config \
21+
libssl-dev
22+
23+
# Install Rust
24+
echo "Installing Rust ${RUST_TOOLCHAIN}..."
25+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain "${RUST_TOOLCHAIN}"
26+
source "$HOME/.cargo/env"
27+
echo 'source $HOME/.cargo/env' >> "$HOME/.bashrc"
28+
29+
# Install Rust components
30+
rustup component add clippy rustfmt
31+
rustup toolchain install nightly
32+
rustup component add --toolchain nightly rustfmt clippy rust-src miri llvm-tools-preview
33+
34+
echo "Rust installed:"
35+
cargo --version
36+
rustc --version
37+
38+
# Install protoc
39+
echo "Installing protoc ${PROTOC_VERSION}..."
40+
ARCH=$(uname -m)
41+
if [ "$ARCH" = "x86_64" ]; then
42+
PROTOC_ARCH=linux-x86_64
43+
else
44+
PROTOC_ARCH=linux-aarch_64
45+
fi
46+
curl -fsSL -o /tmp/protoc.zip "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-${PROTOC_ARCH}.zip"
47+
sudo unzip -o /tmp/protoc.zip -d /usr/local bin/protoc 'include/*'
48+
sudo chmod +x /usr/local/bin/protoc
49+
rm /tmp/protoc.zip
50+
protoc --version
51+
52+
# Install flatc
53+
echo "Installing flatc ${FLATC_VERSION}..."
54+
if [ "$ARCH" = "x86_64" ]; then
55+
curl -fsSL -o /tmp/flatc.zip "https://github.com/google/flatbuffers/releases/download/v${FLATC_VERSION}/Linux.flatc.binary.clang++-18.zip"
56+
sudo unzip -o /tmp/flatc.zip -d /usr/local/bin
57+
sudo chmod +x /usr/local/bin/flatc
58+
rm /tmp/flatc.zip
59+
else
60+
# Build from source for ARM64
61+
git clone --depth 1 --branch "v${FLATC_VERSION}" https://github.com/google/flatbuffers.git /tmp/flatbuffers
62+
cd /tmp/flatbuffers
63+
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release .
64+
ninja
65+
sudo cp flatc /usr/local/bin/
66+
cd -
67+
rm -rf /tmp/flatbuffers
68+
fi
69+
flatc --version
70+
71+
# Install cargo tools
72+
echo "Installing cargo tools..."
73+
source "$HOME/.cargo/env"
74+
cargo install cargo-nextest --locked
75+
cargo install cargo-hack --locked
76+
cargo install grcov --locked
77+
78+
# Cleanup
79+
echo "Cleaning up..."
80+
sudo apt-get clean
81+
sudo rm -rf /var/lib/apt/lists/*
82+
rm -rf /tmp/*
83+
84+
echo "=== Vortex CI dependencies installed successfully ==="
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
# Start SSH for Packer to connect
3+
systemctl start ssh

.github/packer/vortex-ci.pkr.hcl

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
packer {
2+
required_plugins {
3+
amazon = {
4+
version = ">= 1.3.0"
5+
source = "github.com/hashicorp/amazon"
6+
}
7+
}
8+
}
9+
10+
variable "aws_region" {
11+
type = string
12+
default = "eu-west-1"
13+
}
14+
15+
variable "arch" {
16+
type = string
17+
description = "Architecture: x64 or arm64"
18+
}
19+
20+
variable "ami_prefix" {
21+
type = string
22+
default = "vortex-ci"
23+
}
24+
25+
variable "source_ami_owner" {
26+
type = string
27+
default = "135269210855"
28+
description = "runs-on AWS account ID"
29+
}
30+
31+
variable "subnet_id" {
32+
type = string
33+
default = ""
34+
}
35+
36+
variable "rust_toolchain" {
37+
type = string
38+
default = "1.89"
39+
}
40+
41+
variable "protoc_version" {
42+
type = string
43+
default = "29.3"
44+
}
45+
46+
variable "flatc_version" {
47+
type = string
48+
default = "25.9.23"
49+
}
50+
51+
locals {
52+
timestamp = formatdate("YYYYMMDD-HHmmss", timestamp())
53+
54+
arch_config = {
55+
x64 = {
56+
instance_type = "m7i.large"
57+
source_ami_name = "runs-on-v2.2-ubuntu24-full-x64-*"
58+
ami_arch = "x86_64"
59+
}
60+
arm64 = {
61+
instance_type = "m7g.large"
62+
source_ami_name = "runs-on-v2.2-ubuntu24-full-arm64-*"
63+
ami_arch = "arm64"
64+
}
65+
}
66+
67+
config = local.arch_config[var.arch]
68+
}
69+
70+
source "amazon-ebs" "vortex-ci" {
71+
ami_name = "${var.ami_prefix}-${var.arch}-${local.timestamp}"
72+
instance_type = local.config.instance_type
73+
region = var.aws_region
74+
75+
source_ami_filter {
76+
filters = {
77+
name = local.config.source_ami_name
78+
root-device-type = "ebs"
79+
virtualization-type = "hvm"
80+
architecture = local.config.ami_arch
81+
}
82+
most_recent = true
83+
owners = [var.source_ami_owner]
84+
}
85+
86+
subnet_id = var.subnet_id != "" ? var.subnet_id : null
87+
ssh_username = "runner"
88+
89+
# User data to start SSH for Packer connectivity
90+
user_data_file = "${path.root}/scripts/user_data.sh"
91+
92+
launch_block_device_mappings {
93+
device_name = "/dev/sda1"
94+
volume_size = 80
95+
volume_type = "gp3"
96+
delete_on_termination = true
97+
}
98+
99+
tags = {
100+
Name = "${var.ami_prefix}-${var.arch}"
101+
Environment = "ci"
102+
Arch = var.arch
103+
BuildTime = local.timestamp
104+
ManagedBy = "packer"
105+
}
106+
}
107+
108+
build {
109+
sources = ["source.amazon-ebs.vortex-ci"]
110+
111+
# Run the provisioning script
112+
provisioner "shell" {
113+
script = "${path.root}/scripts/provision.sh"
114+
environment_vars = [
115+
"RUST_TOOLCHAIN=${var.rust_toolchain}",
116+
"PROTOC_VERSION=${var.protoc_version}",
117+
"FLATC_VERSION=${var.flatc_version}"
118+
]
119+
}
120+
}

0 commit comments

Comments
 (0)