Skip to content

Commit 8ad7a6c

Browse files
authored
Merge pull request #2 from keaz/copilot/fix-ci-build-issue-macos
Fix macOS CI build by ensuring environment variables are available to cargo build
2 parents 8d2fdef + e60b5c5 commit 8ad7a6c

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,24 @@ jobs:
104104
run: rustup target add ${{ matrix.target }}
105105

106106
- name: Build with Cargo
107+
env:
108+
OPENSSL_DIR: ${{ env.OPENSSL_DIR }}
109+
PKG_CONFIG_PATH: ${{ env.PKG_CONFIG_PATH }}
110+
LDFLAGS: ${{ env.LDFLAGS }}
111+
CPPFLAGS: ${{ env.CPPFLAGS }}
107112
run: |
108113
if [[ "${{ matrix.os }}" == "macos-latest" ]]; then
109114
# Set additional environment variables for macOS build
110115
export MACOSX_DEPLOYMENT_TARGET=10.15
111116
export CC=clang
112117
export CXX=clang++
113118
119+
# Debug: Print environment variables
120+
echo "OPENSSL_DIR: $OPENSSL_DIR"
121+
echo "PKG_CONFIG_PATH: $PKG_CONFIG_PATH"
122+
echo "LDFLAGS: $LDFLAGS"
123+
echo "CPPFLAGS: $CPPFLAGS"
124+
114125
# Build for x86_64 only for now to test the fix
115126
echo "Building for x86_64 macOS target..."
116127
cargo build --release --target ${{ matrix.target_x86 }}

CI_MACOS_FIX.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# macOS CI Build Fix
2+
3+
## Problem
4+
The GitHub Actions CI workflow (`ci.yml`) was failing when building for macOS. The issue was that environment variables needed for building the rdkafka Rust crate with its native dependencies were not being properly propagated to the cargo build step.
5+
6+
## Root Cause
7+
While the "Install dependencies on macOS" step correctly set environment variables like `OPENSSL_DIR`, `PKG_CONFIG_PATH`, `LDFLAGS`, and `CPPFLAGS` and added them to `$GITHUB_ENV`, these variables needed to be explicitly available during the cargo build process. The rdkafka-sys crate's build script requires these variables to locate OpenSSL and librdkafka during compilation.
8+
9+
## Solution
10+
Added an explicit `env:` block to the "Build with Cargo" step that references the environment variables set in previous steps:
11+
12+
```yaml
13+
- name: Build with Cargo
14+
env:
15+
OPENSSL_DIR: ${{ env.OPENSSL_DIR }}
16+
PKG_CONFIG_PATH: ${{ env.PKG_CONFIG_PATH }}
17+
LDFLAGS: ${{ env.LDFLAGS }}
18+
CPPFLAGS: ${{ env.CPPFLAGS }}
19+
run: |
20+
# ... build commands
21+
```
22+
23+
This ensures that:
24+
1. `OPENSSL_DIR` - Points to the OpenSSL installation (required by openssl-sys crate)
25+
2. `PKG_CONFIG_PATH` - Tells pkg-config where to find .pc files for OpenSSL, librdkafka, zstd, and lz4
26+
3. `LDFLAGS` - Tells the linker where to find the shared libraries
27+
4. `CPPFLAGS` - Tells the C compiler where to find header files
28+
29+
## Additional Improvements
30+
Added debug output to print the environment variable values during the build, which will help with troubleshooting if similar issues arise in the future.
31+
32+
## Testing
33+
The fix should be validated by running the CI workflow on a push to the main branch or by creating a tag. The workflow will:
34+
1. Install dependencies via Homebrew
35+
2. Set environment variables
36+
3. Verify dependencies are installed correctly
37+
4. Build the project with the environment variables properly set
38+
5. Create release artifacts
39+
40+
## References
41+
- CLAUDE.md - Documents the required environment variables for macOS builds
42+
- `.github/workflows/ci.yml` - The updated CI workflow file

0 commit comments

Comments
 (0)