Skip to content

Commit

Permalink
Merge pull request #875 from yyk808/main
Browse files Browse the repository at this point in the history
feat(CI): cross platform CI for mega and monobean
  • Loading branch information
genedna authored Feb 27, 2025
2 parents b9342cf + 73d7d71 commit e739a77
Show file tree
Hide file tree
Showing 117 changed files with 1,586 additions and 954 deletions.
136 changes: 136 additions & 0 deletions .github/install-dep/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: 'Install Dependencies'
description: 'Install dependencies with caching support'

inputs:
cache-key:
description: 'Cache key for dependencies'
required: true
platform:
description: 'Platform (ubuntu-latest, windows-latest, macos-latest)'
required: true
use-gtk:
description: 'Whether download and setup GTK libs (true, false)'
required: false
default: 'true'

runs:
using: "composite"
steps:
# ================= Universal Initialization =================
# on windows, it suffers from extremely slow zstd compression and decompression speed
# https://github.com/actions/toolkit/issues/1578#issuecomment-2253355054
# So we have to manuallly restore and save the cache
- name: Restore dependencies
id: cache-restore
uses: actions/cache/restore@v4
with:
path: |
/var/cache/apt/
~/Library/Caches/Homebrew
C:\ProgramData\chocolatey\lib
./.choco-cache
key: ${{ inputs.platform }}-sysdeps-${{ inputs.cache-key }}

- name: Setup Rust Toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy rustfmt
cache-workspaces: |
./
./scorpio
./monobean
cache-directories: |
./target
./scorpio/target
./monobean/target
# ================ Platform-specific Initialization (Linux) ================
- name: Install dependencies (Ubuntu)
if: inputs.platform == 'ubuntu-latest'
shell: bash
run: |
echo "deb http://gb.archive.ubuntu.com/ubuntu jammy main" | sudo tee -a /etc/apt/sources.list
sudo apt update
sudo apt install -y \
git-lfs \
libwebkit2gtk-4.1-dev \
build-essential \
curl \
wget \
file \
libssl-dev \
libgtk-3-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
libgtk-4-dev \
libadwaita-1-0 \
libadwaita-1-dev \
fuse3 \
libfuse3-dev \
# ================ Platform-specific Initialization (macOS) ================
- name: Set up Homebrew
if: inputs.platform == 'macos-latest'
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master

# fuse not available on macOS
- name: Install dependencies (macOS)
if: inputs.platform == 'macos-latest'
shell: bash
run: |
export HOMEBREW_NO_AUTO_UPDATE=1
brew install \
gtk4 \
gtk+3 \
libadwaita \
openssl@3 \
librsvg \
# =============== Platform-specific Initialization (Windows) ===============
# According to https://github.com/actions/runner-images/blob/main/images/windows/toolsets/toolset-2025.json
# OpenSSL, cmake and some other build tools have been embedded into the windows-latest image.
- name: Install dependencies (Windows)
if: inputs.platform == 'windows-latest'
shell: pwsh
run: |
choco config set cacheLocation ./.choco-cache
choco install --no-progress git-lfs pkgconfiglite ninja nasm
pip install requests tqdm
# Required by monobean, performing this step would take about 5s.
# Won't caching it, for compression and decompression are MUCH slower than downloading it directly.
- name: Load GTK and libadwaita
if: inputs.platform == 'windows-latest' && inputs.use-gtk == 'true'
shell: pwsh
run: python ./monobean/setup.py

- name: Manually set env vars and export
if: inputs.platform == 'windows-latest'
shell: pwsh
run: |
$env:Path = "$env:Path;${{ github.workspace }}\monobean\resources\lib\bin;C:\Program Files\NASM;C:\Program Files\CMake\bin"
$env:OPENSSL_DIR = "C:\Program Files\OpenSSL\"
$env:PKG_CONFIG_PATH = "$env:PKG_CONFIG_PATH;${{ github.workspace }}\monobean\resources\lib\lib\pkgconfig;C:\Program Files\PkgConfig\lib\pkgconfig"
$env:LIB = "$env:LIB;${{ github.workspace }}\monobean\resources\lib\lib"
$env:INCLUDE = "$env:INCLUDE;${{ github.workspace }}\monobean\resources\lib\include;${{ github.workspace }}\monobean\resources\lib\include\cairo;${{ github.workspace }}\monobean\resources\lib\include\glib-2.0;${{ github.workspace }}\monobean\resources\lib\include\gobject-introspection-1.0;${{ github.workspace }}\monobean\resources\lib\lib\glib-2.0\include"
$env:AWS_LC_SYS_PREBUILT_NASM = 1
$env:AWS_LC_SYS_C_STD = 11
$exportVariables = @("Path", "OPENSSL_DIR", "OPENSSL_LIB_DIR", "PKG_CONFIG_PATH", "LIB", "INCLUDE", "AWS_LC_SYS_C_STD", "AWS_LC_SYS_PREBUILT_NASM")
foreach ($var in $exportVariables) {
if (Test-Path "Env:\$var") {
"$var=$((Get-Item "Env:\$var").Value)" | Out-File -FilePath $env:GITHUB_ENV -Append
}
}
# =============== Save cache for speeding up ===============
- name: Cache dependencies
if: inputs.platform != 'windows-latest' || steps.cache-restore.outputs.cache-hit == 'false'
uses: actions/cache/save@v4
with:
path: |
/var/cache/apt/
~/Library/Caches/Homebrew
C:\ProgramData\chocolatey\lib
./.choco-cache
key: ${{ inputs.platform }}-sysdeps-${{ inputs.cache-key }}
183 changes: 106 additions & 77 deletions .github/workflows/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,133 +3,162 @@
# History:
# 1. 2023-02-14: Created at 2023-02-14T16:00:00Z by Quanyi Ma <[email protected]>
# 2. 2024-05-07: Update the `fuse` job to install `fuse3` and `libfuse3-dev` at 2024-05-07T16:00:00Z by Xiaoyang Han <[email protected]>
#
# 3. 2025-02-27: Reconstruct the workflow and add `install-dep` action to support test on multiple platforms by Neon <[email protected]>
#

