Skip to content

Commit 723e1bb

Browse files
committed
chore: update workflow
1 parent 7920817 commit 723e1bb

File tree

4 files changed

+265
-104
lines changed

4 files changed

+265
-104
lines changed

.cargo/config.toml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[target.aarch64-unknown-linux-gnu]
2+
linker = "aarch64-linux-gnu-gcc"
3+
4+
[target.x86_64-pc-windows-msvc]
5+
linker = "rust-lld"
6+
7+
[target.i686-pc-windows-msvc]
8+
linker = "rust-lld"
9+
10+
[target.'cfg(not(target_os = "windows"))']
11+
rustflags = ["-C", "link-arg=-Wl,-undefined,dynamic_lookup"]
12+
13+
[target.x86_64-unknown-linux-musl]
14+
rustflags = [
15+
"-C", "target-feature=-crt-static",
16+
]

.github/workflows/build.yml

-104
This file was deleted.

.github/workflows/ci.yml

+231
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
---
2+
3+
name: Build and Lint
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
debug_enabled:
8+
type: boolean
9+
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
10+
required: false
11+
default: false
12+
push:
13+
paths-ignore:
14+
- '**.md'
15+
- '**.yaml'
16+
- '**.yml'
17+
18+
permissions:
19+
contents: write
20+
21+
env:
22+
EXTENSION_NAME: fluent
23+
24+
jobs:
25+
tests:
26+
runs-on: ubuntu-latest
27+
strategy:
28+
matrix:
29+
php-version: [ "8.1" ]
30+
clang: [ "16" ]
31+
target: [ "x86_64-unknown-linux-gnu" ]
32+
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
with:
37+
submodules: recursive
38+
39+
- name: Cache cargo and LLVM and Clang
40+
id: cache-llvm
41+
uses: actions/cache@v4
42+
with:
43+
path: |
44+
~/.cargo/bin/
45+
~/.cargo/registry/index/
46+
~/.cargo/registry/cache/
47+
~/.cargo/git/db/
48+
target/
49+
${{ runner.temp }}/llvm-${{ matrix.clang }}
50+
key: ${{ matrix.php-version }}-test
51+
52+
- name: Setup LLVM & Clang
53+
id: clang
54+
if: runner.os == 'Linux'
55+
uses: KyleMayes/install-llvm-action@v2
56+
with:
57+
version: ${{ matrix.clang }}
58+
directory: ${{ runner.temp }}/llvm-${{ matrix.clang }}
59+
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
60+
61+
- name: Configure Clang
62+
run: |
63+
echo "LIBCLANG_PATH=${{ runner.temp }}/llvm-${{ matrix.clang }}/lib" >> $GITHUB_ENV
64+
echo "LLVM_VERSION=${{ steps.clang.outputs.version }}" >> $GITHUB_ENV
65+
echo "LLVM_CONFIG_PATH=${{ runner.temp }}/llvm-${{ matrix.clang }}/bin/llvm-config" >> $GITHUB_ENV
66+
67+
- uses: shivammathur/setup-php@v2
68+
with:
69+
php-version: ${{ matrix.php-version }}
70+
tools: php-config
71+
72+
- name: Install latest Rust toolchain
73+
run: |
74+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
75+
source $HOME/.cargo/env
76+
rustup default stable
77+
rustup target add ${{ matrix.target }}
78+
79+
- name: Build module
80+
run: |
81+
cargo build --target ${{ matrix.target }} --lib
82+
cargo test --target ${{ matrix.target }}
83+
84+
# Enable tmate debugging of manually-triggered workflows if the input option was provided
85+
- name: Setup tmate session
86+
uses: mxschmitt/action-tmate@v3
87+
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
88+
89+
- name: Run PHP Test
90+
run: NO_INTERACTION=1 php run-tests.php -n -d extension=target/${{ matrix.target }}/debug/libfluent.so
91+
92+
build:
93+
runs-on: ${{ matrix.os }}
94+
needs: tests
95+
strategy:
96+
matrix:
97+
clang: [ "16" ]
98+
php-version: [ "8.1", "8.2", "8.3" ]
99+
target: [ x86_64-pc-windows-msvc, aarch64-apple-darwin, x86_64-apple-darwin, x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu ]
100+
phpts: [ "nts", "ts" ]
101+
include:
102+
- { rust_channel: stable }
103+
- { target: x86_64-pc-windows-msvc, rust_channel: nightly }
104+
- { target: x86_64-pc-windows-msvc, os: windows-latest }
105+
- { target: aarch64-apple-darwin, os: macos-latest }
106+
- { target: x86_64-apple-darwin, os: macos-latest }
107+
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest }
108+
- { target: aarch64-unknown-linux-gnu, os: ubuntu-latest }
109+
exclude:
110+
- { target: aarch64-apple-darwin, phpts: ts }
111+
- { target: x86_64-apple-darwin, phpts: ts }
112+
- { target: x86_64-unknown-linux-gnu, phpts: ts }
113+
- { target: aarch64-unknown-linux-gnu, phpts: ts }
114+
115+
steps:
116+
- name: Checkout
117+
uses: actions/checkout@v4
118+
with:
119+
submodules: recursive
120+
121+
- name: Cache cargo and LLVM and Clang
122+
id: cache-llvm
123+
uses: actions/cache@v4
124+
with:
125+
path: |
126+
~/.cargo/bin/
127+
~/.cargo/registry/index/
128+
~/.cargo/registry/cache/
129+
~/.cargo/git/db/
130+
target/
131+
${{ runner.temp }}/llvm-${{ matrix.clang }}
132+
key: ${{ matrix.php-version }}-test
133+
134+
- name: Setup LLVM & Clang
135+
id: clang
136+
if: runner.os == 'Linux'
137+
uses: KyleMayes/install-llvm-action@v2
138+
with:
139+
version: ${{ matrix.clang }}
140+
directory: ${{ runner.temp }}/llvm-${{ matrix.clang }}
141+
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
142+
143+
- name: Configure Clang
144+
if: runner.os == 'Linux'
145+
run: |
146+
echo "LIBCLANG_PATH=${{ runner.temp }}/llvm-${{ matrix.clang }}/lib" >> $GITHUB_ENV
147+
echo "LLVM_VERSION=${{ steps.clang.outputs.version }}" >> $GITHUB_ENV
148+
echo "LLVM_CONFIG_PATH=${{ runner.temp }}/llvm-${{ matrix.clang }}/bin/llvm-config" >> $GITHUB_ENV
149+
150+
- name: Install latest Rust toolchain
151+
run: |
152+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
153+
#source $HOME/.cargo/env
154+
rustup default ${{ matrix.rust_channel }}
155+
rustup target add ${{ matrix.target }}
156+
shell: bash
157+
158+
- name: Setup PHP with PECL extension
159+
uses: shivammathur/setup-php@v2
160+
with:
161+
php-version: ${{ matrix.php-version }}
162+
tools: php-config
163+
env:
164+
phpts: ${{ matrix.phpts }}
165+
166+
- name: OS Specific Configuration - Linux
167+
if: runner.os == 'Linux'
168+
run: |
169+
echo "OUTPUT_FILE=lib${{ env.EXTENSION_NAME }}.so" >> $GITHUB_ENV
170+
echo "LIB_EXT=so" >> $GITHUB_ENV
171+
sudo apt-get install -y gcc-aarch64-linux-gnu libc6-dev-arm64-cross musl-tools musl-dev
172+
173+
- name: OS Specific Configuration - macOS
174+
if: runner.os == 'macOS'
175+
run: |
176+
echo "OUTPUT_FILE=lib${{ env.EXTENSION_NAME }}.dylib" >> $GITHUB_ENV
177+
echo "LIB_EXT=so" >> $GITHUB_ENV
178+
179+
- name: OS Specific Configuration - Windows
180+
if: runner.os == 'Windows'
181+
run: |
182+
echo "OUTPUT_FILE=${{ env.EXTENSION_NAME }}.dll" >> $GITHUB_ENV
183+
echo "LIB_EXT=dll" >> $GITHUB_ENV
184+
shell: bash
185+
186+
- name: Build module
187+
run: |
188+
cargo build --release --target ${{ matrix.target }} --lib
189+
190+
- name: Rename file
191+
run: mv target/${{ matrix.target }}/release/${{ env.OUTPUT_FILE }} target/php${{ matrix.php-version }}-${{ matrix.phpts }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.${{ env.LIB_EXT }}
192+
shell: bash
193+
194+
- uses: actions/upload-artifact@v4
195+
with:
196+
name: php${{ matrix.php-version }}-${{ matrix.target }}
197+
path: target/php${{ matrix.php-version }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.${{ env.LIB_EXT }}
198+
199+
release:
200+
runs-on: ubuntu-latest
201+
needs: build
202+
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'release'
203+
204+
steps:
205+
- name: Checkout
206+
uses: actions/checkout@v4
207+
208+
- name: Get Cargo Version
209+
id: cargo_version
210+
run: |
211+
VERSION=$(grep '^version =' Cargo.toml | head -n 1 | sed 's/.*"\(.*\)".*/\1/')
212+
echo "VERSION=$VERSION" >> $GITHUB_ENV
213+
shell: bash
214+
215+
- name: Download all artifacts
216+
uses: actions/download-artifact@v4
217+
with:
218+
path: ./artifacts
219+
220+
- name: Create GitHub Release
221+
if: startsWith(github.ref, 'refs/tags/v')
222+
id: create_release
223+
uses: softprops/action-gh-release@v2
224+
with:
225+
tag_name: v${{ env.VERSION }}
226+
name: Release ${{ env.VERSION }}
227+
draft: false
228+
prerelease: false
229+
files: ./artifacts/**
230+
env:
231+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Define versions used to select image versions
2+
# (ARGs declared before FROM can't be used outside of FROMs)
3+
ARG FROM_PHP=8.0
4+
5+
# Select distro
6+
ARG FROM_DISTRO=bullseye
7+
8+
FROM php:${FROM_PHP}-fpm-${FROM_DISTRO}
9+
10+
RUN apt-get update && apt install curl build-essential gcc libclang-dev make -y
11+
12+
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
13+
14+
RUN echo 'source $HOME/.cargo/env' >> $HOME/.bashrc
15+
ENV PATH="/root/.cargo/bin:${PATH}"
16+
17+
WORKDIR /code
18+
ENTRYPOINT [ "" ]

0 commit comments

Comments
 (0)