Skip to content

Commit 75153b3

Browse files
Merge pull request #7 from IntegralPilot/ci2
Improve CI speed
2 parents a6bed76 + 40f51bc commit 75153b3

File tree

2 files changed

+68
-25
lines changed

2 files changed

+68
-25
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,46 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14+
# 1. Checkout Code
1415
- name: Checkout repository
15-
uses: actions/checkout@v3
16+
uses: actions/checkout@v4
1617

18+
# 2. Set up Rust
1719
- name: Set up Rust (nightly)
18-
uses: actions-rs/toolchain@v1
20+
uses: dtolnay/rust-toolchain@stable
1921
with:
2022
toolchain: nightly
21-
override: true
22-
components: rustc, rust-src, cargo
23+
components: rustc-dev llvm-tools cargo
2324

25+
# 4. Set up Java
2426
- name: Set up Java
25-
uses: actions/setup-java@v3
27+
uses: actions/setup-java@v4
2628
with:
2729
distribution: 'temurin'
2830
java-version: '21'
2931

32+
# 5. Set up Python
3033
- name: Set up Python
31-
uses: actions/setup-python@v4
34+
uses: actions/setup-python@v5
3235
with:
3336
python-version: '3.x'
3437

38+
# 6. Set up Gradle
3539
- name: Set up Gradle
3640
uses: gradle/actions/setup-gradle@v4
3741

38-
- name: Install dependencies
39-
run: |
40-
sudo apt-get update
41-
sudo apt-get install -y make
42-
43-
- name: Build all components
44-
run: make all
45-
42+
# 7. Make just the files needed to cargo cache
43+
- name: Make Gen Files
44+
run: make gen-files
45+
46+
# 8. Cargo Caching (Crucial for speed)
47+
- name: Cache cargo dependencies
48+
uses: Swatinem/rust-cache@v2
49+
50+
# 9. Build using the CI-specific make target
51+
- name: Build CI Target
52+
run: make ci # Use your optimized CI build command
53+
54+
# 10. Run tests
4655
- name: Run integration tests
47-
run: python3 Tester.py
48-
49-
- name: Cleanup
50-
if: always() # Ensure cleanup runs even if previous steps failed
51-
run: make clean
56+
run: python3 Tester.py

Makefile

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# === Phony Targets ===
22
.PHONY: all help clean rust-components rust clean-rust java-linker clean-java-linker \
33
shim-metadata-gen clean-shim-metadata-gen asm-processor clean-asm-processor \
4-
library clean-library gen-files clean-gen-files
4+
library clean-library gen-files clean-gen-files ci
55

