|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + types: [opened, synchronize, reopened] |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + name: Build Rust (${{ matrix.os }}) |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + strategy: |
| 14 | + fail-fast: true |
| 15 | + matrix: |
| 16 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 17 | + include: |
| 18 | + - os: ubuntu-latest |
| 19 | + lib_src: rust/target/debug/libtakumi_php.so |
| 20 | + lib_dst: lib/libtakumi_php.so |
| 21 | + artifact: libtakumi_php-linux |
| 22 | + - os: macos-latest |
| 23 | + lib_src: rust/target/debug/libtakumi_php.dylib |
| 24 | + lib_dst: lib/libtakumi_php.dylib |
| 25 | + artifact: libtakumi_php-macos |
| 26 | + - os: windows-latest |
| 27 | + lib_src: rust/target/debug/takumi_php.dll |
| 28 | + lib_dst: lib/takumi_php.dll |
| 29 | + artifact: libtakumi_php-windows |
| 30 | + |
| 31 | + steps: |
| 32 | + - name: Checkout |
| 33 | + uses: actions/checkout@v6 |
| 34 | + |
| 35 | + - name: Setup Rust |
| 36 | + uses: dtolnay/rust-toolchain@stable |
| 37 | + |
| 38 | + - name: Cache Rust dependencies |
| 39 | + uses: actions/cache@v5 |
| 40 | + with: |
| 41 | + path: | |
| 42 | + ~/.cargo/registry |
| 43 | + ~/.cargo/git |
| 44 | + rust/target |
| 45 | + key: ${{ runner.os }}-cargo-${{ hashFiles('rust/Cargo.lock') }} |
| 46 | + restore-keys: ${{ runner.os }}-cargo- |
| 47 | + |
| 48 | + - name: Run Rust tests |
| 49 | + working-directory: rust |
| 50 | + run: cargo test |
| 51 | + |
| 52 | + - name: Build Rust library (debug) |
| 53 | + working-directory: rust |
| 54 | + run: cargo build |
| 55 | + |
| 56 | + - name: Stage library for upload |
| 57 | + shell: bash |
| 58 | + run: | |
| 59 | + mkdir -p lib |
| 60 | + cp ${{ matrix.lib_src }} ${{ matrix.lib_dst }} |
| 61 | +
|
| 62 | + - name: Upload library artifact |
| 63 | + uses: actions/upload-artifact@v7 |
| 64 | + with: |
| 65 | + name: ${{ matrix.artifact }} |
| 66 | + path: ${{ matrix.lib_dst }} |
| 67 | + retention-days: 1 |
| 68 | + |
| 69 | + test: |
| 70 | + name: PHP ${{ matrix.php }} (${{ matrix.os }}) |
| 71 | + needs: build |
| 72 | + runs-on: ${{ matrix.os }} |
| 73 | + strategy: |
| 74 | + fail-fast: true |
| 75 | + matrix: |
| 76 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 77 | + php: [8.3, 8.4] |
| 78 | + include: |
| 79 | + - os: ubuntu-latest |
| 80 | + lib_dst: lib/libtakumi_php.so |
| 81 | + artifact: libtakumi_php-linux |
| 82 | + - os: macos-latest |
| 83 | + lib_dst: lib/libtakumi_php.dylib |
| 84 | + artifact: libtakumi_php-macos |
| 85 | + - os: windows-latest |
| 86 | + lib_dst: lib/takumi_php.dll |
| 87 | + artifact: libtakumi_php-windows |
| 88 | + |
| 89 | + steps: |
| 90 | + - name: Checkout |
| 91 | + uses: actions/checkout@v6 |
| 92 | + |
| 93 | + - name: Download library artifact |
| 94 | + uses: actions/download-artifact@v8 |
| 95 | + with: |
| 96 | + name: ${{ matrix.artifact }} |
| 97 | + path: lib |
| 98 | + |
| 99 | + - name: Setup PHP |
| 100 | + uses: shivammathur/setup-php@v2 |
| 101 | + with: |
| 102 | + php-version: ${{ matrix.php }} |
| 103 | + extensions: ffi, gd, exif, fileinfo |
| 104 | + coverage: none |
| 105 | + |
| 106 | + - name: Install Composer dependencies |
| 107 | + uses: ramsey/composer-install@v4 |
| 108 | + |
| 109 | + - name: Run PHP tests |
| 110 | + run: composer test |
0 commit comments