Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes CI workflow configuration #195

Merged
merged 4 commits into from
Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
67 changes: 39 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
php: ['8.0', '8.1']
php: ["8.0", "8.1"]
rust: [stable, nightly]
clang: ["14"]
phpts: [ts, nts]
exclude:
# ext-php-rs requires nightly Rust when on Windows.
Expand All @@ -24,6 +25,8 @@ jobs:
phpts: ts
- os: ubuntu-latest
phpts: ts
env:
CARGO_TERM_COLOR: always
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -34,59 +37,67 @@ jobs:
env:
phpts: ${{ matrix.phpts }}
- name: Setup Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
override: true
components: rustfmt, clippy
- name: Setup LLVM & Clang
- run: rustup show
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@v2
# Uncomment the following if statement if caching nightly deps
# ends up causing too much cache invalidation.
# if: matrix.rust == 'stable'
with:
# increment this manually to force cache eviction
prefix-key: "v0-rust"
# LLVM & Clang
- name: Cache LLVM and Clang
id: cache-llvm
uses: actions/cache@v2
ju1ius marked this conversation as resolved.
Show resolved Hide resolved
if: "!contains(matrix.os, 'windows')"
with:
path: ${{ runner.temp }}/llvm-${{ matrix.clang }}
key: ${{ matrix.os }}-llvm-${{ matrix.clang }}
- name: Setup LLVM & Clang
id: clang
uses: KyleMayes/install-llvm-action@v1
if: "!contains(matrix.os, 'windows')"
with:
version: '13.0'
directory: ${{ runner.temp }}/llvm
version: ${{ matrix.clang }}
directory: ${{ runner.temp }}/llvm-${{ matrix.clang }}
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
- name: Configure Clang
if: "!contains(matrix.os, 'windows')"
run: |
echo "LIBCLANG_PATH=${{ runner.temp }}/llvm/lib" >> $GITHUB_ENV
echo "LIBCLANG_PATH=${{ runner.temp }}/llvm-${{ matrix.clang }}/lib" >> $GITHUB_ENV
echo "LLVM_VERSION=${{ steps.clang.outputs.version }}" >> $GITHUB_ENV
echo "LLVM_CONFIG_PATH=${{ runner.temp }}/llvm-${{ matrix.clang }}/bin/llvm-config" >> $GITHUB_ENV
- name: Configure Clang (macOS only)
if: "contains(matrix.os, 'macos')"
run: echo "SDKROOT=$(xcrun --show-sdk-path)" >> $GITHUB_ENV
# Build
- name: Build
env:
EXT_PHP_RS_TEST:
EXT_PHP_RS_TEST: ""
run: cargo build --release --all-features --all
# Test & lint
- name: Test inline examples
uses: actions-rs/cargo@v1
with:
command: test
args: --release --all --all-features
run: cargo test --release --all --all-features
- name: Run rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.1'
run: cargo fmt --all -- --check
- name: Run clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all -- -D warnings
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.1'
run: cargo clippy --all -- -D warnings
# Docs
- name: Run rustdoc
uses: actions-rs/cargo@v1
with:
command: rustdoc
args: -- -D warnings
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.1'
run: cargo rustdoc -- -D warnings
- name: Build with docs stub
env:
DOCS_RS:
run:
cargo clean && cargo build
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.1'
env:
DOCS_RS: ""
run: cargo clean && cargo build
build-zts:
name: Build with ZTS
runs-on: ubuntu-latest
Expand Down
26 changes: 18 additions & 8 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,38 @@ on:
jobs:
docs:
name: Build and Deploy
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest"]
php: ["8.0"]
clang: ["14"]
mdbook: ["latest"]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: ${{ matrix.php }}
- name: Setup Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@nightly
- name: Cache LLVM and Clang
id: cache-llvm
uses: actions/cache@v2
with:
toolchain: nightly
override: true
path: ${{ runner.temp }}/llvm-${{ matrix.clang }}
key: ${{ matrix.os }}-llvm-${{ matrix.clang }}
- name: Setup LLVM & Clang
uses: KyleMayes/install-llvm-action@v1
with:
version: 11.0
directory: ${{ runner.temp }}/llvm-11.0
version: ${{ matrix.clang }}
directory: ${{ runner.temp }}/llvm-${{ matrix.clang }}
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
- name: Install mdbook
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: latest
mdbook-version: ${{ matrix.mdbook }}
- name: Build guide
run: mdbook build guide
- name: Publish docs
Expand Down
12 changes: 8 additions & 4 deletions src/types/zval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ impl Zval {
}

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

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