From b6eb7590e3a0c90cb93969440862ff0d794364ed Mon Sep 17 00:00:00 2001 From: MolecularPilot Date: Fri, 11 Apr 2025 16:49:12 +1000 Subject: [PATCH 1/2] hopefully improve CI speed a bit --- .github/workflows/ci.yml | 37 +++++++++++++++++++------------------ Makefile | 28 +++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74304d1..abc83ff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,41 +11,42 @@ jobs: runs-on: ubuntu-latest steps: + # 1. Checkout Code - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 + # 2. Set up Rust - name: Set up Rust (nightly) - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: toolchain: nightly - override: true - components: rustc, rust-src, cargo + components: rustc-dev llvm-tools, cargo + # 3. Cargo Caching (Crucial for speed) + - name: Cache cargo dependencies + uses: Swatinem/rust-cache@v2 + + # 4. Set up Java - name: Set up Java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '21' + # 5. Set up Python - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.x' + # 6. Set up Gradle) - name: Set up Gradle uses: gradle/actions/setup-gradle@v4 - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y make - - - name: Build all components - run: make all + # 7. Build using the CI-specific make target + - name: Build CI Target + run: make ci # Use your optimized CI build command + # 8. Run tests - name: Run integration tests - run: python3 Tester.py - - - name: Cleanup - if: always() # Ensure cleanup runs even if previous steps failed - run: make clean \ No newline at end of file + run: python3 Tester.py \ No newline at end of file diff --git a/Makefile b/Makefile index 1f0890a..38a1fd2 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # === Phony Targets === .PHONY: all help clean rust-components rust clean-rust java-linker clean-java-linker \ shim-metadata-gen clean-shim-metadata-gen asm-processor clean-asm-processor \ - library clean-library gen-files clean-gen-files + library clean-library gen-files clean-gen-files ci # === Terminal Colors === GREEN := \033[1;32m @@ -19,12 +19,18 @@ LIBRARY_JAR := $(LIBRARY_DIR)/build/libs/library-0.1.0.jar all: rust gen-files java-linker asm-processor @echo "$(GREEN)✨ Build complete! ✨$(RESET)" +# === CI Target === +# Running "make ci" sets IS_CI=1 and then behaves exactly like "make all" +ci: + $(MAKE) all IS_CI=1 + # === Help === help: @echo "$(CYAN)🛠️ Makefile for building the project$(RESET)" @echo "" @echo "Available targets:" @echo " make all - Build all components" + @echo " make ci - Build all components in CI mode (skips rust-components and shim-metadata-gen)" @echo " make clean - Clean all components" @echo " make rust-components - Install needed Rust components" @echo " make rust - Build the Rust root project" @@ -38,12 +44,18 @@ help: # === Needed rust components === rust-components: @echo "$(CYAN)🔧 Installing Rust components...$(RESET)" - rustup component add rust-src rustc-dev llvm-tools-preview + rustup component add rustc-dev llvm-tools # === Rust root project (Cargo) === +ifeq ($(IS_CI),1) +rust: $(SHIM_METADATA_GEN_DIR)/core.json + @echo "$(CYAN)📦 Building Rust root project...$(RESET)" + cargo build +else rust: $(SHIM_METADATA_GEN_DIR)/core.json rust-components @echo "$(CYAN)📦 Building Rust root project...$(RESET)" cargo build +endif clean-rust: @echo "$(CYAN)🧹 Cleaning Rust root project...$(RESET)" @@ -60,8 +72,14 @@ clean-java-linker: # === Library Shim Metadata Generator === $(SHIM_METADATA_GEN_DIR)/core.json: library - @echo "$(CYAN)🛠️ Generating library shim metadata...$(RESET)" - cd $(SHIM_METADATA_GEN_DIR) && cargo run -- ../$(LIBRARY_JAR) ./core.json + @if [ "$(IS_CI)" = "1" ]; then \ + echo "$(CYAN)CI mode: skipping shim-metadata-gen$(RESET)"; \ + elif [ -f $@ ]; then \ + echo "$(CYAN)core.json already exists, skipping shim-metadata-gen$(RESET)"; \ + else \ + echo "$(CYAN)🛠️ Generating library shim metadata...$(RESET)"; \ + cd $(SHIM_METADATA_GEN_DIR) && cargo run -- ../$(LIBRARY_JAR) ./core.json; \ + fi clean-shim-metadata-gen: @echo "$(CYAN)🧹 Cleaning shim-metadata-gen...$(RESET)" @@ -88,7 +106,7 @@ clean-library: @echo "$(CYAN)🧹 Cleaning library shim...$(RESET)" cd $(LIBRARY_DIR) && gradle clean -# === Generate files from templates == +# === Generate files from templates === gen-files: clean-gen-files @echo "$(CYAN)🛠️ Generating files from templates...$(RESET)" python3 GenerateFiles.py From 40f51bc5d96e113788182ba0473218de0003f31b Mon Sep 17 00:00:00 2001 From: MolecularPilot Date: Fri, 11 Apr 2025 16:58:48 +1000 Subject: [PATCH 2/2] refactor CI configuration for improved clarity and performance --- .github/workflows/ci.yml | 20 ++++++++++++-------- Makefile | 24 ++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index abc83ff..a8df3f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,11 +20,7 @@ jobs: uses: dtolnay/rust-toolchain@stable with: toolchain: nightly - components: rustc-dev llvm-tools, cargo - - # 3. Cargo Caching (Crucial for speed) - - name: Cache cargo dependencies - uses: Swatinem/rust-cache@v2 + components: rustc-dev llvm-tools cargo # 4. Set up Java - name: Set up Java @@ -39,14 +35,22 @@ jobs: with: python-version: '3.x' - # 6. Set up Gradle) + # 6. Set up Gradle - name: Set up Gradle uses: gradle/actions/setup-gradle@v4 - # 7. Build using the CI-specific make target + # 7. Make just the files needed to cargo cache + - name: Make Gen Files + run: make gen-files + + # 8. Cargo Caching (Crucial for speed) + - name: Cache cargo dependencies + uses: Swatinem/rust-cache@v2 + + # 9. Build using the CI-specific make target - name: Build CI Target run: make ci # Use your optimized CI build command - # 8. Run tests + # 10. Run tests - name: Run integration tests run: python3 Tester.py \ No newline at end of file diff --git a/Makefile b/Makefile index 38a1fd2..cd2cccf 100644 --- a/Makefile +++ b/Makefile @@ -16,11 +16,15 @@ LIBRARY_DIR := library LIBRARY_JAR := $(LIBRARY_DIR)/build/libs/library-0.1.0.jar # === Default Target === +ifeq ($(IS_CI),1) +all: rust java-linker asm-processor + @echo "$(GREEN)✨ Build complete in CI mode! ✨$(RESET)" +else all: rust gen-files java-linker asm-processor @echo "$(GREEN)✨ Build complete! ✨$(RESET)" +endif # === CI Target === -# Running "make ci" sets IS_CI=1 and then behaves exactly like "make all" ci: $(MAKE) all IS_CI=1 @@ -89,22 +93,38 @@ clean-shim-metadata-gen: # === ASM Processor (Gradle) === asm-processor: @echo "$(CYAN)⚙️ Building ASM processor...$(RESET)" +ifeq ($(IS_CI),1) + cd $(ASM_PROCESSOR_DIR) && gradle --no-daemon shadowJar +else cd $(ASM_PROCESSOR_DIR) && gradle shadowJar +endif clean-asm-processor: @echo "$(CYAN)🧹 Cleaning ASM processor...$(RESET)" +ifeq ($(IS_CI),1) + cd $(ASM_PROCESSOR_DIR) && gradle --no-daemon clean +else cd $(ASM_PROCESSOR_DIR) && gradle clean +endif # === Standard Library Shim (Gradle) === library: $(LIBRARY_JAR) $(LIBRARY_JAR): @echo "$(CYAN)📚 Building standard library shim...$(RESET)" +ifeq ($(IS_CI),1) + cd $(LIBRARY_DIR) && gradle --no-daemon build && cd build/distributions && unzip -o library-0.1.0.zip +else cd $(LIBRARY_DIR) && gradle build && cd build/distributions && unzip -o library-0.1.0.zip +endif clean-library: @echo "$(CYAN)🧹 Cleaning library shim...$(RESET)" +ifeq ($(IS_CI),1) + cd $(LIBRARY_DIR) && gradle --no-daemon clean +else cd $(LIBRARY_DIR) && gradle clean +endif # === Generate files from templates === gen-files: clean-gen-files @@ -118,4 +138,4 @@ clean-gen-files: # === Clean All === clean: clean-rust clean-java-linker clean-asm-processor clean-library clean-shim-metadata-gen clean-gen-files - @echo "$(GREEN)🧼 All clean!$(RESET)" + @echo "$(GREEN)🧼 All clean!$(RESET)" \ No newline at end of file