66
# === Terminal Colors ===
77
GREEN := \033[1;32m
@@ -16,15 +16,25 @@ LIBRARY_DIR := library
1616
LIBRARY_JAR := $(LIBRARY_DIR)/build/libs/library-0.1.0.jar
1717

1818
# === Default Target ===
19+
ifeq ($(IS_CI),1)
20+
all: rust java-linker asm-processor
21+
@echo "$(GREEN)✨ Build complete in CI mode! ✨$(RESET)"
22+
else
1923
all: rust gen-files java-linker asm-processor
2024
@echo "$(GREEN)✨ Build complete! ✨$(RESET)"
25+
endif
26+
27+
# === CI Target ===
28+
ci:
29+
$(MAKE) all IS_CI=1
2130

2231
# === Help ===
2332
help:
2433
@echo "$(CYAN)🛠️ Makefile for building the project$(RESET)"
2534
@echo ""
2635
@echo "Available targets:"
2736
@echo " make all - Build all components"
37+
@echo " make ci - Build all components in CI mode (skips rust-components and shim-metadata-gen)"
2838
@echo " make clean - Clean all components"
2939
@echo " make rust-components - Install needed Rust components"
3040
@echo " make rust - Build the Rust root project"
@@ -38,12 +48,18 @@ help:
3848
# === Needed rust components ===
3949
rust-components:
4050
@echo "$(CYAN)🔧 Installing Rust components...$(RESET)"
41-
rustup component add rust-src rustc-dev llvm-tools-preview
51+
rustup component add rustc-dev llvm-tools
4252

4353
# === Rust root project (Cargo) ===
54+
ifeq ($(IS_CI),1)
55+
rust: $(SHIM_METADATA_GEN_DIR)/core.json
56+
@echo "$(CYAN)📦 Building Rust root project...$(RESET)"
57+
cargo build
58+
else
4459
rust: $(SHIM_METADATA_GEN_DIR)/core.json rust-components
4560
@echo "$(CYAN)📦 Building Rust root project...$(RESET)"
4661
cargo build
62+
endif
4763

4864
clean-rust:
4965
@echo "$(CYAN)🧹 Cleaning Rust root project...$(RESET)"
@@ -60,8 +76,14 @@ clean-java-linker:
6076

6177
# === Library Shim Metadata Generator ===
6278
$(SHIM_METADATA_GEN_DIR)/core.json: library
63-
@echo "$(CYAN)🛠️ Generating library shim metadata...$(RESET)"
64-
cd $(SHIM_METADATA_GEN_DIR) && cargo run -- ../$(LIBRARY_JAR) ./core.json
79+
@if [ "$(IS_CI)" = "1" ]; then \
80+
echo "$(CYAN)CI mode: skipping shim-metadata-gen$(RESET)"; \
81+
elif [ -f $@ ]; then \
82+
echo "$(CYAN)core.json already exists, skipping shim-metadata-gen$(RESET)"; \
83+
else \
84+
echo "$(CYAN)🛠️ Generating library shim metadata...$(RESET)"; \
85+
cd $(SHIM_METADATA_GEN_DIR) && cargo run -- ../$(LIBRARY_JAR) ./core.json; \
86+
fi
6587

6688
clean-shim-metadata-gen:
6789
@echo "$(CYAN)🧹 Cleaning shim-metadata-gen...$(RESET)"
@@ -71,24 +93,40 @@ clean-shim-metadata-gen:
7193
# === ASM Processor (Gradle) ===
7294
asm-processor:
7395
@echo "$(CYAN)⚙️ Building ASM processor...$(RESET)"
96+
ifeq ($(IS_CI),1)
97+
cd $(ASM_PROCESSOR_DIR) && gradle --no-daemon shadowJar
98+
else
7499
cd $(ASM_PROCESSOR_DIR) && gradle shadowJar
100+
endif
75101

76102
clean-asm-processor:
77103
@echo "$(CYAN)🧹 Cleaning ASM processor...$(RESET)"
104+
ifeq ($(IS_CI),1)
105+
cd $(ASM_PROCESSOR_DIR) && gradle --no-daemon clean
106+
else
78107
cd $(ASM_PROCESSOR_DIR) && gradle clean
108+
endif
79109

80110
# === Standard Library Shim (Gradle) ===
81111
library: $(LIBRARY_JAR)
82112

83113
$(LIBRARY_JAR):
84114
@echo "$(CYAN)📚 Building standard library shim...$(RESET)"
115+
ifeq ($(IS_CI),1)
116+
cd $(LIBRARY_DIR) && gradle --no-daemon build && cd build/distributions && unzip -o library-0.1.0.zip
117+
else
85118
cd $(LIBRARY_DIR) && gradle build && cd build/distributions && unzip -o library-0.1.0.zip
119+
endif
86120

87121
clean-library:
88122
@echo "$(CYAN)🧹 Cleaning library shim...$(RESET)"
123+
ifeq ($(IS_CI),1)
124+
cd $(LIBRARY_DIR) && gradle --no-daemon clean
125+
else
89126
cd $(LIBRARY_DIR) && gradle clean
127+
endif
90128

91-
# === Generate files from templates ==
129+
# === Generate files from templates ===
92130
gen-files: clean-gen-files
93131
@echo "$(CYAN)🛠️ Generating files from templates...$(RESET)"
94132
python3 GenerateFiles.py
@@ -100,4 +138,4 @@ clean-gen-files:
100138

101139
# === Clean All ===
102140
clean: clean-rust clean-java-linker clean-asm-processor clean-library clean-shim-metadata-gen clean-gen-files
103-
@echo "$(GREEN)🧼 All clean!$(RESET)"
141+
@echo "$(GREEN)🧼 All clean!$(RESET)"

0 commit comments

Comments
 (0)