Skip to content

Commit ce3e3f9

Browse files
test: run the suite from Cacti's Composer instead of the plugin's
TheWitness asked on plugin_thold#773 for no composer.json in plugins and for testing to use Cacti's own Composer. The unit job now builds the image Cacti's tests/tools/docker_pest.sh builds and runs its locked Pest against a pinned runtime checkout, so the plugin contributes no dependency of its own. Dropping pestphp/pest also drops the reason the job was pinned to PHP 8.2. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
1 parent 6cb7b41 commit ce3e3f9

2 files changed

Lines changed: 33 additions & 40 deletions

File tree

.github/workflows/plugin-ci-workflow.yml

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ on:
2929
paths:
3030
- '**.php'
3131
- '.github/workflows/**'
32-
- 'composer.json'
33-
- 'composer.lock'
3432
- 'phpunit.xml.dist'
3533
- 'tests/**'
3634
pull_request:
@@ -40,8 +38,6 @@ on:
4038
paths:
4139
- '**.php'
4240
- '.github/workflows/**'
43-
- 'composer.json'
44-
- 'composer.lock'
4541
- 'phpunit.xml.dist'
4642
- 'tests/**'
4743
workflow_dispatch:
@@ -72,29 +68,47 @@ jobs:
7268
args: -color
7369

7470
unit-test:
75-
name: Standalone test suite
71+
name: Pest using Cacti Composer (Docker)
7672
runs-on: ubuntu-latest
73+
timeout-minutes: 20
74+
7775
steps:
7876
- name: Checkout monitor Plugin
79-
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
77+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
8078

81-
- name: Install PHP
82-
uses: shivammathur/setup-php@b604ade2a87db23f8871b7182e69ec5e75effb45 # v2
79+
- name: Checkout Cacti runtime
80+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
8381
with:
84-
# 8.2 is the floor for the test tooling, not for the plugin: Pest 2 pulls
85-
# brianium/paratest ^7.4, which requires 8.2. The plugin's own floor is
86-
# covered by syntax-floor on 8.0 and by the 8.1 integration matrix entry.
87-
php-version: '8.2'
88-
tools: composer
82+
repository: Cacti/cacti
83+
# Commit behind the annotated release/1.2.31 tag.
84+
ref: 1e8eaca26b84b128c39ce8cc8ece42d7ff76aac1
85+
path: cacti-runtime
8986

90-
- name: Install dev dependencies
91-
run: composer install --prefer-dist --no-progress --no-interaction --no-plugins --no-scripts
87+
- name: Checkout Cacti test toolchain
88+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
89+
with:
90+
repository: Cacti/cacti
91+
# Pins Composer, Pest, the lock file and Cacti's Docker test image.
92+
ref: 298bd51eca843490fb90b27ada6b3fecc9b9a7d8
93+
path: cacti-toolchain
94+
95+
# The same image Cacti's own tests/tools/docker_pest.sh builds. Composer and
96+
# Pest come from Cacti's locked toolchain, so the plugin ships no
97+
# composer.json and no parallel vendor directory.
98+
- name: Build Cacti test image
99+
run: |
100+
docker build --tag cacti-web --file cacti-toolchain/docker/Dockerfile cacti-toolchain/docker
101+
docker build --tag cacti-monitor-test --file cacti-toolchain/docker/Dockerfile.test cacti-toolchain
92102
93-
- name: Run the test suite
94-
run: composer test
103+
- name: Run Pest
104+
run: |
105+
docker run --rm \
106+
--volume "$PWD/cacti-runtime":/cacti \
107+
--volume "$PWD":/cacti/plugins/monitor \
108+
--user root \
109+
--entrypoint composer cacti-monitor-test \
110+
test -- --configuration=/cacti/plugins/monitor/phpunit.xml.dist
95111
96-
# compat = 1.2.15 implies Cacti 1.2.x, which requires PHP 8.0. The matrix
97-
# below starts at 8.1, so it cannot catch syntax the declared floor rejects.
98112
syntax-floor:
99113
name: PHP 8.0 syntax floor
100114
runs-on: ubuntu-latest

composer.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)