|
| 1 | +# .github/workflows/ci.yml |
| 2 | +name: CI/CD for Inline-Lua |
| 3 | + |
| 4 | +# IMPORTANT: |
| 5 | +# Sets default permissions to be read-only for security |
| 6 | +permissions: |
| 7 | + contents: read |
| 8 | + |
| 9 | +on: |
| 10 | + push: |
| 11 | + branches: [ master, main, develop ] |
| 12 | + pull_request: |
| 13 | + branches: [ master, main, develop ] |
| 14 | + workflow_dispatch: # Allow manual runs |
| 15 | + |
| 16 | +jobs: |
| 17 | + test: |
| 18 | + runs-on: ${{ matrix.os }} |
| 19 | + strategy: |
| 20 | + fail-fast: false # Don't cancel other jobs if one fails |
| 21 | + matrix: |
| 22 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 23 | + perl: |
| 24 | + - 5.8 |
| 25 | + - 5.16 |
| 26 | + - 5.22 |
| 27 | + - 5.30 |
| 28 | + - 5.36 |
| 29 | + - 5.38 |
| 30 | + include: |
| 31 | + # Also test bleeding edge on Ubuntu for forward-compatibility |
| 32 | + - os: ubuntu-latest |
| 33 | + perl: devel |
| 34 | + exclude: |
| 35 | + # Older Perls can be problematic on Windows, so, we'll be selective |
| 36 | + - os: windows-latest |
| 37 | + perl: 5.8 |
| 38 | + - os: windows-latest |
| 39 | + perl: 5.16 |
| 40 | + |
| 41 | + name: Perl ${{ matrix.perl }} on ${{ matrix.os }} |
| 42 | + |
| 43 | + steps: |
| 44 | + - name: Checkout code |
| 45 | + uses: actions/checkout@v4 |
| 46 | + |
| 47 | + - name: Set up Perl |
| 48 | + uses: shogo82148/actions-setup-perl@v1 |
| 49 | + with: |
| 50 | + perl-version: ${{ matrix.perl }} |
| 51 | + distribution: strawberry # for windows latest |
| 52 | + |
| 53 | + - name: Cache CPAN modules |
| 54 | + uses: actions/cache@v4 |
| 55 | + with: |
| 56 | + path: | |
| 57 | + ~/perl5 |
| 58 | + ~/.cpanm |
| 59 | + key: ${{ runner.os }}-perl${{ matrix.perl }}-${{ hashFiles('**/cpanfile', '**/Makefile.PL', '**/META.json') }} |
| 60 | + restore-keys: | |
| 61 | + ${{ runner.os }}-perl${{ matrix.perl }}- |
| 62 | +
|
| 63 | + - name: Install system dependencies (Lua) |
| 64 | + run: | |
| 65 | + if [ "$RUNNER_OS" == "Linux" ]; then |
| 66 | + sudo apt-get update |
| 67 | + sudo apt-get install -y liblua5.3-dev |
| 68 | + elif [ "$RUNNER_OS" == "macOS" ]; then |
| 69 | + brew install lua |
| 70 | + elif [ "$RUNNER_OS" == "Windows" ]; then |
| 71 | + # Using scoop to install Lua on Windows |
| 72 | + scoop install lua |
| 73 | + # Add Lua paths to the environment for Makefile.PL |
| 74 | + echo "LUA_LIB_PATH=C:\Users\runneradmin\scoop\apps\lua\current\lib" >> $env:GITHUB_ENV |
| 75 | + echo "LUA_INC_PATH=C:\Users\runneradmin\scoop\apps\lua\current\include" >> $env:GITHUB_ENV |
| 76 | + echo "PATH=C:\Users\runneradmin\scoop\apps\lua\current\bin;${env:PATH}" >> $env:GITHUB_ENV |
| 77 | + fi |
| 78 | + shell: bash |
| 79 | + |
| 80 | + - name: Install Perl Dependencies |
| 81 | + run: cpanm --notest --installdeps . |
| 82 | + |
| 83 | + - name: Build and Test |
| 84 | + run: | |
| 85 | + # Provide hints to Makefile.PL on Windows if env vars are set |
| 86 | + if [ "$RUNNER_OS" == "Windows" ]; then |
| 87 | + perl Makefile.PL INC="-I$env:LUA_INC_PATH" LIBS="-L$env:LUA_LIB_PATH -llua53" |
| 88 | + else |
| 89 | + perl Makefile.PL |
| 90 | + fi |
| 91 | + make |
| 92 | + make test TEST_VERBOSE=1 |
| 93 | +
|
| 94 | + - name: Run Author/Extended Tests (if they exist) |
| 95 | + continue-on-error: true |
| 96 | + run: | |
| 97 | + if [ -d "xt" ]; then |
| 98 | + if [ -f "xt/cpanfile" ]; then |
| 99 | + cpanm --installdeps xt/ |
| 100 | + fi |
| 101 | + prove -lv -r xt |
| 102 | + else |
| 103 | + echo "No xt/ directory found, skipping author tests." |
| 104 | + fi |
| 105 | +
|
| 106 | + dist-test: |
| 107 | + runs-on: ubuntu-latest |
| 108 | + needs: test |
| 109 | + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') |
| 110 | + |
| 111 | + steps: |
| 112 | + - uses: actions/checkout@v4 |
| 113 | + |
| 114 | + - name: Set up Perl |
| 115 | + uses: shogo82148/actions-setup-perl@v1 |
| 116 | + with: |
| 117 | + perl-version: 5.38 |
| 118 | + |
| 119 | + - name: Install Release Tools |
| 120 | + run: cpanm --notest Test::CPAN::Meta |
| 121 | + |
| 122 | + - name: Build and Test Distribution |
| 123 | + run: | |
| 124 | + cpanm --notest --installdeps . |
| 125 | + perl Makefile.PL |
| 126 | + make |
| 127 | + make test |
| 128 | + make dist |
| 129 | + cpan-meta-json --file $(ls *.tar.gz | head -1) --validate |
| 130 | +
|
| 131 | + - name: Archive distribution |
| 132 | + # REMINDER: This step requires write permissions for actions to upload artifacts |
| 133 | + uses: actions/upload-artifact@v4 |
| 134 | + with: |
| 135 | + name: perl-distribution |
| 136 | + path: "*.tar.gz" |
| 137 | + retention-days: 30 |
0 commit comments