Skip to content

Fix GitHub release permissions by adding explicit contents: write per… #18

Fix GitHub release permissions by adding explicit contents: write per…

Fix GitHub release permissions by adding explicit contents: write per… #18

Workflow file for this run

name: Build & Test
on:
push:
branches:
- main
- develop
pull_request:
workflow_dispatch:
env:
RUST_VERSION: 1.89.0
CARGO_TERM_COLOR: always
jobs:
lint:
runs-on: ubuntu-latest
env:
CARGO_TARGET_DIR: target/ci/lint
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.RUST_VERSION }}
- name: Cache cargo registry & target
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target/ci/lint
key: ${{ runner.os }}-lint-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-lint-
- name: Install components
run: |
rustup component add rustfmt
rustup component add clippy
- name: cargo fmt
run: cargo fmt --all -- --check
- name: cargo clippy
run: cargo clippy --all-targets --all-features -- -D warnings
tests:
runs-on: ubuntu-latest
needs: lint
strategy:
fail-fast: false
matrix:
php: ['8.2', '8.3', '8.4']
env:
CARGO_TARGET_DIR: target/ci/tests-${{ matrix.php }}
steps:
- uses: actions/checkout@v4
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config docker-compose zip
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: phpize, php-config, composer
coverage: none
- name: Resolve php-config
id: php
run: echo "php_config=$(command -v php-config)" >> "$GITHUB_OUTPUT"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.RUST_VERSION }}
- name: Cache cargo registry & target
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target/ci/tests-${{ matrix.php }}
key: ${{ runner.os }}-tests-${{ matrix.php }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-tests-${{ matrix.php }}-
${{ runner.os }}-tests-
- name: Cache Composer
uses: actions/cache@v4
with:
path: |
~/.cache/composer
php/tests/vendor
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('php/tests/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-${{ matrix.php }}-
${{ runner.os }}-composer-
- name: Install PHP dependencies
working-directory: php/tests
run: composer install --no-interaction --no-progress --prefer-dist
- name: Cargo test
run: cargo test --all
env:
EXT_PHP_RS_PHP_CONFIG: ${{ steps.php.outputs.php_config }}
- name: Cargo build
run: cargo build
env:
EXT_PHP_RS_PHP_CONFIG: ${{ steps.php.outputs.php_config }}
- name: PHP integration tests
run: |
chmod +x ./run-test.sh
./run-test.sh
build-linux:
runs-on: ubuntu-latest
needs: tests
strategy:
fail-fast: false
matrix:
php: ['8.2', '8.3', '8.4']
env:
CARGO_TARGET_DIR: target/ci/build-linux-${{ matrix.php }}
steps:
- uses: actions/checkout@v4
- name: Install prerequisites
run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config zip
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: phpize, php-config
coverage: none
- name: Resolve php-config
id: php
run: echo "php_config=$(command -v php-config)" >> "$GITHUB_OUTPUT"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.RUST_VERSION }}
- name: Cache cargo registry & target
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target/ci/build-linux-${{ matrix.php }}
key: ${{ runner.os }}-build-linux-${{ matrix.php }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-build-linux-${{ matrix.php }}-
${{ runner.os }}-build-linux-
- name: Cargo build (release)
run: cargo build --release --locked
env:
EXT_PHP_RS_PHP_CONFIG: ${{ steps.php.outputs.php_config }}
- name: Package artifact
run: |
mkdir -p dist
ref="${GITHUB_REF_NAME:-$GITHUB_SHA}"
short="${ref:0:7}"
artifact_path="${CARGO_TARGET_DIR%/}/release/librabbit_rs.so"
if [ ! -f "${artifact_path}" ]; then
echo "Artifact not found at ${artifact_path}" >&2
exit 1
fi
scripts/package-extension.sh \
"${artifact_path}" \
"${{ matrix.php }}" \
"linux-gnu-$(uname -m)" \
"${short}" \
"dist"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: rabbit-rs-linux-php${{ matrix.php }}
path: dist/*
build-macos:
runs-on: macos-14
needs: tests
strategy:
fail-fast: false
matrix:
php: ['8.2', '8.3', '8.4']
env:
CARGO_TARGET_DIR: target/ci/build-macos-${{ matrix.php }}
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: phpize, php-config, composer
coverage: none
- name: Resolve php-config
id: php
run: echo "php_config=$(command -v php-config)" >> "$GITHUB_OUTPUT"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.RUST_VERSION }}
- name: Cache cargo registry & target
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target/ci/build-macos-${{ matrix.php }}
key: ${{ runner.os }}-build-macos-${{ matrix.php }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-build-macos-${{ matrix.php }}-
${{ runner.os }}-build-macos-
- name: Cargo build (release)
run: cargo build --release --locked
env:
EXT_PHP_RS_PHP_CONFIG: ${{ steps.php.outputs.php_config }}
- name: Package artifact
run: |
mkdir -p dist
ref="${GITHUB_REF_NAME:-$GITHUB_SHA}"
short="${ref:0:7}"
artifact_path="${CARGO_TARGET_DIR%/}/release/librabbit_rs.dylib"
if [ ! -f "${artifact_path}" ]; then
echo "Artifact not found at ${artifact_path}" >&2
exit 1
fi
scripts/package-extension.sh \
"${artifact_path}" \
"${{ matrix.php }}" \
"darwin-$(uname -m)" \
"${short}" \
"dist"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: rabbit-rs-darwin-php${{ matrix.php }}
path: dist/*