Skip to content

Commit 9a105ab

Browse files
authored
fixes CI workflow configuration (#195)
* upgrades LLVM to v14 * migrates from the unmaintained `action-rs/*` actions to [dtolnay/rust-toolchain](https://github.com/dtolnay/rust-toolchain), using [Swatinem/rust-cache](https://github.com/Swatinem/rust-cache/) as a cache layer. * adds a cache layer for LLVM build * adds a weekly cron schedule for all workflows * fixes an issue in the docblocks
1 parent 8d2ad7d commit 9a105ab

File tree

3 files changed

+71
-40
lines changed

3 files changed

+71
-40
lines changed

.github/workflows/build.yml

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: Build and Lint
22
on:
3+
schedule:
4+
# runs every monday at midnight
5+
- cron: "0 0 * * 1"
36
push:
47
branches:
58
- master
@@ -12,8 +15,9 @@ jobs:
1215
strategy:
1316
matrix:
1417
os: [ubuntu-latest, macos-latest, windows-latest]
15-
php: ['8.0', '8.1']
18+
php: ["8.0", "8.1"]
1619
rust: [stable, nightly]
20+
clang: ["14"]
1721
phpts: [ts, nts]
1822
exclude:
1923
# ext-php-rs requires nightly Rust when on Windows.
@@ -24,6 +28,8 @@ jobs:
2428
phpts: ts
2529
- os: ubuntu-latest
2630
phpts: ts
31+
env:
32+
CARGO_TERM_COLOR: always
2733
steps:
2834
- name: Checkout code
2935
uses: actions/checkout@v3
@@ -34,59 +40,67 @@ jobs:
3440
env:
3541
phpts: ${{ matrix.phpts }}
3642
- name: Setup Rust
37-
uses: actions-rs/toolchain@v1
43+
uses: dtolnay/rust-toolchain@master
3844
with:
3945
toolchain: ${{ matrix.rust }}
40-
override: true
4146
components: rustfmt, clippy
42-
- name: Setup LLVM & Clang
47+
- run: rustup show
48+
- name: Cache cargo dependencies
49+
uses: Swatinem/rust-cache@v2
50+
# Uncomment the following if statement if caching nightly deps
51+
# ends up causing too much cache invalidation.
52+
# if: matrix.rust == 'stable'
53+
with:
54+
# increment this manually to force cache eviction
55+
prefix-key: "v0-rust"
56+
# LLVM & Clang
57+
- name: Cache LLVM and Clang
58+
id: cache-llvm
59+
uses: actions/cache@v3
4360
if: "!contains(matrix.os, 'windows')"
61+
with:
62+
path: ${{ runner.temp }}/llvm-${{ matrix.clang }}
63+
key: ${{ matrix.os }}-llvm-${{ matrix.clang }}
64+
- name: Setup LLVM & Clang
4465
id: clang
4566
uses: KyleMayes/install-llvm-action@v1
67+
if: "!contains(matrix.os, 'windows')"
4668
with:
47-
version: '13.0'
48-
directory: ${{ runner.temp }}/llvm
69+
version: ${{ matrix.clang }}
70+
directory: ${{ runner.temp }}/llvm-${{ matrix.clang }}
71+
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
4972
- name: Configure Clang
5073
if: "!contains(matrix.os, 'windows')"
5174
run: |
52-
echo "LIBCLANG_PATH=${{ runner.temp }}/llvm/lib" >> $GITHUB_ENV
75+
echo "LIBCLANG_PATH=${{ runner.temp }}/llvm-${{ matrix.clang }}/lib" >> $GITHUB_ENV
5376
echo "LLVM_VERSION=${{ steps.clang.outputs.version }}" >> $GITHUB_ENV
77+
echo "LLVM_CONFIG_PATH=${{ runner.temp }}/llvm-${{ matrix.clang }}/bin/llvm-config" >> $GITHUB_ENV
5478
- name: Configure Clang (macOS only)
5579
if: "contains(matrix.os, 'macos')"
5680
run: echo "SDKROOT=$(xcrun --show-sdk-path)" >> $GITHUB_ENV
81+
# Build
5782
- name: Build
5883
env:
59-
EXT_PHP_RS_TEST:
84+
EXT_PHP_RS_TEST: ""
6085
run: cargo build --release --all-features --all
86+
# Test & lint
6187
- name: Test inline examples
62-
uses: actions-rs/cargo@v1
63-
with:
64-
command: test
65-
args: --release --all --all-features
88+
run: cargo test --release --all --all-features
6689
- name: Run rustfmt
67-
uses: actions-rs/cargo@v1
68-
with:
69-
command: fmt
70-
args: --all -- --check
7190
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.1'
91+
run: cargo fmt --all -- --check
7292
- name: Run clippy
73-
uses: actions-rs/cargo@v1
74-
with:
75-
command: clippy
76-
args: --all -- -D warnings
7793
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.1'
94+
run: cargo clippy --all -- -D warnings
95+
# Docs
7896
- name: Run rustdoc
79-
uses: actions-rs/cargo@v1
80-
with:
81-
command: rustdoc
82-
args: -- -D warnings
8397
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.1'
98+
run: cargo rustdoc -- -D warnings
8499
- name: Build with docs stub
85-
env:
86-
DOCS_RS:
87-
run:
88-
cargo clean && cargo build
89100
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.1'
101+
env:
102+
DOCS_RS: ""
103+
run: cargo clean && cargo build
90104
build-zts:
91105
name: Build with ZTS
92106
runs-on: ubuntu-latest

.github/workflows/docs.yml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,48 @@
11
name: Deploy documentation
22
on:
33
workflow_dispatch:
4+
# runs every monday at midnight
5+
schedule:
6+
- cron: "0 0 * * 1"
47
push:
58
branches:
69
- master
710

811
jobs:
912
docs:
1013
name: Build and Deploy
11-
runs-on: ubuntu-latest
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
os: ["ubuntu-latest"]
18+
php: ["8.0"]
19+
clang: ["14"]
20+
mdbook: ["latest"]
1221
steps:
1322
- name: Checkout code
1423
uses: actions/checkout@v3
1524
- name: Setup PHP
1625
uses: shivammathur/setup-php@v2
1726
with:
18-
php-version: 8.0
27+
php-version: ${{ matrix.php }}
1928
- name: Setup Rust
20-
uses: actions-rs/toolchain@v1
29+
uses: dtolnay/rust-toolchain@nightly
30+
- name: Cache LLVM and Clang
31+
id: cache-llvm
32+
uses: actions/cache@v3
2133
with:
22-
toolchain: nightly
23-
override: true
34+
path: ${{ runner.temp }}/llvm-${{ matrix.clang }}
35+
key: ${{ matrix.os }}-llvm-${{ matrix.clang }}
2436
- name: Setup LLVM & Clang
2537
uses: KyleMayes/install-llvm-action@v1
2638
with:
27-
version: 11.0
28-
directory: ${{ runner.temp }}/llvm-11.0
39+
version: ${{ matrix.clang }}
40+
directory: ${{ runner.temp }}/llvm-${{ matrix.clang }}
41+
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
2942
- name: Install mdbook
3043
uses: peaceiris/actions-mdbook@v1
3144
with:
32-
mdbook-version: latest
45+
mdbook-version: ${{ matrix.mdbook }}
3346
- name: Build guide
3447
run: mdbook build guide
3548
- name: Publish docs

src/types/zval.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ impl Zval {
117117
}
118118

119119
/// Returns the value of the zval if it is a string and can be unpacked into
120-
/// a vector of a given type. Similar to the [`unpack`](https://www.php.net/manual/en/function.unpack.php)
121-
/// in PHP, except you can only unpack one type.
120+
/// a vector of a given type. Similar to the [`unpack`] function in PHP,
121+
/// except you can only unpack one type.
122122
///
123123
/// # Safety
124124
///
@@ -129,13 +129,14 @@ impl Zval {
129129
/// documentation for more details.
130130
///
131131
/// [`pack`]: https://www.php.net/manual/en/function.pack.php
132+
/// [`unpack`]: https://www.php.net/manual/en/function.unpack.php
132133
pub fn binary<T: Pack>(&self) -> Option<Vec<T>> {
133134
self.zend_str().map(T::unpack_into)
134135
}
135136

136137
/// Returns the value of the zval if it is a string and can be unpacked into
137-
/// a slice of a given type. Similar to the [`unpack`](https://www.php.net/manual/en/function.unpack.php)
138-
/// in PHP, except you can only unpack one type.
138+
/// a slice of a given type. Similar to the [`unpack`] function in PHP,
139+
/// except you can only unpack one type.
139140
///
140141
/// This function is similar to [`Zval::binary`] except that a slice is
141142
/// returned instead of a vector, meaning the contents of the string is
@@ -148,6 +149,9 @@ impl Zval {
148149
/// platform-to-platform due to the different representation of some
149150
/// types on different platforms. Consult the [`pack`] function
150151
/// documentation for more details.
152+
///
153+
/// [`pack`]: https://www.php.net/manual/en/function.pack.php
154+
/// [`unpack`]: https://www.php.net/manual/en/function.unpack.php
151155
pub fn binary_slice<T: PackSlice>(&self) -> Option<&[T]> {
152156
self.zend_str().map(T::unpack_into)
153157
}

0 commit comments

Comments
 (0)