88
99on :
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
2124name : Base GitHub Action for Check, Test and Lints
2225
@@ -26,7 +29,7 @@ concurrency:
2629
2730jobs :
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
0 commit comments