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
2 changes: 1 addition & 1 deletion .github/workflows/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
- name: Run cargo test
run: |
cargo build --bin mega --bin libra
cargo test --all-targets --no-fail-fast
cargo test -p libra --all-features --no-fail-fast -- --nocapture

monobean:
name: Test Monobean for ${{ matrix.os }}
Expand Down
33 changes: 31 additions & 2 deletions .github/workflows/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,35 @@ jobs:
- name: Build mono and libra
run: |
cargo build --bin mono --bin libra
echo "The mono volumn located at: ${{ github.workspace }}/testing"
mkdir -p ${{ github.workspace }}/testing
echo "The mono volume is located at: ${{ github.workspace }}/testing"
ls -l ${{ github.workspace }}/testing
mkdir -p ${{ github.workspace }}/testing/etc
mkdir -p ${{ github.workspace }}/testing/cache
mkdir -p ${{ github.workspace }}/testing/lfs
mkdir -p ${{ github.workspace }}/testing/logs
mkdir -p ${{ github.workspace }}/testing/objects
mkdir -p ${{ github.workspace }}/testing/etc/ssh
mkdir -p ${{ github.workspace }}/testing/etc/https
ssh-keygen -t rsa -b 4096 -f "${{ github.workspace }}/testing/etc/ssh/ssh_host_rsa_key" -N "" -C "sshd host key" >/dev/null 2>&1
cp ${{ github.workspace }}/config/config-workflow.toml ${{ github.workspace }}/testing/etc/config.toml
echo "Directory structure has been successfully created:"
echo "${{ github.workspace }}/testing"
echo "├── etc"
echo "│ ├── ssh"
echo "│ │ ├── ssh_host_rsa_key"
echo "│ │ └── ssh_host_rsa_key.pub"
echo "│ ├── https"
echo "│ └── config.toml"
echo "├── cache"
echo "├── lfs"
echo "├── logs"
echo "├── objects"
export MEGA_BASE_DIR="${{ github.workspace }}/testing"
nohup ${{ github.workspace }}/target/debug/mono -c ${{ github.workspace }}/testing/etc/config.toml service multi http ssh --host 0.0.0.0 --port 8000 --ssh-port 9000 >/dev/null 2>&1 &
echo "mono has been successfully built and started in the background"
sleep 10
cargo test -p mega --all-features --no-fail-fast -- --nocapture
cargo test -p mono --all-features --no-fail-fast -- --nocapture
cargo test --test service_test -- --nocapture
cargo test --test lfs_test -- --nocapture

116 changes: 116 additions & 0 deletions config/config-workflow.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# the directory where the data files is located, such as logs, database, etc.
# can be overridden by environment variable `MEGA_BASE_DIR`
# When using monobean, this option will be ignored, you should set it in monobean preference GUI.
base_dir = "/tmp/.mono"

# Filling the following environment variables with values you set
## Logging Configuration
[log]
# The path which log file is saved
log_path = "${base_dir}/logs"

# log level
level = "debug"

# print std log in console, disable it on production for performance
print_std = true


[database]
# "sqlite" | "postgres"
# "sqlite" will use `db_path` and ignore `db_url`
db_type = "postgres"

# used for sqlite
db_path = "${base_dir}/mega.db"

# database connection url, set to "postgres://mono:mono@mono-pg:5432/mono" if you're using docker
db_url = "postgres://mono:mono@localhost:5432/mono"

# db max connection, setting it to twice the number of CPU cores would be appropriate.
max_connection = 4

# db min connection, setting it to the number of CPU cores would be appropriate.
min_connection = 2

# Whether to disabling SQLx Log
sqlx_logging = false

[authentication]
# Support http authentication, login in with github and generate token before push
enable_http_auth = false

# Enable a test user for debugging and development purposes.
# If set to true, the service allows using a predefined test user for authentication.
enable_test_user = true

# Specify the name of the test user.
# This is only relevant if `enable_test_user` is set to true.
test_user_name = "mega"

