Skip to content
Merged
Show file tree
Hide file tree
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
17 changes: 17 additions & 0 deletions .github/workflows/build-deb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ jobs:
--load \
.

- name: Restore ccache
uses: actions/cache/restore@v4
with:
path: .ccache
key: ccache-deb-${{ matrix.name }}-${{ matrix.arch }}_${{ github.sha }}
restore-keys: |
ccache-deb-${{ matrix.name }}-${{ matrix.arch }}_

- name: Build monero-python
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
with:
Expand All @@ -129,9 +137,18 @@ jobs:
--platform $PLATFORM \
-v $PWD:/monero-python -w /monero-python \
-e PACKAGE_NAME="${PACKAGE_NAME}" \
-e CCACHE_DIR=/monero-python/.ccache \
-e CCACHE_MAXSIZE=500M \
monero-python:${{ matrix.name }}-${{ matrix.arch }} \
bash -euxc "./docker/build.sh"

- name: Save ccache
if: ${{ !cancelled() }}
uses: actions/cache/save@v4
with:
path: .ccache
key: ccache-deb-${{ matrix.name }}-${{ matrix.arch }}_${{ github.sha }}

- name: Upload deb package
uses: actions/upload-artifact@v4
with:
Expand Down
30 changes: 28 additions & 2 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ jobs:
build:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_MAXSIZE: 500M
CCACHE_COMPILERCHECK: "%compiler% -v"

strategy:
fail-fast: false
Expand All @@ -27,7 +31,7 @@ jobs:

- name: Install dependencies
run: |
HOMEBREW_NO_AUTO_UPDATE=1 brew install python boost@1.85 hidapi openssl zmq libpgm miniupnpc expat libunwind-headers protobuf unbound
HOMEBREW_NO_AUTO_UPDATE=1 brew install python boost@1.85 hidapi openssl zmq libpgm miniupnpc expat libunwind-headers protobuf unbound ccache
brew unlink boost || true
brew link boost@1.85 --force
pip3 install pytest pytest-cov setuptools wheel scikit-build-core --break-system-packages
Expand All @@ -40,6 +44,17 @@ jobs:
run: |
pip3 install delocate --break-system-packages

- name: Restore ccache
uses: actions/cache/restore@v4
with:
path: .ccache
key: ccache-${{ matrix.os }}_${{ github.sha }}
restore-keys: |
ccache-${{ matrix.os }}_

- name: Reset ccache statistics
run: ccache --zero-stats

- name: Build monero
run: |
cd external/monero-cpp/external/monero-project
Expand All @@ -54,7 +69,7 @@ jobs:
cd external/monero-cpp
mkdir -p build
cd build
cmake ..
cmake .. -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake --build .
make -j3
cd ../../../
Expand All @@ -64,6 +79,17 @@ jobs:
mkdir -p build
python3 -m pip wheel . -w dist --no-build-isolation

- name: Show ccache statistics
if: ${{ !cancelled() }}
run: ccache --show-stats

- name: Save ccache
if: ${{ !cancelled() }}
uses: actions/cache/save@v4
with:
path: .ccache
key: ccache-${{ matrix.os }}_${{ github.sha }}

