Skip to content

Commit 2adcf45

Browse files
committed
simplify things in github actions
1 parent 085009d commit 2adcf45

19 files changed

+508
-614
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: 'Setup runner environment'
2+
description: 'Sets up runner environment with Ninja and proper toolchain for building Ada'
3+
runs:
4+
using: 'composite'
5+
steps:
6+
- name: Setup Linux
7+
if: runner.os == 'Linux'
8+
shell: bash
9+
run: |
10+
sudo apt-get update
11+
sudo apt-get install -y ninja-build
12+
13+
- name: Setup macOS
14+
if: runner.os == 'macOS'
15+
shell: bash
16+
run: |
17+
brew install ninja
18+
19+
- name: Setup Windows
20+
if: runner.os == 'Windows'
21+
shell: pwsh
22+
run: |
23+
choco install ninja

.github/workflows/_build.yaml

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
name: 'Build'
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
# Runner configuration
7+
runner:
8+
type: string
9+
required: true
10+
11+
# Build configuration
12+
cxx:
13+
type: string
14+
required: false
15+
default: ''
16+
cxxflags:
17+
type: string
18+
required: false
19+
default: ''
20+
shared:
21+
type: string
22+
required: false
23+
default: 'OFF'
24+
simdutf:
25+
type: string
26+
required: false
27+
default: 'OFF'
28+
build_type:
29+
type: string
30+
required: false
31+
default: ''
32+
33+
# CMake options
34+
cmake_args:
35+
type: string
36+
required: false
37+
default: ''
38+
testing:
39+
type: string
40+
required: false
41+
default: 'ON'
42+
benchmarks:
43+
type: string
44+
required: false
45+
default: 'OFF'
46+
47+
# Windows-specific
48+
arch:
49+
type: string
50+
required: false
51+
default: ''
52+
toolset:
53+
type: string
54+
required: false
55+
default: ''
56+
57+
# Post-build actions
58+
run_tests:
59+
type: boolean
60+
required: false
61+
default: true
62+
run_benchmarks:
63+
type: boolean
64+
required: false
65+
default: false
66+
run_install:
67+
type: boolean
68+
required: false
69+
default: false
70+
71+
# Cross-compilation
72+
toolchain_file:
73+
type: string
74+
required: false
75+
default: ''
76+
qemu_cpu:
77+
type: string
78+
required: false
79+
default: ''
80+
qemu_ld_prefix:
81+
type: string
82+
required: false
83+
default: ''
84+
setup_script:
85+
type: string
86+
required: false
87+
default: ''
88+
89+
# run-on-arch-action (for s390x, etc.)
90+
use_run_on_arch:
91+
type: boolean
92+
required: false
93+
default: false
94+
run_on_arch_arch:
95+
type: string
96+
required: false
97+
default: ''
98+
run_on_arch_distro:
99+
type: string
100+
required: false
101+
default: ''
102+
run_on_arch_install:
103+
type: string
104+
required: false
105+
default: ''
106+
run_on_arch_run:
107+
type: string
108+
required: false
109+
default: ''
110+
111+
permissions:
112+
contents: read
113+
114+
jobs:
115+
build:
116+
runs-on: ${{ inputs.runner }}
117+
steps:
118+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
119+
120+
- name: Setup Runner
121+
if: ${{ !inputs.use_run_on_arch }}
122+
uses: ./.github/actions/setup-runner
123+
124+
- name: Setup environment
125+
if: ${{ !inputs.use_run_on_arch && inputs.setup_script != '' }}
126+
shell: bash
127+
run: ${{ inputs.setup_script }}
128+
129+
- name: Configure
130+
if: ${{ !inputs.use_run_on_arch }}
131+
shell: bash
132+
run: |
133+
CMAKE_ARGS="-G Ninja -B build"
134+
CMAKE_ARGS="$CMAKE_ARGS -DADA_TESTING=${{ inputs.testing }}"
135+
CMAKE_ARGS="$CMAKE_ARGS -DADA_BENCHMARKS=${{ inputs.benchmarks }}"
136+
CMAKE_ARGS="$CMAKE_ARGS -DBUILD_SHARED_LIBS=${{ inputs.shared }}"
137+
CMAKE_ARGS="$CMAKE_ARGS -DADA_USE_SIMDUTF=${{ inputs.simdutf }}"
138+
if [ -n "${{ inputs.build_type }}" ]; then
139+
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=${{ inputs.build_type }}"
140+
fi
141+
if [ -n "${{ inputs.toolchain_file }}" ]; then
142+
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${{ inputs.toolchain_file }}"
143+
fi
144+
if [ -n "${{ inputs.cmake_args }}" ]; then
145+
CMAKE_ARGS="$CMAKE_ARGS ${{ inputs.cmake_args }}"
146+
fi
147+
if [ -n "${{ inputs.qemu_ld_prefix }}" ]; then
148+
export QEMU_LD_PREFIX="${{ inputs.qemu_ld_prefix }}"
149+
fi
150+
if [ -n "${{ inputs.qemu_cpu }}" ]; then
151+
export QEMU_CPU="${{ inputs.qemu_cpu }}"
152+
fi
153+
echo "Running: cmake $CMAKE_ARGS"
154+
cmake $CMAKE_ARGS
155+
env:
156+
CXX: ${{ inputs.cxx }}
157+
CXXFLAGS: ${{ inputs.cxxflags }}
158+
159+
- name: Build
160+
if: ${{ !inputs.use_run_on_arch }}
161+
run: cmake --build build -j=4
162+
163+
- name: Test
164+
if: ${{ !inputs.use_run_on_arch && inputs.run_tests }}
165+
shell: bash
166+
run: |
167+
if [ -n "${{ inputs.qemu_ld_prefix }}" ]; then
168+
export QEMU_LD_PREFIX="${{ inputs.qemu_ld_prefix }}"
169+
fi
170+
if [ -n "${{ inputs.qemu_cpu }}" ]; then
171+
export QEMU_CPU="${{ inputs.qemu_cpu }}"
172+
fi
173+
ctest --output-on-failure --test-dir build
174+
175+
- name: Run benchmarks
176+
if: ${{ !inputs.use_run_on_arch && inputs.run_benchmarks }}
177+
shell: bash
178+
run: cd build && benchmarks/bench
179+
180+
- name: Install
181+
if: ${{ !inputs.use_run_on_arch && inputs.run_install }}
182+
run: cmake --install build
183+
184+
- name: Build and run install test
185+
if: ${{ !inputs.use_run_on_arch && inputs.run_install }}
186+
shell: bash
187+
run: |
188+
cmake -DCMAKE_INSTALL_PREFIX:PATH=../../destination -S tests/installation -B build_install_test
189+
cmake --build build_install_test
190+
./build_install_test/main
191+
192+
# run-on-arch path (for s390x and similar architectures)
193+
- uses: uraimo/run-on-arch-action@d94c13912ea685de38fccc1109385b83fd79427d # v3.0.1
194+
if: ${{ inputs.use_run_on_arch }}
195+
name: Build and Test
196+
with:
197+
arch: ${{ inputs.run_on_arch_arch }}
198+
distro: ${{ inputs.run_on_arch_distro }}
199+
githubToken: ${{ github.token }}
200+
install: ${{ inputs.run_on_arch_install }}
201+
run: ${{ inputs.run_on_arch_run }}

.github/workflows/alpine.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/emscripten.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/macos.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: macOS
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, ready_for_review]
6+
paths-ignore:
7+
- '**.md'
8+
- 'docs/**'
9+
push:
10+
branches:
11+
- main
12+
paths-ignore:
13+
- '**.md'
14+
- 'docs/**'
15+
16+
permissions:
17+
contents: read
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: true
22+
23+
jobs:
24+
build:
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
runner: [macos-14, macos-15, macos-26]
29+
shared: [OFF]
30+
name: build (${{ matrix.runner }}, shared=${{ matrix.shared }})
31+
uses: ./.github/workflows/_build.yaml
32+
with:
33+
runner: ${{ matrix.runner }}
34+
shared: ${{ matrix.shared }}
35+
cmake_args: '-DCMAKE_INSTALL_PREFIX:PATH=destination'
36+
run_install: true

.github/workflows/macos_install.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)