Skip to content

Commit f0d68e4

Browse files
committed
chore: update workflow
1 parent 7920817 commit f0d68e4

File tree

5 files changed

+268
-104
lines changed

5 files changed

+268
-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

+233
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
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, x86_64-unknown-linux-musl, 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: x86_64-unknown-linux-musl, os: ubuntu-latest }
109+
- { target: aarch64-unknown-linux-gnu, os: ubuntu-latest }
110+
exclude:
111+
- { target: aarch64-apple-darwin, phpts: ts }
112+
- { target: x86_64-apple-darwin, phpts: ts }
113+
- { target: x86_64-unknown-linux-gnu, phpts: ts }
114+
- { target: x86_64-unknown-linux-musl, phpts: ts }
115+
- { target: aarch64-unknown-linux-gnu, phpts: ts }
116+
117+
steps:
118+
- name: Checkout
119+
uses: actions/checkout@v4
120+
with:
121+
submodules: recursive
122+
123+
- name: Cache cargo and LLVM and Clang
124+
id: cache-llvm
125+
uses: actions/cache@v4
126+
with:
127+
path: |
128+
~/.cargo/bin/
129+
~/.cargo/registry/index/
130+
~/.cargo/registry/cache/
131+
~/.cargo/git/db/
132+
target/
133+
${{ runner.temp }}/llvm-${{ matrix.clang }}
134+
key: ${{ matrix.php-version }}-test
135+
136+
- name: Setup LLVM & Clang
137+
id: clang
138+
if: runner.os == 'Linux'
139+
uses: KyleMayes/install-llvm-action@v2
140+
with:
141+
version: ${{ matrix.clang }}
142+
directory: ${{ runner.temp }}/llvm-${{ matrix.clang }}
143+
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
144+
145+
- name: Configure Clang
146+
if: runner.os == 'Linux'
147+
run: |
148+
echo "LIBCLANG_PATH=${{ runner.temp }}/llvm-${{ matrix.clang }}/lib" >> $GITHUB_ENV
149+
echo "LLVM_VERSION=${{ steps.clang.outputs.version }}" >> $GITHUB_ENV
150+
echo "LLVM_CONFIG_PATH=${{ runner.temp }}/llvm-${{ matrix.clang }}/bin/llvm-config" >> $GITHUB_ENV
151+
152+
- name: Install latest Rust toolchain
153+
run: |
154+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
155+
#source $HOME/.cargo/env
156+
rustup default ${{ matrix.rust_channel }}
157+
rustup target add ${{ matrix.target }}
158+
shell: bash
159+
160+
- name: Setup PHP with PECL extension
161+
uses: shivammathur/setup-php@v2
162+
with:
163+
php-version: ${{ matrix.php-version }}
164+
tools: php-config
165+
env:
166+
phpts: ${{ matrix.phpts }}
167+
168+
- name: OS Specific Configuration - Linux
169+
if: runner.os == 'Linux'
170+
run: |
171+
echo "OUTPUT_FILE=lib${{ env.EXTENSION_NAME }}.so" >> $GITHUB_ENV
172+
echo "LIB_EXT=so" >> $GITHUB_ENV
173+
sudo apt-get install -y gcc-aarch64-linux-gnu libc6-dev-arm64-cross musl-tools musl-dev
174+
175+
- name: OS Specific Configuration - macOS
176+
if: runner.os == 'macOS'
177+
run: |
178+
echo "OUTPUT_FILE=lib${{ env.EXTENSION_NAME }}.dylib" >> $GITHUB_ENV
179+
echo "LIB_EXT=so" >> $GITHUB_ENV
180+
181+
- name: OS Specific Configuration - Windows
182+
if: runner.os == 'Windows'
183+
run: |
184+
echo "OUTPUT_FILE=${{ env.EXTENSION_NAME }}.dll" >> $GITHUB_ENV
185+
echo "LIB_EXT=dll" >> $GITHUB_ENV
186+
shell: bash
187+
188+
- name: Build module
189+
run: |
190+
cargo build --release --target ${{ matrix.target }} --lib
191+
192+
- name: Rename file
193+
run: mv target/${{ matrix.target }}/release/${{ env.OUTPUT_FILE }} target/php${{ matrix.php-version }}-${{ matrix.phpts }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.${{ env.LIB_EXT }}
194+
shell: bash
195+
196+
- uses: actions/upload-artifact@v4
197+
with:
198+
name: php${{ matrix.php-version }}-${{ matrix.phpts }}-${{ matrix.target }}
199+
path: target/php${{ matrix.php-version }}-${{ matrix.phpts }}-${{ matrix.target }}-${{ env.EXTENSION_NAME }}.${{ env.LIB_EXT }}
200+
201+
release:
202+
runs-on: ubuntu-latest
203+
needs: build
204+
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'release'
205+
206+
steps:
207+
- name: Checkout
208+
uses: actions/checkout@v4
209+
210+
- name: Get Cargo Version
211+
id: cargo_version
212+
run: |
213+
VERSION=$(grep '^version =' Cargo.toml | head -n 1 | sed 's/.*"\(.*\)".*/\1/')
214+
echo "VERSION=$VERSION" >> $GITHUB_ENV
215+
shell: bash
216+
217+
- name: Download all artifacts
218+
uses: actions/download-artifact@v4
219+
with:
220+
path: ./artifacts
221+
222+
- name: Create GitHub Release
223+
if: startsWith(github.ref, 'refs/tags/v')
224+
id: create_release
225+
uses: softprops/action-gh-release@v2
226+
with:
227+
tag_name: v${{ env.VERSION }}
228+
name: Release ${{ env.VERSION }}
229+
draft: false
230+
prerelease: false
231+
files: ./artifacts/**
232+
env:
233+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

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)