# Specify the token for the test user.
# This is used for authentication when `enable_test_user` is set to true.
test_user_token = "mega"

[monorepo]
## Only import directory support multi-branch commit and tag, monorepo only support main branch
## Mega treats files under this directory as import repo and other directories as monorepo
import_dir = "/third-party"

# Set System Admin in directory init, replace the admin's github username here
admin = "admin"

# Set serveral root dirs in directory init
root_dirs = ["third-party", "project", "doc", "release"]

[pack]
# The maximum memory used by decode
# Support the following units/notations: K, M, G, T, KB, MB, GB, TB, KiB, MiB, GiB, TiB, `%` and decimal percentages
# Capacity units are case-insensitive and can also be spelled as mb or Mb
# Abbreviated units are treated as binary byte units, for example M is treated as MiB
pack_decode_mem_size = "4G"
pack_decode_disk_size = "20%"

# The location where the object stored when the memory used by decode exceeds the limit
pack_decode_cache_path = "${base_dir}/cache"

clean_cache_after_decode = true

# The maximum message size in channel buffer while decode
channel_message_size = 1_000_000

[lfs]
# lfs file storage type, support values can be "local_fs" or "aws_s3"
storage_type = "local_fs"

[lfs.ssh]
# The lfs ssh transport protocol still relies on http to send files
http_url = "http://localhost:8000"

[lfs.local]
# set the local path of the lfs storage
lfs_file_path = "${base_dir}/lfs"

## IMPORTANT: The 'enable_split' feature can only be enabled for new databases. Existing databases do not support this feature.
# Enable or disable splitting large files into smaller chunks
enable_split = true # Default is disabled. Set to true to enable file splitting.

# Size of each file chunk when splitting is enabled. Ignored if splitting is disabled.
split_size = "20M"

[lfs.aws]
s3_bucket = "gitmono"
s3_region = "ap-southeast-2"
s3_access_key_id = ""
s3_secret_access_key = ""

[oauth]
# GitHub OAuth application client id and secret
github_client_id = ""
github_client_secret = ""

# Used for redirect to ui after login, for example: https://console.gitmono.com
ui_domain = "http://localhost:3000"

# Set your own domain here, for example: .gitmono.com
cookie_domain = "localhost"
3 changes: 3 additions & 0 deletions libra/tests/command/clone_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use tempfile::tempdir;

#[tokio::test]
#[serial]
#[ignore]
/// Test the clone command with a specific branch
async fn test_clone_branch() {
let temp_path = tempdir().unwrap();
Expand Down Expand Up @@ -36,6 +37,7 @@ async fn test_clone_branch() {

#[tokio::test]
#[serial]
#[ignore]
/// Test the clone command with the default branch
async fn test_clone_default_branch() {
let temp_path = tempdir().unwrap();
Expand Down Expand Up @@ -65,6 +67,7 @@ async fn test_clone_default_branch() {

#[tokio::test]
#[serial]
#[ignore]
/// Test the clone command with an empty repository
async fn test_clone_empty_repo() {
let temp_path = tempdir().unwrap();
Expand Down
3 changes: 2 additions & 1 deletion mega/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ serial_test = { workspace = true }
lazy_static = { workspace = true }
assert_cmd = { workspace = true }
testcontainers = { workspace = true, features = ["http_wait","reusable-containers"] }
http = { workspace = true }
http = { workspace = true }
reqwest = { workspace = true }
13 changes: 13 additions & 0 deletions mega/tests/service_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use serial_test::serial;

#[tokio::test]
#[serial]
async fn check_mono_service_status() -> Result<(), reqwest::Error> {
let client = reqwest::Client::new();
let response = client.get("http://127.0.0.1:8000/api/v1/status")
.send()
.await?;

assert_eq!(response.status(), reqwest::StatusCode::OK, "Service status API did not return 200 OK");
Ok(())
}
Loading