Skip to content

Continuous integration ​

GitHub Actions ​

yaml
# .github/workflows/tests.yml
name: Tests
on: [push, pull_request]

jobs:
  golem:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: achedon12/golem@v0

That is the whole setup: the runner's PHP runs the CLI, and PocketMine plus its PHP build are cached between runs. When a test fails, the job fails and the failure is annotated on the pull request diff, at the line of the test.

Inputs ​

InputDefaultDescription
path.Plugin folder, for repositories holding several plugins
testsfrom composer.json, else testsTests folder, relative to the plugin
pocketminefrom composer.json, else latestPocketMine-MP version
filterOnly run matching tests
junitgolem-junit.xmlJUnit report path, empty to skip it
report-htmlWrite a self-contained HTML report there, to upload as an artifact
commentfalseOn pull requests, post a summary comment (results, failures, coverage) and update it on every push. Needs pull-requests: write
parallel1Number of servers to split the tests between (see --parallel)

A summary on every pull request ​

With comment: true, the action posts the results on the pull request, failures included, and updates the same comment on every push. The same summary goes to the job's summary page.

yaml
jobs:
  golem:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
    steps:
      - uses: actions/checkout@v7
      - uses: achedon12/golem@v0
        with:
          comment: true
          report-html: golem-report.html
      - uses: actions/upload-artifact@v6
        if: always()
        with:
          name: golem-report
          path: golem-report.html

Pull requests from forks get a read-only token: the comment is skipped there, with a warning.

Testing against several PocketMine versions ​

yaml
jobs:
  golem:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        pocketmine: ['5.40.0', '5.44.3']
    steps:
      - uses: actions/checkout@v7
      - uses: achedon12/golem@v0
        with:
          pocketmine: ${{ matrix.pocketmine }}

Testing on a fork as well ​

yaml
jobs:
  golem:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        pocketmine: ['5.44.3', 'Plutonium-Mcpe/PocketMine-MP']
    steps:
      - uses: actions/checkout@v7
      - uses: achedon12/golem@v0
        with:
          pocketmine: ${{ matrix.pocketmine }}

A migration report on every pull request ​

yaml
      - uses: shivammathur/setup-php@v2
        with:
          php-version: '8.4'
      - run: composer install
      - run: vendor/bin/golem --compare=Plutonium-Mcpe/PocketMine-MP

The differences land in the job summary, and the job fails when a passing test breaks on the fork.

Keeping the JUnit report ​

yaml
      - uses: achedon12/golem@v0
      - uses: actions/upload-artifact@v6
        if: always()
        with:
          name: golem-report
          path: golem-junit.xml

Other CI systems ​

Any Linux machine with PHP 8.1+ can run Golem:

bash
composer install
vendor/bin/golem --log-junit=build/golem-junit.xml

Cache ~/.cache/golem between runs to skip the downloads (or point GOLEM_CACHE_DIR at a cached folder). GitLab CI, for example:

yaml
golem:
  image: php:8.3-cli
  variables:
    GOLEM_CACHE_DIR: "$CI_PROJECT_DIR/.golem-cache"
  cache:
    paths: [.golem-cache/]
  script:
    - apt-get update && apt-get install -y git unzip
    - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
    - composer install
    - vendor/bin/golem --log-junit=golem-junit.xml
  artifacts:
    when: always
    reports:
      junit: golem-junit.xml

TeamCity ​

--teamcity replaces the usual output with TeamCity service messages: TeamCity, and other tools that read them, show each test class as a suite, each test with its duration, and failures with their expected and actual values.

bash
vendor/bin/golem --teamcity
text
##teamcity[testCount count='4']
##teamcity[testSuiteStarted name='LobbyHudTest' locationHint='php_qn:///…/tests/LobbyHudTest.php::\Example\HelloWorld\Tests\LobbyHudTest']
##teamcity[testStarted name='testCountsPlayersOnline' locationHint='php_qn:///…/tests/LobbyHudTest.php::\Example\HelloWorld\Tests\LobbyHudTest::testCountsPlayersOnline']
##teamcity[testFailed name='testCountsPlayersOnline' message='The scoreboard of Steve does not show "Online: 3"' type='comparisonFailure' expected='"Online: 3"' actual='…']
##teamcity[testFinished name='testCountsPlayersOnline' duration='1452']

Released under the MIT License.