Build and Lint #28
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Build and Lint | |
on: | |
workflow_dispatch: | |
inputs: | |
debug_enabled: | |
type: boolean | |
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' | |
required: false | |
default: false | |
push: | |
paths-ignore: | |
- '**.md' | |
- '**.yaml' | |
- '**.yml' | |
permissions: | |
contents: write | |
env: | |
EXTENSION_NAME: fluent | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
php-version: [ "8.1" ] | |
clang: [ "16" ] | |
target: [ "x86_64-unknown-linux-gnu" ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Cache cargo and LLVM and Clang | |
id: cache-llvm | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
${{ runner.temp }}/llvm-${{ matrix.clang }} | |
key: ${{ matrix.php-version }}-test | |
- name: Setup LLVM & Clang | |
id: clang | |
if: runner.os == 'Linux' | |
uses: KyleMayes/install-llvm-action@v2 | |
with: | |
version: ${{ matrix.clang }} | |
directory: ${{ runner.temp }}/llvm-${{ matrix.clang }} | |
cached: ${{ steps.cache-llvm.outputs.cache-hit }} | |
- name: Configure Clang | |
run: | | |
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 | |
- uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
tools: php-config | |
- name: Install latest Rust toolchain | |
run: | | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
source $HOME/.cargo/env | |
rustup default stable | |
rustup target add ${{ matrix.target }} | |
- name: Build module | |
run: | | |
cargo build --target ${{ matrix.target }} --lib | |
cargo test --target ${{ matrix.target }} | |
# Enable tmate debugging of manually-triggered workflows if the input option was provided | |
- name: Setup tmate session | |
uses: mxschmitt/action-tmate@v3 | |
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} | |
- name: Run PHP Test | |
run: NO_INTERACTION=1 php run-tests.php -n -d extension=target/${{ matrix.target }}/debug/libfluent.so | |
build: | |
runs-on: ${{ matrix.os }} | |
needs: tests | |
strategy: | |
matrix: | |
clang: [ "16" ] | |
php-version: [ "8.1", "8.2", "8.3" ] | |
target: [ x86_64-pc-windows-msvc, aarch64-apple-darwin, x86_64-apple-darwin, x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu ] | |
phpts: [ "nts", "ts" ] | |
include: | |
- { rust_channel: stable } | |
- { target: x86_64-pc-windows-msvc, rust_channel: nightly } | |
- { target: x86_64-pc-windows-msvc, os: windows-latest } | |
- { target: aarch64-apple-darwin, os: macos-latest } | |
- { target: x86_64-apple-darwin, os: macos-latest } | |
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest } | |
- { target: aarch64-unknown-linux-gnu, os: ubuntu-latest } | |
exclude: | |
- { target: aarch64-apple-darwin, phpts: ts } | |
- { target: x86_64-apple-darwin, phpts: ts } | |
- { target: x86_64-unknown-linux-gnu, phpts: ts } | |
- { target: aarch64-unknown-linux-gnu, phpts: ts } | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Cache cargo and LLVM and Clang | |
id: cache-llvm | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
${{ runner.temp }}/llvm-${{ matrix.clang }} | |
key: ${{ matrix.php-version }}-test | |
- name: Setup LLVM & Clang | |
id: clang | |
if: runner.os == 'Linux' | |
uses: KyleMayes/install-llvm-action@v2 | |
with: | |
version: ${{ matrix.clang }} | |
directory: ${{ runner.temp }}/llvm-${{ matrix.clang }} | |
cached: ${{ steps.cache-llvm.outputs.cache-hit }} | |
- name: Configure Clang | |
if: runner.os == 'Linux' | |
run: | | |
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: Install latest Rust toolchain | |
run: | | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
#source $HOME/.cargo/env | |
rustup default ${{ matrix.rust_channel }} | |
rustup target add ${{ matrix.target }} | |
shell: bash | |
- name: Setup PHP with PECL extension | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
tools: php-config | |
env: | |
phpts: ${{ matrix.phpts }} | |
- name: OS Specific Configuration - Linux | |
if: runner.os == 'Linux' | |
run: | | |
echo "OUTPUT_FILE=lib${{ env.EXTENSION_NAME }}.so" >> $GITHUB_ENV | |
echo "LIB_EXT=so" >> $GITHUB_ENV | |
sudo apt-get install -y gcc-aarch64-linux-gnu libc6-dev-arm64-cross musl-tools musl-dev | |
- name: OS Specific Configuration - macOS | |
if: runner.os == 'macOS' | |
run: | | |
echo "OUTPUT_FILE=lib${{ env.EXTENSION_NAME }}.dylib" >> $GITHUB_ENV | |
echo "LIB_EXT=so" >> $GITHUB_ENV | |
- name: OS Specific Configuration - Windows | |
if: runner.os == 'Windows' | |
run: | | |
echo "OUTPUT_FILE=${{ env.EXTENSION_NAME }}.dll" >> $GITHUB_ENV | |
echo "LIB_EXT=dll" >> $GITHUB_ENV | |
shell: bash | |
- name: Build module | |
run: | | |
cargo build --release --target ${{ matrix.target }} --lib | |
- name: Rename file | |
run: mv target/${{ matrix.target }}/release/${{ env.OUTPUT_FILE }} target/php${{ matrix.php-version }}-${{ matrix.phpts }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.${{ env.LIB_EXT }} | |
shell: bash | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: php${{ matrix.php-version }}-${{ matrix.phpts }}-${{ matrix.target }} | |
path: target/php${{ matrix.php-version }}-${{ matrix.phpts }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.${{ env.LIB_EXT }} | |
release: | |
runs-on: ubuntu-latest | |
needs: build | |
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'release' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get Cargo Version | |
id: cargo_version | |
run: | | |
VERSION=$(grep '^version =' Cargo.toml | head -n 1 | sed 's/.*"\(.*\)".*/\1/') | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
shell: bash | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./artifacts | |
- name: Create GitHub Release | |
if: startsWith(github.ref, 'refs/tags/v') | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: v${{ env.VERSION }} | |
name: Release ${{ env.VERSION }} | |
draft: false | |
prerelease: false | |
files: ./artifacts/** | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |