Skip to content

Commit 6af2167

Browse files
committed
fix: lib detection in tests
1 parent 9a01330 commit 6af2167

File tree

2 files changed

+40
-42
lines changed

2 files changed

+40
-42
lines changed

.github/workflows/build.yml

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,23 @@ jobs:
1818
env:
1919
CARGO_TARGET_DIR: target/ci/lint
2020
steps:
21-
- name: Checkout
22-
uses: actions/checkout@v4
21+
- uses: actions/checkout@v4
2322

2423
- name: Install Rust toolchain
2524
uses: dtolnay/rust-toolchain@stable
2625
with:
2726
toolchain: ${{ env.RUST_VERSION }}
2827

29-
- name: Cache cargo registry & binaries
28+
- name: Cache cargo registry & target
3029
uses: actions/cache@v4
3130
with:
3231
path: |
3332
~/.cargo/registry
3433
~/.cargo/git
3534
target/ci/lint
36-
key: ${{ runner.os }}-lint-cargo-${{ hashFiles('**/Cargo.lock') }}
35+
key: ${{ runner.os }}-lint-${{ hashFiles('**/Cargo.lock') }}
3736
restore-keys: |
38-
${{ runner.os }}-lint-cargo-
37+
${{ runner.os }}-lint-
3938
4039
- name: Install components
4140
run: |
@@ -51,15 +50,14 @@ jobs:
5150
tests:
5251
runs-on: ubuntu-latest
5352
needs: lint
54-
env:
55-
CARGO_TARGET_DIR: target/ci/tests-${{ matrix.php }}
5653
strategy:
5754
fail-fast: false
5855
matrix:
5956
php: ['8.2', '8.3', '8.4']
57+
env:
58+
CARGO_TARGET_DIR: target/ci/tests-${{ matrix.php }}
6059
steps:
61-
- name: Checkout
62-
uses: actions/checkout@v4
60+
- uses: actions/checkout@v4
6361

6462
- name: Install system dependencies
6563
run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config docker-compose zip
@@ -87,21 +85,21 @@ jobs:
8785
~/.cargo/registry
8886
~/.cargo/git
8987
target/ci/tests-${{ matrix.php }}
90-
key: ${{ runner.os }}-tests-${{ matrix.php }}-cargo-${{ hashFiles('**/Cargo.lock') }}
88+
key: ${{ runner.os }}-tests-${{ matrix.php }}-${{ hashFiles('**/Cargo.lock') }}
9189
restore-keys: |
92-
${{ runner.os }}-tests-${{ matrix.php }}-cargo-
93-
${{ runner.os }}-tests-cargo-
90+
${{ runner.os }}-tests-${{ matrix.php }}-
91+
${{ runner.os }}-tests-
9492
9593
- name: Cache Composer
9694
uses: actions/cache@v4
9795
with:
9896
path: |
9997
~/.cache/composer
10098
php/tests/vendor
101-
key: ${{ runner.os }}-tests-composer-${{ matrix.php }}-${{ hashFiles('php/tests/composer.lock') }}
99+
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('php/tests/composer.lock') }}
102100
restore-keys: |
103-
${{ runner.os }}-tests-composer-${{ matrix.php }}-
104-
${{ runner.os }}-tests-composer-
101+
${{ runner.os }}-composer-${{ matrix.php }}-
102+
${{ runner.os }}-composer-
105103
106104
- name: Install PHP dependencies
107105
working-directory: php/tests
@@ -112,7 +110,7 @@ jobs:
112110
env:
113111
EXT_PHP_RS_PHP_CONFIG: ${{ steps.php.outputs.php_config }}
114112

115-
- name: Cargo build (debug)
113+
- name: Cargo build
116114
run: cargo build
117115
env:
118116
EXT_PHP_RS_PHP_CONFIG: ${{ steps.php.outputs.php_config }}
@@ -125,15 +123,14 @@ jobs:
125123
build-linux:
126124
runs-on: ubuntu-latest
127125
needs: tests
128-
env:
129-
CARGO_TARGET_DIR: target/ci/build-linux-${{ matrix.php }}
130126
strategy:
131127
fail-fast: false
132128
matrix:
133129
php: ['8.2', '8.3', '8.4']
130+
env:
131+
CARGO_TARGET_DIR: target/ci/build-linux-${{ matrix.php }}
134132
steps:
135-
- name: Checkout
136-
uses: actions/checkout@v4
133+
- uses: actions/checkout@v4
137134