- name: Repair wheel with delocate
run: |
delocate-wheel -w wheelhouse -v dist/*.whl
Expand Down
28 changes: 27 additions & 1 deletion .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ jobs:
msys2-mingw64:
name: MSYS2 MinGW64
runs-on: windows-latest
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_MAXSIZE: 500M

defaults:
run:
Expand Down Expand Up @@ -50,6 +53,7 @@ jobs:
mingw-w64-x86_64-protobuf
mingw-w64-x86_64-libusb
mingw-w64-x86_64-ntldd
mingw-w64-x86_64-ccache
git
make
gettext
Expand Down Expand Up @@ -114,6 +118,17 @@ jobs:
echo "5b56ad87bc544336b2d51edb8bb0614f46542571362daf4d7e53bf23120175a1 mingw-w64-x86_64-pybind11-2.13.6-2-any.pkg.tar.zst" | sha256sum -c
pacman -U --noconfirm mingw-w64-x86_64-pybind11-2.13.6-2-any.pkg.tar.zst

- name: Restore ccache
uses: actions/cache/restore@v4
with:
path: .ccache
key: ccache-windows_${{ github.sha }}
restore-keys: |
ccache-windows_

- name: Reset ccache statistics
run: ccache --zero-stats

- name: Build monero
run: |
cd external/monero-cpp/external/monero-project
Expand All @@ -135,7 +150,7 @@ jobs:
cd external/monero-cpp
mkdir -p build
cd build
cmake ..
cmake .. -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake --build .

- name: Build wheel
Expand All @@ -146,6 +161,17 @@ jobs:
-C cmake.define.Python3_FIND_STRATEGY=LOCATION \
-C cmake.define.Python3_FIND_REGISTRY=NEVER

- name: Show ccache statistics
if: ${{ !cancelled() }}
run: ccache --show-stats

- name: Save ccache
if: ${{ !cancelled() }}
uses: actions/cache/save@v4
with:
path: .ccache
key: ccache-windows_${{ github.sha }}

- name: Repair wheel with delvewheel
run: |
export WIN_PYTHON_EXE=$(cygpath -u "$pythonLocation/python.exe")
Expand Down
88 changes: 84 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ jobs:
linux:
runs-on: ubuntu-24.04
name: linux (pytest)
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_MAXSIZE: 500M

steps:
- name: Checkout repository
Expand Down Expand Up @@ -52,6 +55,17 @@ jobs:
sudo make install
cd ../

- name: Restore ccache
uses: actions/cache/restore@v4
with:
path: .ccache
key: ccache-linux-test_${{ github.sha }}
restore-keys: |
ccache-linux-test_

- name: Reset ccache statistics
run: ccache --zero-stats

- name: Build monero
run: |
cd external/monero-cpp/external/monero-project
Expand All @@ -66,7 +80,7 @@ jobs:
cd external/monero-cpp
mkdir -p build
cd build
cmake .. -DENABLE_COVERAGE=ON
cmake .. -DENABLE_COVERAGE=ON -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake --build .
make -j3
cd ../../../
Expand All @@ -78,6 +92,18 @@ jobs:
cmake --build build
cp build/monero.cpython-312-x86_64-linux-gnu.so ~/.local/lib/python3.12/site-packages/

- name: Show ccache statistics
if: ${{ !cancelled() }}
run: ccache --show-stats

- name: Save ccache
# Pull requests only read the cache, pushes to main and manual runs populate it.
if: ${{ !cancelled() && github.event_name != 'pull_request' }}
uses: actions/cache/save@v4
with:
path: .ccache
key: ccache-linux-test_${{ github.sha }}

- name: Setup test environment
run: |
docker compose -f tests/docker-compose.yml up -d node_1 node_2 xmr_wallet_1 xmr_wallet_2 xmr_wallet_3
Expand Down Expand Up @@ -158,6 +184,9 @@ jobs:
windows:
name: windows (pytest)
runs-on: windows-latest
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_MAXSIZE: 500M

defaults:
run:
Expand Down Expand Up @@ -195,6 +224,7 @@ jobs:
mingw-w64-x86_64-protobuf
mingw-w64-x86_64-libusb
mingw-w64-x86_64-ntldd
mingw-w64-x86_64-ccache
git
make
gettext
Expand Down Expand Up @@ -259,6 +289,17 @@ jobs:
echo "5b56ad87bc544336b2d51edb8bb0614f46542571362daf4d7e53bf23120175a1 mingw-w64-x86_64-pybind11-2.13.6-2-any.pkg.tar.zst" | sha256sum -c
pacman -U --noconfirm mingw-w64-x86_64-pybind11-2.13.6-2-any.pkg.tar.zst

- name: Restore ccache
uses: actions/cache/restore@v4
with:
path: .ccache
key: ccache-windows_${{ github.sha }}
restore-keys: |
ccache-windows_

- name: Reset ccache statistics
run: ccache --zero-stats

- name: Build monero
run: |
cd external/monero-cpp/external/monero-project
Expand All @@ -280,7 +321,7 @@ jobs:
cd external/monero-cpp
mkdir -p build
cd build
cmake ..
cmake .. -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake --build .

- name: Build monero-python
Expand All @@ -300,6 +341,18 @@ jobs:
done
cd ..

- name: Show ccache statistics
if: ${{ !cancelled() }}
run: ccache --show-stats

- name: Save ccache
# Pull requests only read the cache, pushes to main and manual runs populate it.
if: ${{ !cancelled() && github.event_name != 'pull_request' }}
uses: actions/cache/save@v4
with:
path: .ccache
key: ccache-windows_${{ github.sha }}

- name: Run unit tests
shell: bash
env:
Expand All @@ -312,6 +365,10 @@ jobs:
macos:
name: ${{ matrix.os }} (pytest)
runs-on: ${{ matrix.os }}
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_MAXSIZE: 500M
CCACHE_COMPILERCHECK: "%compiler% -v"

strategy:
fail-fast: false
Expand All @@ -326,7 +383,7 @@ jobs:

- name: Install dependencies
run: |
HOMEBREW_NO_AUTO_UPDATE=1 brew install python boost@1.85 hidapi openssl zmq libpgm miniupnpc expat libunwind-headers protobuf unbound
HOMEBREW_NO_AUTO_UPDATE=1 brew install python boost@1.85 hidapi openssl zmq libpgm miniupnpc expat libunwind-headers protobuf unbound ccache
brew unlink boost || true
brew link boost@1.85 --force
pip3 install pytest pytest-rerunfailures pytest-timeout pytest-cov setuptools wheel scikit-build-core --break-system-packages
Expand All @@ -335,6 +392,17 @@ jobs:
run: |
pip3 install pybind11==2.13.6 pybind11-stubgen --break-system-packages

- name: Restore ccache
uses: actions/cache/restore@v4
with:
path: .ccache
key: ccache-${{ matrix.os }}_${{ github.sha }}
restore-keys: |
ccache-${{ matrix.os }}_

- name: Reset ccache statistics
run: ccache --zero-stats

- name: Build monero
run: |
cd external/monero-cpp/external/monero-project
Expand All @@ -349,7 +417,7 @@ jobs:
cd external/monero-cpp
mkdir -p build
cd build
cmake ..
cmake .. -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake --build .
make -j3
cd ../../../
Expand All @@ -359,6 +427,18 @@ jobs:
mkdir -p build
pip3 install --no-build-isolation -vvv . --break-system-packages

- name: Show ccache statistics
if: ${{ !cancelled() }}
run: ccache --show-stats

- name: Save ccache
# Pull requests only read the cache, pushes to main and manual runs populate it.
if: ${{ !cancelled() && github.event_name != 'pull_request' }}
uses: actions/cache/save@v4
with:
path: .ccache
key: ccache-${{ matrix.os }}_${{ github.sha }}

- name: Run unit tests
run: |
pytest -m unit
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ coverage*
.coverage
.cache
monero.log
monero_tests_*.log
monero_tests_*.log
.ccache
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ if (WIN32)
add_definitions( "-DWIN32_LEAN_AND_MEAN" )
endif()

option(USE_CCACHE "Use ccache if found" ON)

# Respect a launcher given explicitly (-DCMAKE_CXX_COMPILER_LAUNCHER or env).
if(USE_CCACHE AND NOT CMAKE_CXX_COMPILER_LAUNCHER)
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
message(STATUS "Using ccache: ${CCACHE_PROGRAM}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
endif()
endif()

option(ENABLE_COVERAGE "Enable coverage" OFF)

if(ENABLE_COVERAGE)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ wallet_full.close(True)
```
6. Or run build script: `./bin/build_libmonero_python.sh`

> **Faster rebuilds:** if [ccache](https://ccache.dev/) is installed it is used automatically for monero and monero-python (pass `-DUSE_CCACHE=OFF` to cmake to disable it). To use it for monero-cpp as well, build that with `-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache`.

### Linux Docker Build

1. Install [Docker](https://docs.docker.com/engine/install/)
Expand Down
Loading
Loading