on: [push, pull_request]

name: Base GitHub Action for Check, Test and Lints

jobs:
# cache files before all jobs
setup:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

name: Setup and cache ${{ matrix.os }}
runs-on: ${{ matrix.os }}

env:
CARGO_TERM_COLOR: always

steps:
- uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- uses: actions-rs/toolchain@v1
- name: Setup Rust Toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v2
components: clippy rustfmt
cache-workspaces: |
./
./scorpio
./monobean
cache-directories: |
./target
./scorpio/target
./monobean/target
#
check:
name: Check
format:
name: Rustfmt Check
runs-on: ubuntu-latest
needs: setup
steps:
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgtk-4-dev libadwaita-1-0 libadwaita-1-dev librust-gtk4-sys-dev
- uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions-rs/cargo@v1
with:
command: check
- run: cargo fmt --all -- --check

#
clippy:
name: Clippy
runs-on: ubuntu-latest
name: Clippy for ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{ matrix.os }}
needs: setup
env:
CARGO_TERM_COLOR: always

steps:
- uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- run: |
echo "deb http://gb.archive.ubuntu.com/ubuntu jammy main" | sudo tee -a /etc/apt/sources.list
sudo apt update
sudo apt install -y libwebkit2gtk-4.1-dev \
build-essential \
curl \
wget \
file \
libssl-dev \
libgtk-3-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
libgtk-4-dev \
libadwaita-1-0 \
libadwaita-1-dev \
librust-gtk4-sys-dev
- uses: actions-rs/cargo@v1
with:
command: build
args: --bin mega --bin libra
- run: rustup component add clippy
- uses: actions-rs/cargo@v1

- name: Install system dependencies
uses: ./.github/install-dep
with:
command: clippy
args: --workspace --all-targets --all-features -- -D warnings
cache-key: sysdeps
platform: ${{ matrix.os }}

- name: Run cargo clippy
run: |
cargo build --bin mega --bin libra
cargo clippy --workspace --all-targets --all-features -- -D warnings
#
test:
name: Tests
runs-on: ubuntu-latest
name: Test for ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{ matrix.os }}
needs: setup
env:
CARGO_TERM_COLOR: always

steps:
- uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- run: |
sudo apt update
sudo apt-get install -y git-lfs
sudo apt install libgtk-4-dev libadwaita-1-0 libadwaita-1-dev librust-gtk4-sys-dev

- name: Install system dependencies
uses: ./.github/install-dep
with:
cache-key: sysdeps
platform: ${{ matrix.os }}

- name: Set up git lfs
run: |
git lfs install
git config --global user.email "[email protected]"
git config --global user.name "Mega"
git config --global lfs.url http://localhost:8000
- uses: actions-rs/cargo@v1
with:
command: build
args: --bin mega --bin libra
- uses: actions-rs/cargo@v1
with:
command: test
args: --workspace --test '*' -- --nocapture
- name: Run cargo test
run: |
cargo build --bin mega --bin libra
cargo test --workspace --all-features --all --no-fail-fast
#
doc:
name: Doc
runs-on: ubuntu-latest
monobean:
name: Test Monobean for ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{ matrix.os }}
needs: setup
env:
CARGO_TERM_COLOR: always

steps:
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgtk-4-dev libadwaita-1-0 libadwaita-1-dev librust-gtk4-sys-dev
- uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions-rs/cargo@v1

- name: Install system dependencies
uses: ./.github/install-dep
with:
command: doc
cache-key: sysdeps
platform: ${{ matrix.os }}

- name: Run Lints
run: |
cargo clippy --manifest-path monobean/Cargo.toml --all-targets --all-features -- -D warnings
cargo test --manifest-path monobean/Cargo.toml --all-features --all --no-fail-fast -- --nocapture
#
fuse:
name: Fuse Lints
runs-on: ubuntu-latest
needs: setup
steps:
- uses: actions/checkout@v3
- run: |
git submodule update --init --recursive
sudo apt-get update && sudo apt-get install -y fuse3 libfuse3-dev
cd ./scorpio && cargo clippy --all-targets --all-features -- -D warnings
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- run: cargo clippy --manifest-path scorpio/Cargo.toml --all-targets --all --all-features -- -D warnings

moon-lint-and-build:
name: MOON Lint & Build
Expand Down
2 changes: 1 addition & 1 deletion aries/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ fn main() {
println!("cargo:rustc-link-arg=-Wl,-rpath,$ORIGIN");
#[cfg(target_os = "macos")]
println!("cargo:rustc-link-arg=-Wl,-rpath,@executable_path");
}
}
2 changes: 1 addition & 1 deletion aries/src/service/api/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub mod nostr_router;
pub mod ca_router;
pub mod nostr_router;

#[cfg(test)]
mod tests {}
1 change: 0 additions & 1 deletion ceres/src/api_service/import_api_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ impl ApiHandler for ImportApiService {
));
}


fn strip_relative(&self, path: &Path) -> Result<PathBuf, GitError> {
if let Ok(relative_path) = path.strip_prefix(self.repo.repo_path.clone()) {
Ok(relative_path.to_path_buf())
Expand Down
Loading

1 comment on commit e739a77

@vercel
Copy link

@vercel vercel bot commented on e739a77 Feb 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

mega – ./

mega-gitmono.vercel.app
mega-git-main-gitmono.vercel.app
gitmega.dev
www.gitmega.dev

Please sign in to comment.