Skip to content
This repository was archived by the owner on Oct 19, 2026. It is now read-only.

Commit eabfab1

Browse files
authored
feat: fix migration and add note table (#2033)
* feat: fix migration and add note table * fix: merge clippy
1 parent 3743856 commit eabfab1

37 files changed

Lines changed: 897 additions & 410 deletions

‎.github/workflows/base.yml‎

Lines changed: 67 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@
88

99
on:
1010
workflow_dispatch:
11+
push:
12+
branches:
13+
- main
1114
pull_request:
1215
paths-ignore:
13-
- 'config/**'
14-
- 'docker/**'
15-
- 'docs/**'
16-
- 'moon/**'
17-
- 'scripts/**'
18-
- 'toolchains/**'
19-
- '.github/workflows/web-**'
16+
- "config/**"
17+
- "docker/**"
18+
- "docs/**"
19+
- "moon/**"
20+
- "scripts/**"
21+
- "toolchains/**"
22+
- ".github/workflows/web-**"
2023

2124
name: Base GitHub Action for Check, Test and Lints
2225

@@ -26,7 +29,7 @@ concurrency:
2629

2730
jobs:
2831
format:
29-
if: ${{ github.repository == 'web3infra-foundation/mega' }}
32+
if: ${{ !(github.repository == 'web3infra-foundation/mega' && github.event_name == 'push') }}
3033
name: Rustfmt Check
3134
runs-on: ubuntu-latest
3235
steps:
@@ -44,12 +47,14 @@ jobs:
4447

4548
#
4649
clippy:
47-
if: ${{ github.repository == 'web3infra-foundation/mega' }}
50+
if: ${{ !(github.repository == 'web3infra-foundation/mega' && github.event_name == 'push') }}
4851
name: Clippy Check
4952
runs-on: ubuntu-latest
5053
env:
5154
CARGO_TERM_COLOR: always
5255
RUSTUP_TOOLCHAIN: stable
56+
RUSTC_WRAPPER: sccache
57+
SCCACHE_DIR: ${{ github.workspace }}/.sccache
5358
steps:
5459
- name: Checkout repository
5560
uses: actions/checkout@v4
@@ -61,26 +66,42 @@ jobs:
6166
with:
6267
cache-key: sysdeps
6368
platform: ubuntu
69+
- name: Install sccache
70+
run: |
71+
sudo apt-get update
72+
sudo apt-get install -y sccache
73+
- name: Prepare sccache directory
74+
run: |
75+
mkdir -p "$SCCACHE_DIR"
76+
- name: Cache sccache
77+
uses: actions/cache@v4
78+
with:
79+
path: ${{ env.SCCACHE_DIR }}
80+
key: sccache-${{ runner.os }}-stable-${{ hashFiles('**/Cargo.lock') }}-clippy
81+
restore-keys: |
82+
sccache-${{ runner.os }}-stable-${{ hashFiles('**/Cargo.lock') }}-
83+
sccache-${{ runner.os }}-stable-
84+
- name: Rust cache
85+
uses: Swatinem/rust-cache@v2
86+
with:
87+
shared-key: base-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
88+
cache-on-failure: true
6489
- name: Run cargo clippy
6590
run: |
91+
sccache --start-server || true
6692
cargo +stable clippy --all-targets --all-features -- -D warnings
93+
sccache --show-stats || true
6794
6895
test:
96+
if: ${{ !(github.repository == 'web3infra-foundation/mega' && github.event_name == 'push') }}
6997
name: Full Test
70-
if: ${{ github.repository == 'web3infra-foundation/mega' }}
71-
strategy:
72-
fail-fast: false
73-
matrix:
74-
include:
75-
- os: ubuntu
76-
runs-on: [self-hosted, Linux, X64]
77-
home: /home/github
78-
79-
runs-on: ${{ matrix.runs-on }}
98+
runs-on: ${{ fromJson(github.repository == 'web3infra-foundation/mega' && '["self-hosted","Linux","X64"]' || '"ubuntu-latest"') }}
8099
env:
81100
CARGO_TERM_COLOR: always
82101
RUSTUP_TOOLCHAIN: stable
83-
HOME: ${{ matrix.home }}
102+
HOME: ${{ github.repository == 'web3infra-foundation/mega' && '/home/github' || '/home/runner' }}
103+
RUSTC_WRAPPER: sccache
104+
SCCACHE_DIR: ${{ github.workspace }}/.sccache
84105
steps:
85106
- name: Install Redis
86107
run: sudo apt-get update && sudo apt-get install -y redis-server
@@ -95,25 +116,48 @@ jobs:
95116
uses: ./.github/install-dep
96117
with:
97118
cache-key: sysdeps
98-
platform: ${{ matrix.os }}
99-
self-hosted: true
119+
platform: ubuntu
120+
self-hosted: ${{ github.repository == 'web3infra-foundation/mega' }}
100121
use-gtk: false
122+
- name: Install sccache
123+
run: |
124+
sudo apt-get update
125+
sudo apt-get install -y sccache
126+
- name: Prepare sccache directory
127+
run: |
128+
mkdir -p "$SCCACHE_DIR"
129+
- name: Cache sccache
130+
uses: actions/cache@v4
131+
with:
132+
path: ${{ env.SCCACHE_DIR }}
133+
key: sccache-${{ runner.os }}-stable-${{ hashFiles('**/Cargo.lock') }}-test
134+
restore-keys: |
135+
sccache-${{ runner.os }}-stable-${{ hashFiles('**/Cargo.lock') }}-
136+
sccache-${{ runner.os }}-stable-
137+
- name: Rust cache
138+
uses: Swatinem/rust-cache@v2
139+
with:
140+
shared-key: base-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
141+
cache-on-failure: true
101142

102143
- name: Set up git lfs
103144
run: |
104-
echo "GPG_TTY=${{ matrix.os == 'windows' && 'CON' || '$(tty)' }}" >> $GITHUB_ENV
145+
echo "GPG_TTY=$(tty)" >> $GITHUB_ENV
105146
git lfs install
106147
git config --global user.email "mega@github.com"
107148
git config --global user.name "Mega"
108149
git config --global lfs.url http://localhost:8000
109150
110151
- name: Run cargo test
111152
run: |
153+
sccache --start-server || true
112154
cargo test --manifest-path common/Cargo.toml --all-features --no-fail-fast -- --nocapture
113155
cargo test --manifest-path jupiter/Cargo.toml --all-features --no-fail-fast -- --nocapture
114156
cargo test --manifest-path ceres/Cargo.toml --all-features --no-fail-fast -- --nocapture
115157
cargo test --manifest-path vault/Cargo.toml --all-features --no-fail-fast -- --nocapture
116158
cargo test --manifest-path saturn/Cargo.toml --all-features --no-fail-fast -- --nocapture
159+
cargo test --manifest-path orion-server/Cargo.toml --all-features --no-fail-fast -- --nocapture
160+
sccache --show-stats || true
117161
118162
# Note: The fuse/scorpio job has been removed as scorpio has been moved
119163
# to its own repository: https://github.com/web3infra-foundation/scorpiofs

‎.github/workflows/mono-engine-deploy.yml‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,19 @@ jobs:
8585
8686
ECR_IMAGE="$ECR_REGISTRY/${{ env.REGISTRY_ALIAS }}/${{ env.REPOSITORY }}:$IMAGE_TAG"
8787
GCP_IMAGE="us-central1-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.REPOSITORY }}:$IMAGE_TAG"
88+
ECR_CACHE_IMAGE="$ECR_REGISTRY/${{ env.REGISTRY_ALIAS }}/${{ env.REPOSITORY }}:buildcache-${ARCH_SUFFIX}"
89+
CACHE_SCOPE="mono-engine-${ARCH_SUFFIX}"
8890
8991
echo "ECR_IMAGE=$ECR_IMAGE"
9092
echo "GCP_IMAGE=$GCP_IMAGE"
93+
echo "ECR_CACHE_IMAGE=$ECR_CACHE_IMAGE"
94+
echo "CACHE_SCOPE=$CACHE_SCOPE"
9195
9296
docker buildx build \
93-
--cache-from type=gha \
94-
--cache-to type=gha,mode=max \
97+
--cache-from type=gha,scope=$CACHE_SCOPE \
98+
--cache-from type=registry,ref=$ECR_CACHE_IMAGE \
99+
--cache-to type=gha,mode=max,scope=$CACHE_SCOPE \
100+
--cache-to type=registry,ref=$ECR_CACHE_IMAGE,mode=max \
95101
--provenance=false \
96102
--sbom=false \
97103
-f ./mono/Dockerfile \

‎.github/workflows/orion-server-deploy.yml‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,15 @@ jobs:
7979
GCP_IMAGE_BASE="us-central1-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.REPOSITORY }}"
8080
8181
TAG="${{ env.IMAGE_TAG_BASE }}-$ARCH_SUFFIX"
82+
AWS_CACHE_IMAGE="$AWS_IMAGE_BASE:buildcache-$ARCH_SUFFIX"
83+
CACHE_SCOPE="orion-server-$ARCH_SUFFIX"
8284
8385
docker buildx build \
8486
--platform "$PLATFORM" \
85-
--cache-from type=gha \
86-
--cache-to type=gha,mode=max \
87+
--cache-from type=gha,scope=$CACHE_SCOPE \
88+
--cache-from type=registry,ref=$AWS_CACHE_IMAGE \
89+
--cache-to type=gha,mode=max,scope=$CACHE_SCOPE \
90+
--cache-to type=registry,ref=$AWS_CACHE_IMAGE,mode=max \
8791
--provenance=false \
8892
--sbom=false \
8993
-f orion-server/Dockerfile \

‎ceres/Cargo.toml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ async-recursion = { workspace = true }
3737
rand = { workspace = true }
3838
sysinfo = { workspace = true }
3939
utoipa = { workspace = true }
40-
base64 = { workspace = true }
41-
http = { workspace = true }
4240
regex = { workspace = true }
4341
tokio-util = { workspace = true }
4442
uuid = { workspace = true, features = ["v4"] }

‎ceres/src/protocol/mod.rs‎

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
use core::fmt;
22
use std::{path::PathBuf, str::FromStr, sync::Arc};
33

4-
use base64::{engine::general_purpose, prelude::*};
54
use bellatrix::Bellatrix;
65
use callisto::sea_orm_active_enums::RefTypeEnum;
76
use common::{
87
errors::{MegaError, ProtocolError},
98
utils::ZERO_ID,
109
};
11-
use http::{HeaderMap, HeaderValue};
1210
use import_refs::RefCommand;
1311
use jupiter::redis::lock::RedLock;
1412
use repo::Repo;
@@ -225,62 +223,6 @@ impl SmartProtocol {
225223
Ok(Arc::new(res))
226224
}
227225
}
228-
229-
pub fn enable_http_auth(&self, state: &ProtocolApiState) -> bool {
230-
state.storage.config().enable_http_auth()
231-
}
232-
233-
pub async fn http_auth(
234-
&mut self,
235-
state: &ProtocolApiState,
236-
header: &HeaderMap<HeaderValue>,
237-
) -> bool {
238-
for (k, v) in header {
239-
if k == http::header::AUTHORIZATION {
240-
let decoded = general_purpose::STANDARD
241-
.decode(
242-
v.to_str()
243-
.unwrap()
244-
.strip_prefix("Basic ")
245-
.unwrap()
246-
.as_bytes(),
247-
)
248-
.unwrap();
249-
let credentials = String::from_utf8(decoded).unwrap_or_default();
250-
let mut parts = credentials.splitn(2, ':');
251-
let username = parts.next().unwrap_or("");
252-
self.username = Some(username.to_owned());
253-
let token = parts.next().unwrap_or("");
254-
let auth_config = state.storage.config().authentication.clone();
255-
if auth_config.enable_test_user
256-
&& username == auth_config.test_user_name
257-
&& token == auth_config.test_user_token
258-
{
259-
self.authenticated_user = Some(PushUserInfo {
260-
username: username.to_string(),
261-
});
262-
return true;
263-
}
264-
let token_valid = state
265-
.storage
266-
.user_storage()
267-
.check_token(username, token)
268-
.await
269-
.unwrap_or(false);
270-
271-
if token_valid {
272-
// Valid token: set minimal authenticated user info
273-
self.authenticated_user = Some(PushUserInfo {
274-
username: username.to_string(),
275-
});
276-
return true;
277-
}
278-
279-
return token_valid;
280-
}
281-
}
282-
false
283-
}
284226
}
285227