138135
- name: Install prerequisites
139136
run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config zip
@@ -161,10 +158,10 @@ jobs:
161158
~/.cargo/registry
162159
~/.cargo/git
163160
target/ci/build-linux-${{ matrix.php }}
164-
key: ${{ runner.os }}-build-linux-${{ matrix.php }}-cargo-${{ hashFiles('**/Cargo.lock') }}
161+
key: ${{ runner.os }}-build-linux-${{ matrix.php }}-${{ hashFiles('**/Cargo.lock') }}
165162
restore-keys: |
166-
${{ runner.os }}-build-linux-${{ matrix.php }}-cargo-
167-
${{ runner.os }}-build-linux-cargo-
163+
${{ runner.os }}-build-linux-${{ matrix.php }}-
164+
${{ runner.os }}-build-linux-
168165
169166
- name: Cargo build (release)
170167
run: cargo build --release --locked
@@ -176,7 +173,7 @@ jobs:
176173
mkdir -p dist
177174
ref="${GITHUB_REF_NAME:-$GITHUB_SHA}"
178175
short="${ref:0:7}"
179-
artifact_path="${CARGO_TARGET_DIR}/release/librabbit_rs.so"
176+
artifact_path="${CARGO_TARGET_DIR%/}/release/librabbit_rs.so"
180177
if [ ! -f "${artifact_path}" ]; then
181178
echo "Artifact not found at ${artifact_path}" >&2
182179
exit 1
@@ -197,15 +194,14 @@ jobs:
197194
build-macos:
198195
runs-on: macos-14
199196
needs: tests
200-
env:
201-
CARGO_TARGET_DIR: target/ci/build-macos-${{ matrix.php }}
202197
strategy:
203198
fail-fast: false
204199
matrix:
205200
php: ['8.2', '8.3', '8.4']
201+
env:
202+
CARGO_TARGET_DIR: target/ci/build-macos-${{ matrix.php }}
206203
steps:
207-
- name: Checkout
208-
uses: actions/checkout@v4
204+
- uses: actions/checkout@v4
209205

210206
- name: Setup PHP
211207
uses: shivammathur/setup-php@v2
@@ -230,10 +226,10 @@ jobs:
230226
~/.cargo/registry
231227
~/.cargo/git
232228
target/ci/build-macos-${{ matrix.php }}
233-
key: ${{ runner.os }}-build-macos-${{ matrix.php }}-cargo-${{ hashFiles('**/Cargo.lock') }}
229+
key: ${{ runner.os }}-build-macos-${{ matrix.php }}-${{ hashFiles('**/Cargo.lock') }}
234230
restore-keys: |
235-
${{ runner.os }}-build-macos-${{ matrix.php }}-cargo-
236-
${{ runner.os }}-build-macos-cargo-
231+
${{ runner.os }}-build-macos-${{ matrix.php }}-
232+
${{ runner.os }}-build-macos-
237233
238234
- name: Cargo build (release)
239235
run: cargo build --release --locked
@@ -245,7 +241,7 @@ jobs:
245241
mkdir -p dist
246242
ref="${GITHUB_REF_NAME:-$GITHUB_SHA}"
247243
short="${ref:0:7}"
248-
artifact_path="${CARGO_TARGET_DIR}/release/librabbit_rs.dylib"
244+
artifact_path="${CARGO_TARGET_DIR%/}/release/librabbit_rs.dylib"
249245
if [ ! -f "${artifact_path}" ]; then
250246
echo "Artifact not found at ${artifact_path}" >&2
251247
exit 1

scripts/common.sh

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,24 +132,26 @@ common::resolve_extension() {
132132
*) ext="so" ;;
133133
esac
134134

135-
local debug_candidate="$root/target/debug/librabbit_rs.${ext}"
136-
local release_candidate="$root/target/release/librabbit_rs.${ext}"
135+
local debug_candidate
136+
local release_candidate
137137

138+
# Honour overridden build output directory first.
138139
if [[ -n "${CARGO_TARGET_DIR:-}" ]]; then
139-
local cargo_dir="${CARGO_TARGET_DIR%/}"
140-
local cargo_debug="$cargo_dir/debug/librabbit_rs.${ext}"
141-
local cargo_release="$cargo_dir/release/librabbit_rs.${ext}"
142-
143-
if [[ -f "$cargo_debug" ]]; then
144-
echo "$cargo_debug"
140+
debug_candidate="${CARGO_TARGET_DIR%/}/debug/librabbit_rs.${ext}"
141+
release_candidate="${CARGO_TARGET_DIR%/}/release/librabbit_rs.${ext}"
142+
if [[ -f "$debug_candidate" ]]; then
143+
echo "$debug_candidate"
145144
return 0
146145
fi
147-
if [[ -f "$cargo_release" ]]; then
148-
echo "$cargo_release"
146+
if [[ -f "$release_candidate" ]]; then
147+
echo "$release_candidate"
149148
return 0
150149
fi
151150
fi
152151

152+
debug_candidate="$root/target/debug/librabbit_rs.${ext}"
153+
release_candidate="$root/target/release/librabbit_rs.${ext}"
154+
153155
if [[ -f "$debug_candidate" ]]; then
154156
echo "$debug_candidate"
155157
return 0

0 commit comments

Comments
 (0)