-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
211 additions
and
77 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[target.aarch64-unknown-linux-gnu] | ||
linker = "aarch64-linux-gnu-gcc" | ||
|
||
[target.x86_64-pc-windows-msvc] | ||
linker = "rust-lld" | ||
|
||
[target.i686-pc-windows-msvc] | ||
linker = "rust-lld" | ||
|
||
[target.'cfg(not(target_os = "windows"))'] | ||
rustflags = ["-C", "link-arg=-Wl,-undefined,dynamic_lookup"] | ||
|
||
[target.x86_64-unknown-linux-musl] | ||
rustflags = [ | ||
"-C", "target-feature=-crt-static", | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,204 @@ | ||
--- | ||
|
||
name: Build and Lint | ||
on: | ||
pull_request: | ||
push: | ||
release: | ||
types: [created] | ||
workflow_dispatch: | ||
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"] | ||
|
||
# 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 x86_64-unknown-linux-gnu | ||
|
||
# - name: Run Tests | ||
# run: | | ||
# cargo test --target x86_64-unknown-linux-gnu | ||
|
||
build: | ||
name: Build and Test | ||
runs-on: ${{ matrix.os }} | ||
# needs: tests | ||
strategy: | ||
matrix: | ||
os: [ubuntu-22.04, windows-2019] | ||
# os: [windows-2019, macos-latest, ] | ||
# phpts: [ts, nts] | ||
phpts: [nts, ts] | ||
rust: [nightly] | ||
php: ["8.2", "8.3"] | ||
clang: ["16"] | ||
exclude: | ||
# ext-php-rs requires nightly Rust when on Windows. | ||
- os: windows-2019 | ||
rust: stable | ||
# setup-php doesn't support thread safe PHP on Linux and macOS. | ||
- os: macos-latest | ||
phpts: ts | ||
- os: ubuntu-22.04 | ||
phpts: ts | ||
env: | ||
CARGO_TERM_COLOR: always | ||
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" ] | ||
include: | ||
- { target: x86_64-pc-windows-msvc, os: windows-latest } | ||
- { target: x86_64-pc-windows-msvc, os: windows-latest, phpts: "ts" } | ||
- { 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 } | ||
- { rust_channel: stable } | ||
- { target: x86_64-pc-windows-msvc, rust_channel: nightly } | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
env: | ||
phpts: ${{ matrix.phpts }} | ||
debug: true | ||
- name: Setup Rust | ||
uses: dtolnay/rust-toolchain@master | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
components: rustfmt, clippy | ||
- 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 | ||
submodules: recursive | ||
|
||
- name: Cache cargo and LLVM and Clang | ||
id: cache-llvm | ||
uses: actions/cache@v3 | ||
#if: "!contains(matrix.os, 'windows')" | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ runner.temp }}/llvm-${{ matrix.clang }} | ||
key: ${{ matrix.os }}-llvm-${{ matrix.clang }} | ||
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 | ||
uses: KyleMayes/install-llvm-action@v1 | ||
# if: "!contains(matrix.os, 'windows')" | ||
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: "!contains(matrix.os, 'windows')" | ||
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: Configure Clang (macOS only) | ||
if: "contains(matrix.os, 'macos')" | ||
run: echo "SDKROOT=$(xcrun --show-sdk-path)" >> $GITHUB_ENV | ||
# Build | ||
- name: Build | ||
- 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: | ||
EXT_PHP_RS_TEST: "" | ||
run: cargo build --release --all-features --all -vvv | ||
- name: Archive production artifacts | ||
uses: actions/upload-artifact@v3 | ||
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@v3 | ||
with: | ||
name: artifacts-${{ matrix.os }}-${{ matrix.php }}-${{ matrix.phpts }} | ||
path: | | ||
target/release/fluent.dll | ||
target/release/libfluent.dylib | ||
target/release/libfluent.so | ||
# Test & lint | ||
# - name: Test inline examples | ||
# run: cargo test --release --all --all-features | ||
# - name: Run rustfmt | ||
# if: matrix.rust == 'stable' && matrix.os == 'ubuntu-20.04' && matrix.php == '8.2' | ||
# run: cargo fmt --all -- --check | ||
# - name: Run clippy | ||
# if: matrix.rust == 'stable' && matrix.os == 'ubuntu-20.04' && matrix.php == '8.2' | ||
# run: cargo clippy --all -- -D warnings | ||
name: php${{ matrix.php-version }}-${{ matrix.target }} | ||
path: target/php${{ matrix.php-version }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.${{ env.LIB_EXT }} | ||
|
||
- 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: Create GitHub Release | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
id: create_release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
tag_name: ${{ env.VERSION }} | ||
name: Release ${{ env.VERSION }} | ||
draft: false | ||
prerelease: false | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Upload Release Asset | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
tag_name: ${{ env.VERSION }} | ||
files: | | ||
target/php${{ matrix.php-version }}-$${{ matrix.phpts }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.${{ env.LIB_EXT }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Define versions used to select image versions | ||
# (ARGs declared before FROM can't be used outside of FROMs) | ||
ARG FROM_PHP=8.0 | ||
|
||
# Select distro | ||
ARG FROM_DISTRO=bullseye | ||
|
||
FROM php:${FROM_PHP}-fpm-${FROM_DISTRO} | ||
|
||
RUN apt-get update && apt install curl build-essential gcc libclang-dev make -y | ||
|
||
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y | ||
|
||
RUN echo 'source $HOME/.cargo/env' >> $HOME/.bashrc | ||
ENV PATH="/root/.cargo/bin:${PATH}" | ||
|
||
WORKDIR /code | ||
ENTRYPOINT [ "" ] |