Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 35 additions & 25 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,32 @@ jobs:
restore-keys: |
rust-build-${{ runner.os }}-

- name: Compile Rust code
run: make compile
- name: Compile C code
run: make compile_c

- name: Compile Rust code (Linux Lambda target)
run: cargo build --release --target x86_64-unknown-linux-gnu --manifest-path smartscore/Rust/make_predictions/Cargo.toml

- name: Install compiled Rust module into venv
run: |
SITE_PACKAGES=$(find .venv -type d -name site-packages | head -1)
cp smartscore/Rust/make_predictions/target/x86_64-unknown-linux-gnu/release/libmake_predictions_rust.so \
"$SITE_PACKAGES/make_predictions_rust.so"
uv run python -c "import make_predictions_rust; print('make_predictions_rust import OK')"

- name: Stage build artifacts
run: |
mkdir -p build_artifacts/smartscore/Rust/make_predictions/target/x86_64-unknown-linux-gnu/release
cp smartscore/compiled_code.so build_artifacts/smartscore/compiled_code.so
cp smartscore/Rust/make_predictions/target/x86_64-unknown-linux-gnu/release/libmake_predictions_rust.so \
build_artifacts/smartscore/Rust/make_predictions/target/x86_64-unknown-linux-gnu/release/libmake_predictions_rust.so

- name: Upload build artifacts
uses: actions/upload-artifact@v5
with:
name: build-artifacts
path: |
smartscore/Rust/make_predictions/target/release/*.dll
smartscore/Rust/make_predictions/target/release/*.so
smartscore/Rust/make_predictions/target/release/*.dylib
path: build_artifacts/
if-no-files-found: error
retention-days: 1

lint:
Expand Down Expand Up @@ -89,11 +104,6 @@ jobs:
- name: Install dependencies
run: uv sync --all-groups

- name: Download build artifacts
uses: actions/download-artifact@v6
with:
name: build-artifacts

- name: Run lint
run: uv run make lint

Expand Down Expand Up @@ -122,17 +132,16 @@ jobs:
- name: Install dependencies
run: uv sync --all-groups

- name: Cache Rust build
uses: actions/cache@v4
- name: Download build artifacts
uses: actions/download-artifact@v6
with:
path: |
smartscore/Rust/make_predictions/target
key: rust-build-${{ runner.os }}-${{ hashFiles('smartscore/Rust/make_predictions/Cargo.lock') }}
restore-keys: |
rust-build-${{ runner.os }}-
name: build-artifacts

- name: Compile Rust code
run: make compile_rust
- name: Install compiled Rust module into venv
run: |
SITE_PACKAGES=$(find .venv -type d -name site-packages | head -1)
cp smartscore/Rust/make_predictions/target/x86_64-unknown-linux-gnu/release/libmake_predictions_rust.so \
"$SITE_PACKAGES/make_predictions_rust.so"

- name: Run tests
run: make test
Expand All @@ -149,6 +158,7 @@ jobs:
env_was_dev: ${{ steps.env-detect.outputs.is_dev }}
env:
ENV: ${{ github.ref == 'refs/heads/main' && 'prod' || 'dev' }}
DEPLOY_SKIP_BUILD: "1"
steps:
- name: Detect environment
id: env-detect
Expand All @@ -157,11 +167,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v6

- name: Install build tools
run: |
sudo apt-get update
sudo apt-get install -y build-essential # Install gcc and make

- name: Set up Python
uses: actions/setup-python@v6
with:
Expand All @@ -173,6 +178,11 @@ jobs:
- name: Install dependencies
run: uv sync --no-dev

- name: Download build artifacts
uses: actions/download-artifact@v6
with:
name: build-artifacts

- name: Set environment variables
run: |
echo "SUPABASE_URL=${{ secrets.SUPABASE_URL }}" >> $GITHUB_ENV
Expand Down
37 changes: 24 additions & 13 deletions build_scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -280,20 +280,31 @@ if [ $? -ne 0 ]; then
fi
rm -f $OUTPUT_DIR/requirements.txt

# compile C code
echo "Compiling C code..."
sh build_scripts/compile.sh
if [ $? -ne 0 ]; then
echo "Error: Compilation failed. Ensure docker is running."
exit 1
fi
# compile C and Rust. When the CI "setup" job has already built the artifacts
# (see DEPLOY_SKIP_BUILD in .github/workflows/deploy.yml), reuse them instead.
if [ "${DEPLOY_SKIP_BUILD:-0}" = "1" ]; then
if [ ! -f "$SOURCE_DIR/compiled_code.so" ] || \
[ ! -f "$SOURCE_DIR/Rust/make_predictions/target/x86_64-unknown-linux-gnu/release/libmake_predictions_rust.so" ]; then
echo "Error: DEPLOY_SKIP_BUILD is set but prebuilt artifacts are missing (compile in setup first)."
exit 1
fi
echo "Skipping C/Rust compilation (reusing artifacts from CI setup job)..."
else
# compile C code
echo "Compiling C code..."
sh build_scripts/compile.sh
if [ $? -ne 0 ]; then
echo "Error: Compilation failed. Ensure docker is running."
exit 1
fi

# compile Rust code
echo "Compiling Rust code..."
sh build_scripts/rust_compile.sh
if [ $? -ne 0 ]; then
echo "Error: Compilation failed. Ensure docker is running."
exit 1
# compile Rust code
echo "Compiling Rust code..."
sh build_scripts/rust_compile.sh
if [ $? -ne 0 ]; then
echo "Error: Compilation failed. Ensure docker is running."
exit 1
fi
fi

# update the code
Expand Down
Loading