286228
#[cfg(test)]

‎common/src/config/mod.rs‎

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ pub struct Config {
8484
pub database: DbConfig,
8585
pub monorepo: MonoConfig,
8686
pub pack: PackConfig,
87-
pub authentication: AuthConfig,
8887
pub lfs: LFSConfig,
8988
#[serde(default)]
9089
pub blame: BlameConfig,
@@ -129,7 +128,6 @@ impl Config {
129128
database: DbConfig::default(),
130129
monorepo: MonoConfig::default(),
131130
pack: PackConfig::default(),
132-
authentication: AuthConfig::default(),
133131
lfs: LFSConfig::default(),
134132
blame: BlameConfig::default(),
135133
oauth: OauthConfig::default(),
@@ -173,10 +171,6 @@ impl Config {
173171
pub fn from_config(config: c::Config) -> Result<Self, ConfigError> {
174172
config.try_deserialize::<Config>()
175173
}
176-
177-
pub fn enable_http_auth(&self) -> bool {
178-
self.authentication.enable_http_auth
179-
}
180174
}
181175

182176
/// supports braces-delimited variables (i.e. ${foo}) in config.
@@ -351,25 +345,6 @@ impl Default for RenameConfig {
351345
}
352346
}
353347
}
354-
#[derive(Serialize, Deserialize, Debug, Clone)]
355-
pub struct AuthConfig {
356-
pub enable_http_auth: bool,
357-
pub enable_test_user: bool,
358-
pub test_user_name: String,
359-
pub test_user_token: String,
360-
}
361-
362-
impl Default for AuthConfig {
363-
fn default() -> Self {
364-
Self {
365-
enable_http_auth: false,
366-
enable_test_user: false,
367-
test_user_name: String::from("mega"),
368-
test_user_token: String::from("mega"),
369-
}
370-
}
371-
}
372-
373348
#[derive(Serialize, Deserialize, Debug, Clone)]
374349
pub struct PackConfig {
375350
#[serde(deserialize_with = "string_or_usize")]

‎config/config.toml‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,6 @@ connect_timeout = 3
4747
# Whether to enable SQLx logging
4848
sqlx_logging = false
4949

50-
[authentication]
51-
# Support http authentication, login in with github and generate token before push
52-
enable_http_auth = false
53-
54-
# Enable a test user for debugging and development purposes.
55-
# If set to true, the service allows using a predefined test user for authentication.
56-
enable_test_user = true
57-
58-
# Specify the name of the test user.
59-
# This is only relevant if `enable_test_user` is set to true.
60-
test_user_name = "mega"
61-
62-
# Specify the token for the test user.
63-
# This is used for authentication when `enable_test_user` is set to true.
64-
test_user_token = "mega"
65-
6650
[monorepo]
6751
## Only import directory support multi-branch commit and tag, monorepo only support main branch
6852
## Mega treats files under this directory as import repo and other directories as monorepo

‎jupiter/callisto/src/build_targets.rs‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,3 @@ impl Related<super::target_state_histories::Entity> for Entity {
4141
}
4242

4343
impl ActiveModelBehavior for ActiveModel {}
44-
//:path1 //:path2 //:path3
45-
46-
//target log:
47-
// - id
48-
// - target id
49-
// - task
50-
// - state
51-
// - createdAt

‎jupiter/callisto/src/mega_cl.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ pub struct Model {
1717
pub status: MergeStatusEnum,
1818
#[sea_orm(column_type = "Text")]
1919
pub path: String,
20-
pub base_branch: String,
2120
pub from_hash: String,
2221
pub to_hash: String,
2322
pub created_at: DateTime,
2423
pub updated_at: DateTime,
2524
pub username: String,
25+
pub base_branch: String,
2626
}
2727

2828
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

0 commit comments

Comments
 (0)