Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: GitHub-hosted

on:
push:
branches: [master, main]
pull_request:

env:
CMAKE_BUILD_PARALLEL_LEVEL: 4

jobs:
build-and-test:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
llvm: 20
python: "3.12"
runtime_cxx_standard: 17
- os: ubuntu-24.04
llvm: 21
python: "3.13"
runtime_cxx_standard: 20
- os: ubuntu-24.04
llvm: 21
python: "3.14"
runtime_cxx_standard: 20
- os: macos-15
llvm: 20
python: "3.12"
runtime_cxx_standard: 20

runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} / LLVM ${{ matrix.llvm }} / Py ${{ matrix.python }} / C++${{ matrix.runtime_cxx_standard }}

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: |
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/llvm-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-${{ matrix.llvm }} main" \
| sudo tee /etc/apt/sources.list.d/llvm.list
sudo apt-get update
sudo apt-get install -y \
llvm-${{ matrix.llvm }}-dev \
libclang-${{ matrix.llvm }}-dev \
clang-${{ matrix.llvm }} \
libpolly-${{ matrix.llvm }}-dev \
libboost-dev libeigen3-dev

- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: brew install llvm@${{ matrix.llvm }} boost eigen

- name: pip install CppJIT
run: |
pip install pytest numpy psutil
pip install numba || true
pip install . -v --config-settings=cmake.define.LLVM_DIR=${{
runner.os == 'macOS'
&& format('/opt/homebrew/opt/llvm@{0}/lib/cmake/llvm', matrix.llvm)
|| format('/usr/lib/llvm-{0}/lib/cmake/llvm', matrix.llvm)
}}

- name: Build test dictionaries
run: make -j4
working-directory: test

- name: Run tests
run: python -m pytest -ra --tb=short -q 2>&1 | tee ../test-output.txt
working-directory: test
env:
CPPINTEROP_EXTRA_INTERPRETER_ARGS: "-std=c++${{ matrix.runtime_cxx_standard }}"

- name: Upload result
if: always()
uses: actions/upload-artifact@v4
with:
name: result-${{ matrix.os }}-llvm${{ matrix.llvm }}-py${{ matrix.python }}-cpp${{ matrix.runtime_cxx_standard }}
path: test-output.txt

report:
if: always() && github.event_name == 'pull_request'
needs: build-and-test
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: result-*

- uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const marker = '<!-- cppjit-ci -->';

const rows = fs.readdirSync('.').filter(d => d.startsWith('result-')).sort().map(d => {
const cfg = d.replace('result-', '');
const file = `${d}/test-output.txt`;
const lines = fs.existsSync(file) ? fs.readFileSync(file, 'utf8').trim().split('\n') : [];
const result = lines.length ? lines.at(-1) : 'no output';
return `| ${cfg} | \`${result}\` |`;
});

const body = [marker, '## Test Results', '| Configuration | Result |', '|---|---|', ...rows].join('\n');
const { data: comments } = await github.rest.issues.listComments({
...context.repo, issue_number: context.issue.number,
});
const existing = comments.find(c => c.body.startsWith(marker));

if (existing) {
await github.rest.issues.updateComment({ ...context.repo, comment_id: existing.id, body });
} else {
await github.rest.issues.createComment({ ...context.repo, issue_number: context.issue.number, body });
}
Loading