-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Update docker and test configs #2678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
37cacb9
7cf995d
c71c2ec
10e1646
a35d382
ff1c906
b00e350
56beea9
288b78d
1ec3ec2
038df43
574deb0
68d79e4
2b4a0cb
4881f6b
8a36ebc
81e0d24
45f8069
b3c78f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: CI | ||
name: "CI" | ||
|
||
on: | ||
push: | ||
|
@@ -8,29 +8,32 @@ on: | |
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
name: PHP v${{ matrix.php }} with MongoDB ${{ matrix.mongodb }} ${{ matrix.mode }} | ||
runs-on: "${{ matrix.os }}" | ||
|
||
name: "PHP v${{ matrix.php }} with MongoDB ${{ matrix.mongodb }} ${{ matrix.mode }}" | ||
|
||
strategy: | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
- "ubuntu-latest" | ||
mongodb: | ||
- '4.4' | ||
- '5.0' | ||
- '6.0' | ||
- '7.0' | ||
- "4.4" | ||
- "5.0" | ||
- "6.0" | ||
- "7.0" | ||
php: | ||
- '8.1' | ||
- '8.2' | ||
- '8.3' | ||
- "8.1" | ||
- "8.2" | ||
- "8.3" | ||
include: | ||
- php: '8.1' | ||
mongodb: '5.0' | ||
mode: 'low-deps' | ||
- php: "8.1" | ||
mongodb: "5.0" | ||
mode: "low-deps" | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Create MongoDB Replica Set | ||
- uses: "actions/checkout@v4" | ||
|
||
- name: "Create MongoDB Replica Set" | ||
run: | | ||
docker run --name mongodb -p 27017:27017 -e MONGO_INITDB_DATABASE=unittest --detach mongo:${{ matrix.mongodb }} mongod --replSet rs --setParameter transactionLifetimeLimitSeconds=5 | ||
|
||
|
@@ -39,41 +42,49 @@ jobs: | |
sleep 1 | ||
done | ||
sudo docker exec --tty mongodb $MONGOSH_BIN 127.0.0.1:27017 --eval "rs.initiate({\"_id\":\"rs\",\"members\":[{\"_id\":0,\"host\":\"127.0.0.1:27017\" }]})" | ||
- name: Show MongoDB server status | ||
|
||
- name: "Show MongoDB server status" | ||
run: | | ||
if [ "${{ matrix.mongodb }}" = "4.4" ]; then MONGOSH_BIN="mongo"; else MONGOSH_BIN="mongosh"; fi | ||
docker exec --tty mongodb $MONGOSH_BIN 127.0.0.1:27017 --eval "db.runCommand({ serverStatus: 1 })" | ||
|
||
- name: "Installing php" | ||
uses: shivammathur/setup-php@v2 | ||
uses: "shivammathur/setup-php@v2" | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: curl,mbstring,xdebug | ||
coverage: xdebug | ||
tools: composer | ||
- name: Show PHP version | ||
run: php -v && composer -V | ||
- name: Show Docker version | ||
extensions: "curl,mbstring,xdebug" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not related to the changes, as those are CS changes. From the action-runners docs/readme
Does this get overridden with setting the extensions manually? |
||
coverage: "xdebug" | ||
tools: "composer" | ||
|
||
- name: "Show PHP version" | ||
run: "php -v && composer -V" | ||
|
||
hans-thomas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- name: "Show Docker version" | ||
run: if [[ "$DEBUG" == "true" ]]; then docker version && env; fi | ||
env: | ||
DEBUG: ${{secrets.DEBUG}} | ||
- name: Download Composer cache dependencies from cache | ||
id: composer-cache | ||
DEBUG: ${{ secrets.DEBUG }} | ||
|
||
- name: "Download Composer cache dependencies from cache" | ||
id: "composer-cache" | ||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
- name: Cache Composer dependencies | ||
uses: actions/cache@v3 | ||
|
||
- name: "Cache Composer dependencies" | ||
uses: "actions/cache@v3" | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ matrix.os }}-composer-${{ hashFiles('**/composer.json') }} | ||
restore-keys: ${{ matrix.os }}-composer- | ||
- name: Install dependencies | ||
key: "${{ matrix.os }}-composer-${{ hashFiles('**/composer.json') }}" | ||
restore-keys: "${{ matrix.os }}-composer-" | ||
|
||
- name: "Install dependencies" | ||
run: | | ||
composer update --no-interaction $([[ "${{ matrix.mode }}" == low-deps ]] && echo ' --prefer-lowest --prefer-stable') | ||
- name: Run tests | ||
run: | | ||
./vendor/bin/phpunit --coverage-clover coverage.xml | ||
|
||
- name: "Run tests" | ||
run: "composer test:coverage" | ||
env: | ||
MONGODB_URI: 'mongodb://127.0.0.1/?replicaSet=rs' | ||
- uses: codecov/codecov-action@v3 | ||
|
||
- uses: "codecov/codecov-action@v3" | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
fail_ci_if_error: false | ||
fail_ci_if_error: "false" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
ARG PHP_VERSION=8.1 | ||
|
||
FROM php:${PHP_VERSION}-cli | ||
FROM php:8.1-cli | ||
hans-thomas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Install extensions | ||
RUN apt-get update && \ | ||
apt-get install -y autoconf pkg-config libssl-dev git unzip libzip-dev zlib1g-dev && \ | ||
pecl install mongodb && docker-php-ext-enable mongodb && \ | ||
pecl install xdebug && docker-php-ext-enable xdebug && \ | ||
docker-php-ext-install -j$(nproc) zip | ||
|
||
COPY --from=composer:2.6.2 /usr/bin/composer /usr/local/bin/composer | ||
|
||
ENV COMPOSER_ALLOW_SUPERUSER=1 | ||
|
||
WORKDIR /code | ||
# Increase memory limit | ||
RUN cp /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini && \ | ||
echo "memory_limit=-1" >> /usr/local/etc/php/php.ini | ||
hans-thomas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
COPY ./ ./ | ||
# Enable coverage mode in xdebug | ||
RUN echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/xdebug.ini | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Xdebug mode is set to |
||
|
||
CMD ["bash", "-c", "composer install && ./vendor/bin/phpunit --testdox"] | ||
# Install Composer | ||
RUN curl https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer | ||
hans-thomas marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this change is based on a comment in another PR, but I wonder if it belongs in this PR. As in my eyes it is a code style thing, which adds a lot of noise to the PR. Personally I would create a separate PR to add these changes.
Though personally I don't see a benefit to these changes, but that's me and the project style is leading.