Skip to content

Build Test Matrix

Build Test Matrix #42

Workflow file for this run

---
name: Build Test Matrix
'on':
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]*"
branches:
- "build-ci-*"
schedule:
- cron: "05 00 * * *"
workflow_dispatch:
env:
toolchain: nightly-2024-07-07
matrix-json-file: ".github/workflows/build_tests.json"
CARGO_HTTP_MULTIPLEXING: false
CARGO_UNSTABLE_SPARSE_REGISTRY: true
CARGO: cargo
#CARGO_OPTIONS: "--locked"
CARGO_OPTIONS: "-vv"
CARGO_CACHE: true
concurrency:
# https://docs.github.com/en/actions/examples/using-concurrency-expressions-and-a-test-matrix
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/v') || github.ref != 'refs/heads/development' }}
permissions: {}
jobs:
matrix-prep:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
with:
submodules: false
- name: Set Matrix
id: set-matrix
run: |
#
# build all targets images
# matrix=$( jq -s -c .[] .github/workflows/build_binaries.json )
#
# build only single target image
# matrix_selection=$( jq -c '.[] | select( ."name" == "windows-x64" )' ${{ env.matrix-json-file }} )
# matrix_selection=$( jq -c '.[] | select( ."name" | contains("macos") )' ${{ env.matrix-json-file }} )
#
# build select target images - build_enabled
matrix_selection=$( jq -c '.[] | select( ."build_enabled" != false )' ${{ env.matrix-json-file }} )
#
# Setup the json build matrix
matrix=$(echo ${matrix_selection} | jq -s -c '{"builds": .}')
echo $matrix
echo $matrix | jq .
echo "matrix=${matrix}" >> $GITHUB_OUTPUT
matrix-check:
# Debug matrix
if: ${{ false }}
runs-on: ubuntu-latest
needs: matrix-prep
steps:
- name: Install json2yaml
run: |
sudo npm install -g json2yaml
- name: Check matrix definition
run: |
matrix='${{ needs.matrix-prep.outputs.matrix }}'
echo $matrix
echo $matrix | jq .
echo $matrix | json2yaml
builds:
name: Building ${{ matrix.builds.name }} on ${{ matrix.builds.runs-on }}
needs: matrix-prep
continue-on-error: ${{ matrix.builds.best_effort || false }}
strategy:
fail-fast: false
max-parallel: 5
matrix: ${{ fromJson(needs.matrix-prep.outputs.matrix) }}
runs-on: ${{ matrix.builds.runs-on }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
components: rustfmt, clippy
toolchain: ${{ matrix.builds.rust }}
targets: ${{ matrix.builds.target }}
- name: Install Linux dependencies - Ubuntu
if: ${{ startsWith(runner.os,'Linux') && ( ! matrix.builds.cross ) }}
run: |
sudo apt-get update
sudo bash scripts/install_ubuntu_dependencies.sh
rustup target add ${{ matrix.builds.target }}
- name: Install macOS dependencies
if: startsWith(runner.os,'macOS')
run: |
# openssl, cmake and autoconf already installed
# brew install zip coreutils automake protobuf
brew install zip coreutils automake
rustup target add ${{ matrix.builds.target }}
- name: Install macOS-14 missing dependencies - hack
if: ${{ startsWith(runner.os,'macOS') && startsWith(runner.arch,'ARM64') }}
run: |
brew install libtool
- name: Install Windows dependencies
if: startsWith(runner.os,'Windows')
run: |
# choco upgrade protoc -y
rustup target add ${{ matrix.builds.target }}
- name: Declare Android/iOS envs
shell: bash
run: |
if [[ "${{ matrix.builds.target }}" =~ "android" ]]; then
echo "CFLAGS=-DMDB_USE_ROBUST=0" >> $GITHUB_ENV
echo "TARGET_PLATFORM=android" >> $GITHUB_ENV
elif [[ "${{ matrix.builds.target }}" =~ "ios" ]]; then
echo "TARGET_PLATFORM=ios" >> $GITHUB_ENV
if [[ "${{ matrix.builds.target }}" =~ "-sim" ]]; then
echo "TARGET_SIM=-sim" >> $GITHUB_ENV
fi
elif [[ "${{ matrix.builds.target }}" =~ "linux-gnu" ]]; then
echo "TARGET_PLATFORM=linux" >> $GITHUB_ENV
elif [[ "${{ matrix.builds.target }}" =~ "apple-darwin" ]]; then
echo "TARGET_PLATFORM=macos" >> $GITHUB_ENV
fi
# Strip begining
tempEnv="${{ matrix.builds.target }}"
echo "TARGET_ARCH=${tempEnv/-*/}" >> $GITHUB_ENV
# Strip outside of *_X_*
tempEnv="${{ matrix.libffis }}"
tempEnv=${tempEnv#*_}
echo "TARGET_NAME=${tempEnv%_*}" >> $GITHUB_ENV
- name: Cache cargo files and outputs
if: ${{ ( ! startsWith(github.ref, 'refs/tags/v') ) && ( ! matrix.builds.cross ) && ( env.CARGO_CACHE ) }}
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.builds.target }}
- name: Install and setup cargo cross
if: ${{ matrix.builds.cross }}
shell: bash
run: |
#cargo install cross
cargo install cross --git https://github.com/cross-rs/cross
echo "CARGO=cross" >> $GITHUB_ENV
- name: Setup build release targets
# if: ${{ startsWith(github.ref, 'refs/tags/v') }}
shell: bash
run: |
# echo "TS_BUILD=release" >> $GITHUB_ENV
if [[ "${{ env.TS_BUILD }}" == "release" ]]; then
echo "CARGO_OPTIONS=${{ env.CARGO_OPTIONS }} --${{ env.TS_BUILD }}" >> $GITHUB_ENV
fi
- name: Show command used for Cargo
shell: bash
run: |
echo "cargo command is: ${{ env.CARGO }}"
echo "cargo options is: ${{ env.CARGO_OPTIONS }}"
echo "cross flag: ${{ matrix.builds.cross }}"
- name: Build test for ${{ matrix.builds.target }}
shell: bash
run: |
${{ env.CARGO }} build ${{ env.CARGO_OPTIONS }} \
--target ${{ matrix.builds.target }} \
${{ matrix.builds.flags }}