WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 4eceb09

Browse files
authored
Improve build times while building the SDK (#13)
* Try to improve caching
1 parent be9e761 commit 4eceb09

File tree

2 files changed

+33
-16
lines changed

2 files changed

+33
-16
lines changed

.github/workflows/release_sdk.yml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ on:
1111
description: 'The new version for the sdk library.'
1212
required: true
1313

14-
1514
jobs:
1615
build_native:
1716
name: Build and generate sdk aar
@@ -21,11 +20,28 @@ jobs:
2120
group: ${{ github.ref }}-${{ github.job }}
2221
cancel-in-progress: true
2322

23+
env:
24+
RUST_SDK_PATH: "./matrix-rust-sdk"
25+
2426
steps:
2527

2628
- name: Checkout this repo
2729
uses: actions/checkout@v3
2830

31+
- name: Checkout matrix rust sdk repo
32+
uses: actions/checkout@v3
33+
with:
34+
repository: "matrix-org/matrix-rust-sdk"
35+
ref: ${{ github.event.inputs.rust-checkout-ref }}
36+
path: ${{ env.RUST_SDK_PATH }}
37+
38+
- uses: Swatinem/rust-cache@v2
39+
with:
40+
save-if: ${{ github.ref == 'refs/heads/main' || github.ref == 'main' }}
41+
cache-on-failure: true
42+
workspaces: |
43+
${{ env.RUST_SDK_PATH }} -> target
44+
2945
- name: Set up JDK 11
3046
uses: actions/setup-java@v2
3147
with:
@@ -41,16 +57,6 @@ jobs:
4157
with:
4258
ndk-version: r25c
4359

44-
- uses: actions/cache@v2
45-
with:
46-
path: |
47-
~/.cargo/bin/
48-
~/.cargo/registry/index/
49-
~/.cargo/registry/cache/
50-
~/.cargo/git/db
51-
target/
52-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
53-
5460
- name: Install Rust
5561
uses: dtolnay/rust-toolchain@nightly
5662

@@ -91,4 +97,4 @@ jobs:
9197
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
9298
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9399
run: |
94-
python3 ./scripts/release.py --module SDK --version ${{ github.event.inputs.sdk-version }} --ref ${{ github.event.inputs.rust-checkout-ref }}
100+
python3 ./scripts/release.py --module SDK --version ${{ github.event.inputs.sdk-version }} --ref ${{ github.event.inputs.rust-checkout-ref }} --path-to-sdk $RUST_SDK_PATH --skip-clone

scripts/release.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from enum import Enum, auto
99
from tempfile import TemporaryDirectory
1010

11-
1211
class Module(Enum):
1312
SDK = auto()
1413
CRYPTO = auto()
@@ -226,13 +225,24 @@ def run_publish_close_and_release_tasks(root_project_dir, publish_task: str):
226225
help="Version as a string (e.g. '1.0.0')")
227226
parser.add_argument("-r", "--ref", type=str, required=True,
228227
help="Ref to the git matrix-rust-sdk (branch name, commit or tag)")
228+
parser.add_argument("-p", "--path-to-sdk", type=str, required=False,
229+
help="Choose a module (SDK or CRYPTO)")
230+
parser.add_argument("-s", "--skip-clone", action="store_true", required=False,
231+
help="Skip cloning the Rust SDK repository")
229232

230233
args = parser.parse_args()
231234

232235
current_dir = os.path.dirname(os.path.abspath(__file__))
233236
project_root = os.path.dirname(current_dir).rstrip(os.sep)
234237
sdk_git_url = "https://github.com/matrix-org/matrix-rust-sdk.git"
235238

239+
if args.path_to_sdk:
240+
sdk_path = args.path_to_sdk
241+
else:
242+
sdk_path = TemporaryDirectory().name
243+
244+
skip_clone = args.skip_clone
245+
236246
print(f"Project Root Directory: {project_root}")
237247
print(f"Selected module: {args.module}")
238248
print(f"Version: {args.version}")
@@ -248,10 +258,11 @@ def run_publish_close_and_release_tasks(root_project_dir, publish_task: str):
248258
f"The provided version ({args.version}) is not higher than the previous version ({major}.{minor}.{patch}) so bump the version before retrying.")
249259
exit(0)
250260

251-
with TemporaryDirectory() as sdk_path:
261+
if skip_clone is False:
252262
clone_repo_and_checkout_ref(sdk_path, sdk_git_url, args.ref)
253-
linkable_ref = get_linkable_ref(sdk_path, args.ref)
254-
execute_build_script(current_dir, sdk_path, args.module)
263+
264+
linkable_ref = get_linkable_ref(sdk_path, args.ref)
265+
execute_build_script(current_dir, sdk_path, args.module)
255266

256267
override_version_in_build_version_file(build_version_file_path, args.version)
257268

0 commit comments

Comments
 (0)