Remove the Monero build (#64)

* Remove the Monero CMake and make

* Download the Monero daemon instead of building it

* Cache the Monero daemon

Prevents hammering the Monero servers, should reduce CI time.

* Correct YAML

* Add back sodium-dev

* Create an independent job for downloading the Monero daemon

Improves parallelism while decreasing the amount of work re-done if 
build fails. Also increases modularity.

* Correct Monero job definition

* Correct skipping the Monero download on cache hit
This commit is contained in:
Luke Parker 2022-07-23 03:35:32 -05:00 committed by GitHub
parent b80c1bec4c
commit 42d62c38b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 113 deletions

View file

@ -7,6 +7,31 @@ on:
pull_request: pull_request:
jobs: jobs:
monero-daemon:
runs-on: ubuntu-latest
steps:
- name: Monero cache
id: cache-monerod
uses: actions/cache@v3
with:
path: monerod
key: monerod-${{ runner.os }}-${{ runner.arch }}-v0.17.3.2
- name: Download the Monero Daemon
if: steps.cache-monerod.outputs.cache-hit != 'true'
# Calculates OS/ARCH to demonstrate it, yet then locks to linux-x64 due
# to the contained folder not following the same naming scheme and
# requiring further expansion not worth doing right now
run: |
RUNNER_OS=${{ runner.os }}
RUNNER_ARCH=${{ runner.arch }}
OS_ARCH=${RUNNER_OS,,}-${RUNNER_ARCH,,}
OS_ARCH=linux-x64
wget https://downloads.getmonero.org/cli/monero-$OS_ARCH-v0.17.3.2.tar.bz2
tar -xvf monero-$OS_ARCH-v0.17.3.2.tar.bz2
mv monero-x86_64-linux-gnu-v0.17.3.2/monerod monerod
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -23,9 +48,7 @@ jobs:
- name: Install Monero Dependencies - name: Install Monero Dependencies
run: | run: |
sudo apt update sudo apt update
sudo apt install build-essential cmake pkg-config libboost-all-dev \ sudo apt install build-essential libboost-all-dev libsodium-dev
libssl-dev libzmq3-dev libpgm-dev libunbound-dev \
libsodium-dev ccache
- name: Install Rust - name: Install Rust
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
@ -41,18 +64,6 @@ jobs:
profile: minimal profile: minimal
target: wasm32-unknown-unknown target: wasm32-unknown-unknown
# Cache everything, not only for performance, yet to export these to the
# following jobs
- name: Monero cache
uses: actions/cache@v3
with:
path: |
./coins/monero/c/.build
./coins/monero/c/monero/build
# Hash src, as theoretically, a different version of Monero warranting
# a rebuild would've changed *something* under src
key: ${{ runner.os }}-${{ hashFiles('./coins/monero/c/monero/src') }}
- name: Cargo/Rust cache - name: Cargo/Rust cache
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
@ -81,9 +92,7 @@ jobs:
- name: Install Monero Dependencies - name: Install Monero Dependencies
run: | run: |
sudo apt update sudo apt update
sudo apt install build-essential cmake pkg-config libboost-all-dev \ sudo apt install build-essential libboost-all-dev libsodium-dev
libssl-dev libzmq3-dev libpgm-dev libunbound-dev \
libsodium-dev ccache
- name: Install Rust - name: Install Rust
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
@ -101,15 +110,6 @@ jobs:
profile: minimal profile: minimal
target: wasm32-unknown-unknown target: wasm32-unknown-unknown
# Grab the Monero cache since it'll be unaffected by Rust versioning
- name: Monero cache
uses: actions/cache@v3
with:
path: |
./coins/monero/c/.build
./coins/monero/c/monero/build
key: ${{ runner.os }}-${{ hashFiles('./coins/monero/c/monero/src') }}
# Define a separate cache for nightly Rust # Define a separate cache for nightly Rust
- name: Cargo/Rust nightly cache - name: Cargo/Rust nightly cache
uses: actions/cache@v3 uses: actions/cache@v3
@ -124,7 +124,7 @@ jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build needs: [monero-daemon, build]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
@ -144,8 +144,16 @@ jobs:
- name: Install Monero Dependencies - name: Install Monero Dependencies
run: | run: |
sudo apt update sudo apt update
sudo apt install libboost-all-dev libssl-dev libzmq3-dev libpgm-dev \ sudo apt install build-essential libboost-all-dev libsodium-dev
libunbound-dev libsodium-dev
- name: Monero cache
uses: actions/cache@v3
with:
path: monerod
key: monerod-${{ runner.os }}-${{ runner.arch }}-v0.17.3.2
- name: Monero Regtest Daemon
run: ./monerod --regtest --offline --fixed-difficulty=1 --detach
- name: Install Rust - name: Install Rust
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
@ -161,14 +169,6 @@ jobs:
profile: minimal profile: minimal
target: wasm32-unknown-unknown target: wasm32-unknown-unknown
- name: Monero cache
uses: actions/cache@v3
with:
path: |
./coins/monero/c/.build
./coins/monero/c/monero/build
key: ${{ runner.os }}-${{ hashFiles('./coins/monero/c/monero/src') }}
- name: Cargo/Rust cache - name: Cargo/Rust cache
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
@ -177,9 +177,6 @@ jobs:
./target ./target
key: ${{ runner.os }}-cargo-rust key: ${{ runner.os }}-cargo-rust
- name: Monero Regtest Daemon
run: ./coins/monero/c/monero/build/release/bin/monerod --regtest --offline --fixed-difficulty=1 --detach
- name: Run tests - name: Run tests
run: cargo test --all-features run: cargo test --all-features

View file

@ -1,4 +1,4 @@
use std::{env, path::Path, process::Command}; use std::process::Command;
fn main() { fn main() {
if !Command::new("git") if !Command::new("git")
@ -10,71 +10,6 @@ fn main() {
panic!("git failed to init submodules"); panic!("git failed to init submodules");
} }
if !Command::new("mkdir")
.args(&["-p", ".build"])
.current_dir(&Path::new("c"))
.status()
.unwrap()
.success()
{
panic!("failed to create a directory to track build progress");
}
let out_dir = &env::var("OUT_DIR").unwrap();
// Use a file to signal if Monero was already built, as that should never be rebuilt
// If the signaling file was deleted, run this script again to rebuild Monero though
println!("cargo:rerun-if-changed=c/.build/monero");
if !Path::new("c/.build/monero").exists() {
if !Command::new("mkdir")
.args(&["-p", "build/release"])
.current_dir(&Path::new("c/monero"))
.status()
.unwrap()
.success()
{
panic!("failed to mkdir");
}
if !Command::new("cmake")
.args(&[
"-D",
&format!("ARCH={}", &env::var("ARCH").unwrap_or_else(|_| "native".to_string())),
"-D",
"BUILD_TESTS=OFF",
"-D",
"CMAKE_BUILD_TYPE=Release",
"../..",
])
.current_dir(&Path::new("c/monero/build/release"))
.status()
.unwrap()
.success()
{
panic!("failed to call cmake. Please check your dependencies");
}
if !Command::new("make")
.arg(format!("-j{}", &env::var("THREADS").unwrap_or_else(|_| "2".to_string())))
.current_dir(&Path::new("c/monero/build/release"))
.status()
.unwrap()
.success()
{
panic!("make failed to build Monero. Please check your dependencies");
}
if !Command::new("touch")
.arg("monero")
.current_dir(&Path::new("c/.build"))
.status()
.unwrap()
.success()
{
panic!("failed to create a file to label Monero as built");
}
}
println!("cargo:rerun-if-changed=c/wrapper.cpp"); println!("cargo:rerun-if-changed=c/wrapper.cpp");
#[rustfmt::skip] #[rustfmt::skip]
cc::Build::new() cc::Build::new()
@ -101,9 +36,6 @@ fn main() {
.file("c/monero/src/crypto/keccak.c") .file("c/monero/src/crypto/keccak.c")
.file("c/monero/src/crypto/hash.c") .file("c/monero/src/crypto/hash.c")
.include("c/monero/src/device")
.file("c/monero/src/device/device_default.cpp")
.include("c/monero/src/ringct") .include("c/monero/src/ringct")
.file("c/monero/src/ringct/rctCryptoOps.c") .file("c/monero/src/ringct/rctCryptoOps.c")
.file("c/monero/src/ringct/rctTypes.cpp") .file("c/monero/src/ringct/rctTypes.cpp")
@ -115,7 +47,6 @@ fn main() {
.file("c/wrapper.cpp") .file("c/wrapper.cpp")
.compile("wrapper"); .compile("wrapper");
println!("cargo:rustc-link-search={}", out_dir);
println!("cargo:rustc-link-lib=wrapper"); println!("cargo:rustc-link-lib=wrapper");
println!("cargo:rustc-link-lib=stdc++"); println!("cargo:rustc-link-lib=stdc++");
} }

View file

@ -1,7 +1,5 @@
#include <mutex> #include <mutex>
#include "device/device_default.hpp"
#include "ringct/bulletproofs.h" #include "ringct/bulletproofs.h"
#include "ringct/rctSigs.h" #include "ringct/rctSigs.h"