Use GA runners with conan/ccache caches (#482)

This commit is contained in:
Niq Dudfield
2025-03-28 16:29:55 +07:00
committed by GitHub
parent 48919f028c
commit 689740d818
9 changed files with 660 additions and 172 deletions

View File

@@ -1,94 +0,0 @@
name: MacOS CI
on: [push, pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
strategy:
matrix:
generator:
- Ninja
configuration:
- Debug
runs-on: [self-hosted, macOS, ARM64]
env:
build_dir: .build
NUM_PROCESSORS: 12
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Conan
run: |
brew install conan@1
echo "$(brew --prefix conan@1)/bin" >> $GITHUB_PATH
- name: Install Coreutils
run: |
brew install coreutils
echo "Num proc: $(nproc)"
- name: Install Ninja
if: matrix.generator == 'Ninja'
run: brew install ninja
- name: Install Python
run: |
if which python3 > /dev/null 2>&1; then
echo "Python 3 executable exists"
python3 --version
else
brew install python@3.12
fi
# Create python symlink if needed
if ! which python > /dev/null 2>&1; then
sudo ln -sf $(which python3) /usr/local/bin/python
fi
- name: Install CMake
run: |
if which cmake > /dev/null 2>&1; then
echo "cmake executable exists"
cmake --version
else
brew install cmake
fi
- name: Check environment
run: |
echo "PATH:"
echo ${PATH} | tr ':' '\n'
which python
python --version
which conan
conan --version
which cmake
cmake --version
clang --version
env
- name: Configure Conan
run: |
conan profile new default --detect || true
conan profile update settings.compiler.cppstd=20 default
conan profile update settings.build_type=${{ matrix.configuration }} default
- name: Install dependencies
uses: ./.github/actions/dependencies
with:
configuration: ${{ matrix.configuration }}
cache-key: ${{ runner.os }}-${{ matrix.platform }}-${{ matrix.generator }}
- name: Build
uses: ./.github/actions/build
with:
generator: ${{ matrix.generator }}
configuration: ${{ matrix.configuration }}
cache-key: ${{ runner.os }}-${{ matrix.platform }}-${{ matrix.generator }}
- name: Test
run: |
${build_dir}/rippled --unittest --unittest-jobs $(nproc)

135
.github/workflows/xahau-ga-macos.yml vendored Normal file
View File

@@ -0,0 +1,135 @@
name: MacOS - GA Runner
on:
# Use GA runners on pushes except for the branches which build by the sh runner
push:
branches-ignore: ["dev", "candidate", "release"]
# Concurrency control: Cancels older in-progress runs for the same branch (github.ref)
# when a new push occurs. This saves runner minutes on superseded commits.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
strategy:
# Matrix allows defining variations (e.g., different compilers, configs).
# Keys below are structured to support future matrix expansion.
matrix:
generator:
- Ninja
configuration:
- Debug
# Use the specified macOS runner version
runs-on: macos-15
env:
# Build directory relative to the workspace root
build_dir: .build
# Manual cache version control. Bump this number to invalidate all caches globally.
CACHE_VERSION: 1
# Default branch name used for prioritizing ccache restores. Adjust if needed.
MAIN_BRANCH_NAME: jshooks
steps:
# 1. Checkout Code
- name: Checkout
uses: actions/checkout@v4
# 2. Install Build Dependencies via Homebrew
- name: Install Conan
run: |
brew install conan@1
# Add Conan 1 to the PATH for this job
echo "$(brew --prefix conan@1)/bin" >> $GITHUB_PATH
# 3. Install Coreutils (for 'nproc')
- name: Install Coreutils
run: |
brew install coreutils
echo "Num proc: $(nproc)"
# 4. Install Ninja (if needed by generator)
- name: Install Ninja
if: matrix.generator == 'Ninja'
run: brew install ninja
# 5. Install Python (if needed)
- name: Install Python
run: |
if which python3 > /dev/null 2>&1; then
echo "Python 3 executable exists"
python3 --version
else
brew install python@3.12
fi
# Create 'python' symlink if it doesn't exist (for tools expecting 'python')
if ! which python > /dev/null 2>&1; then
sudo ln -sf $(which python3) /usr/local/bin/python
fi
# 6. Install CMake (if needed)
- name: Install CMake
run: |
if which cmake > /dev/null 2>&1; then
echo "cmake executable exists"
cmake --version
else
brew install cmake
fi
# 7. Install ccache
- name: Install ccache
run: brew install ccache
# 8. Configure ccache (add this action)
- name: Configure ccache
uses: ./.github/actions/xahau-configure-ccache
with:
max_size: 2G
hash_dir: true
compiler_check: content
# 9. Environment Verification (Optional but Recommended)
- name: Check environment
run: |
echo "PATH:"
echo "${PATH}" | tr ':' '\n'
which python && python --version || echo "Python not found"
which conan && conan --version || echo "Conan not found"
which cmake && cmake --version || echo "CMake not found"
clang --version
ccache --version
echo "---- Full Environment ----"
env
# 10. Configure Conan Profile
- name: Configure Conan
run: |
conan profile new default --detect || true # Ignore error if profile exists
conan profile update settings.compiler.cppstd=20 default
# 11. Install dependencies using the action
- name: Install dependencies
uses: ./.github/actions/xahau-ga-dependencies
with:
configuration: ${{ matrix.configuration }}
build_dir: ${{ env.build_dir }}
compiler-id: clang
cache_version: ${{ env.CACHE_VERSION }}
main_branch: ${{ env.MAIN_BRANCH_NAME }}
# 12. Build Project using the action
- name: Build
uses: ./.github/actions/xahau-ga-build
with:
generator: ${{ matrix.generator }}
configuration: ${{ matrix.configuration }}
build_dir: ${{ env.build_dir }}
compiler-id: clang
cache_version: ${{ env.CACHE_VERSION }}
main_branch: ${{ env.MAIN_BRANCH_NAME }}
# 13. Run Tests
- name: Test
run: |
${{ env.build_dir }}/rippled --unittest --unittest-jobs $(nproc)

183
.github/workflows/xahau-ga-nix.yml vendored Normal file
View File

@@ -0,0 +1,183 @@
name: Nix - GA Runner
on:
# Use GA runners on pushes except for the branches which build by the sh runner
push:
branches-ignore: ["dev", "candidate", "release"]
# Concurrency control: Cancels older in-progress runs for the same branch (github.ref)
# when a new push occurs. This saves runner minutes on superseded commits.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# 1. Initial Check Job (Optional Sanity Check)
checkpatterns:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check for suspicious patterns
run: |
if [ -f "suspicious_patterns.sh" ]; then
bash suspicious_patterns.sh
else
echo "Warning: suspicious_patterns.sh not found, skipping check"
# Still exit with success for compatibility with dependent jobs
exit 0
fi
# 2. Main Build Job
build-job:
runs-on: ubuntu-latest
needs: checkpatterns # Depends on the initial check passing
outputs:
# Output artifact name for potential downstream use
artifact_name: ${{ steps.set-artifact-name.outputs.artifact_name }}
strategy:
fail-fast: false
# Matrix defines build variations. Keys are structured for this.
matrix:
compiler: [gcc] # Example: Add 'clang' here later
configuration: [Debug] # Example: Add 'Release' here later
include:
# Link compiler matrix variable to specific package names/paths
- compiler: gcc
cc: gcc-11
cxx: g++-11
compiler_id: gcc-11
# - compiler: clang
# cc: clang-14
# cxx: clang++-14
# compiler_id: clang-14
env:
# Build directory relative to the workspace root
build_dir: .build
# Manual cache version control. Bump this number to invalidate all caches globally.
CACHE_VERSION: 1
# Default branch name used for prioritizing ccache restores. Adjust if needed.
MAIN_BRANCH_NAME: jshooks
steps:
# 2.1. Checkout Code
- name: Checkout
uses: actions/checkout@v4
# 2.2. Install Build System Dependencies (apt)
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y ninja-build ${{ matrix.cc }} ${{ matrix.cxx }} ccache
# Install specific Conan version needed
pip install --upgrade "conan<2"
# 2.3. Configure ccache
- name: Configure ccache
uses: ./.github/actions/xahau-configure-ccache
with:
max_size: 2G
hash_dir: true
compiler_check: content
# 2.4. Configure Conan Profile
# Sets up the Conan profile specifically for the compiler specified in the matrix.
- name: Configure Conan
run: |
conan profile new default --detect || true # Ignore error if profile exists
conan profile update settings.compiler.cppstd=20 default
conan profile update settings.compiler=${{ matrix.compiler }} default
conan profile update settings.compiler.libcxx=libstdc++11 default
conan profile update env.CC=/usr/bin/${{ matrix.cc }} default
conan profile update env.CXX=/usr/bin/${{ matrix.cxx }} default
conan profile update conf.tools.build:compiler_executables='{"c": "/usr/bin/${{ matrix.cc }}", "cpp": "/usr/bin/${{ matrix.cxx }}"}' default
# Set correct compiler version based on matrix.compiler
if [ "${{ matrix.compiler }}" = "gcc" ]; then
conan profile update settings.compiler.version=11 default
elif [ "${{ matrix.compiler }}" = "clang" ]; then
conan profile update settings.compiler.version=14 default
fi
# Display profile for verification
conan profile show default
# 2.5. Environment Verification (Optional but Recommended)
- name: Check environment
run: |
echo "PATH:"
echo "${PATH}" | tr ':' '\n'
which conan && conan --version || echo "Conan not found"
which cmake && cmake --version || echo "CMake not found"
which ${{ matrix.cc }} && ${{ matrix.cc }} --version || echo "${{ matrix.cc }} not found"
which ${{ matrix.cxx }} && ${{ matrix.cxx }} --version || echo "${{ matrix.cxx }} not found"
which ccache && ccache --version || echo "ccache not found"
echo "---- Full Environment ----"
env
# 2.6. Install Dependencies using the action
- name: Install dependencies
uses: ./.github/actions/xahau-ga-dependencies
with:
configuration: ${{ matrix.configuration }}
build_dir: ${{ env.build_dir }}
compiler-id: ${{ matrix.compiler_id }}
cache_version: ${{ env.CACHE_VERSION }}
main_branch: ${{ env.MAIN_BRANCH_NAME }}
# 2.7. Build Project using the action
- name: Build
uses: ./.github/actions/xahau-ga-build
with:
generator: Ninja
configuration: ${{ matrix.configuration }}
build_dir: ${{ env.build_dir }}
cc: ${{ matrix.cc }}
cxx: ${{ matrix.cxx }}
compiler-id: ${{ matrix.compiler_id }}
cache_version: ${{ env.CACHE_VERSION }}
main_branch: ${{ env.MAIN_BRANCH_NAME }}
# 2.8. Set Artifact Name (Based on Matrix)
- name: Set artifact name
id: set-artifact-name
run: |
ARTIFACT_NAME="build-output-nix-${{ github.run_id }}-${{ matrix.compiler }}-${{ matrix.configuration }}"
echo "artifact_name=${ARTIFACT_NAME}" >> "$GITHUB_OUTPUT"
echo "Using artifact name: ${ARTIFACT_NAME}"
# 2.9. Debug Build Directory Contents (Optional)
- name: Debug build directory
run: |
echo "Checking build directory contents: ${{ env.build_dir }}"
ls -la ${{ env.build_dir }} || echo "Build directory not found or empty"
# 2.10. Run Tests
- name: Run tests
run: |
# Ensure the binary exists before trying to run
if [ -f "${{ env.build_dir }}/rippled" ]; then
${{ env.build_dir }}/rippled --unittest --unittest-jobs $(nproc)
else
echo "Error: rippled executable not found in ${{ env.build_dir }}"
exit 1
fi
# These are just here to conform with configured requirements
# 3. Dummy Downstream Job (Build)
build:
runs-on: ubuntu-latest
needs: build-job # Depends on the matrix build finishing
steps:
- name: Dummy Build
run: |
echo "Dummy build step - relies upon build-job matrix completion."
# 4. Dummy Downstream Job (Tests)
tests:
runs-on: ubuntu-latest
needs: build-job # Depends on the matrix build finishing
steps:
- name: Dummy Tests
run: |
echo "Dummy tests step - relies upon build-job matrix completion."

View File

@@ -0,0 +1,106 @@
name: Build using Docker - SH Runner
on:
push:
branches: ["dev", "candidate", "release"]
pull_request:
# Don't build on feature branches that are targeting dev
branches: ["candidate", "release"]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DEBUG_BUILD_CONTAINERS_AFTER_CLEANUP: 1
jobs:
checkout:
runs-on: [self-hosted, vanity]
outputs:
checkout_path: ${{ steps.vars.outputs.checkout_path }}
steps:
- name: Prepare checkout path
id: vars
run: |
SAFE_BRANCH=$(echo "${{ github.ref_name }}" | sed -e 's/[^a-zA-Z0-9._-]/-/g')
CHECKOUT_PATH="${SAFE_BRANCH}-${{ github.sha }}"
echo "checkout_path=${CHECKOUT_PATH}" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v4
with:
path: ${{ steps.vars.outputs.checkout_path }}
clean: true
fetch-depth: 2 # Only get the last 2 commits, to avoid fetching all history
checkpatterns:
runs-on: [self-hosted, vanity]
needs: checkout
defaults:
run:
working-directory: ${{ needs.checkout.outputs.checkout_path }}
steps:
- name: Check for suspicious patterns
run: /bin/bash suspicious_patterns.sh
build:
runs-on: [self-hosted, vanity]
needs: [checkpatterns, checkout]
defaults:
run:
working-directory: ${{ needs.checkout.outputs.checkout_path }}
steps:
- name: Set Cleanup Script Path
run: |
echo "JOB_CLEANUP_SCRIPT=$(mktemp)" >> $GITHUB_ENV
- name: Build using Docker
run: /bin/bash release-builder.sh
- name: Stop Container (Cleanup)
if: always()
run: |
echo "Running cleanup script: $JOB_CLEANUP_SCRIPT"
/bin/bash -e -x "$JOB_CLEANUP_SCRIPT"
CLEANUP_EXIT_CODE=$?
if [[ "$CLEANUP_EXIT_CODE" -eq 0 ]]; then
echo "Cleanup script succeeded."
rm -f "$JOB_CLEANUP_SCRIPT"
echo "Cleanup script removed."
else
echo "⚠️ Cleanup script failed! Keeping for debugging: $JOB_CLEANUP_SCRIPT"
fi
if [[ "${DEBUG_BUILD_CONTAINERS_AFTER_CLEANUP}" == "1" ]]; then
echo "🔍 Checking for leftover containers..."
BUILD_CONTAINERS=$(docker ps --format '{{.Names}}' | grep '^xahaud_cached_builder' || echo "")
if [[ -n "$BUILD_CONTAINERS" ]]; then
echo "⚠️ WARNING: Some build containers are still running"
echo "$BUILD_CONTAINERS"
else
echo "✅ No build containers found"
fi
fi
tests:
runs-on: [self-hosted, vanity]
needs: [build, checkout]
defaults:
run:
working-directory: ${{ needs.checkout.outputs.checkout_path }}
steps:
- name: Unit tests
run: /bin/bash docker-unit-tests.sh
cleanup:
runs-on: [self-hosted, vanity]
needs: [tests, checkout]
if: always()
steps:
- name: Cleanup workspace
run: |
CHECKOUT_PATH="${{ needs.checkout.outputs.checkout_path }}"
echo "Cleaning workspace for ${CHECKOUT_PATH}"
rm -rf "${{ github.workspace }}/${CHECKOUT_PATH}"