Skip to content

Commit

Permalink
Make it possible to set changed files (#14)
Browse files Browse the repository at this point in the history
* Make it possible to set changed files

* Send the name to the body as well

* Slightly better details

* Try to run tests on github instead

* Remove circleci try to fix tests

* Allow newer phpunit

* phpstan

* Allow phpunit 8

* Fix phpstan config

* Try to trigger CI

* Use level 5

* Update readme

* Test setter

* Typo

* Replace badge
  • Loading branch information
eiriksm authored Mar 27, 2022
1 parent 835ef73 commit 906b27a
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 50 deletions.
45 changes: 0 additions & 45 deletions .circleci/config.yml

This file was deleted.

69 changes: 69 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Test
on:
- push
- pull_request

jobs:
test:
name: Run tests
runs-on: 'ubuntu-20.04'
strategy:
fail-fast: false
matrix:
php-version:
- "7.0"
- "7.1"
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
composer-version:
- "1"
- "2"
steps:
- name: Dump matrix context
env:
MATRIX_CONTEXT: ${{ toJSON(matrix) }}
run: echo "$MATRIX_CONTEXT"

- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}

- name: Update composer
run: composer --verbose self-update --${{ matrix.composer-version }}

- name: Dump composer verson
run: composer --version

- name: Validate composer.json
run: composer --verbose validate

- name: Install dependencies
run: composer --verbose install

- name: Install some different dependencies if version is not php 7.0
if: matrix.php-version != 7.0
run: |
composer require --dev phpstan/phpstan
- name: Run tests
run: composer test

- run: composer validate

- name: Coveralls
if: matrix.php-version == 7.4
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
php vendor/bin/php-coveralls -v
- name: Run phpstan
if: matrix.php-version != 7.0
run: composer phpstan
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# violinist-messages

[![Build status](https://circleci.com/gh/violinist-dev/violinist-messages.svg?style=shield)](https://circleci.com/gh/violinist-dev/violinist-messages)
[![Test](https://github.com/violinist-dev/violinist-messages/actions/workflows/test.yml/badge.svg)](https://github.com/violinist-dev/violinist-messages/actions/workflows/test.yml)
[![Coverage Status](https://coveralls.io/repos/github/violinist-dev/violinist-messages/badge.svg?branch=master)](https://coveralls.io/github/violinist-dev/violinist-messages?branch=master)

Template(s) for the pull requests that we send on updates.
Expand Down Expand Up @@ -29,4 +29,8 @@ Currently it receives the following variables:

`custom_message`: A custom message, if configured.

`updated_list`: A list of the changes packages in the update.
`updated_list`: A list of the changed packages in the update.

`package`: The name of the package being updated.

`changed_files`: An array of the files changed in the update, if available.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
"twig/twig": "^1.23.1"
},
"scripts": {
"phpstan": "phpstan analyse src tests",
"test": "@composer lint && phpunit",
"lint": "phpcs -p -n"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.4",
"phpunit/phpunit": "^6.5",
"phpunit/phpunit": "^6.5 || ^7.0 || ^8.0",
"php-coveralls/php-coveralls": "^2.0"
}
}
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
parameters:
level: 5
2 changes: 1 addition & 1 deletion src/UpdateListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function isRemoved(): bool
}

/**
* @param bool $isNew
* @param bool $isRemoved
*/
public function setIsRemoved(bool $isRemoved)
{
Expand Down
2 changes: 2 additions & 0 deletions src/ViolinistMessages.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ public function getPullRequestBody(ViolinistUpdate $msg)
'updated_list' => $this->getUpdatedList($msg->getUpdatedList()),
'title' => $this->getPullRequestTitle($msg),
'changelog' => $msg->getChangelog(),
'changed_files' => $msg->getChangedFiles(),
'custom_message' => $msg->getCustomMessage(),
'package' => $msg->getName(),
]);
}

Expand Down
22 changes: 21 additions & 1 deletion src/ViolinistUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@ class ViolinistUpdate
*/
private $updatedList = [];

private $changedFiles = [];

/**
* @return array
*/
public function getChangedFiles(): array
{
return $this->changedFiles;
}

/**
* @param array $changedFiles
*/
public function setChangedFiles(array $changedFiles)
{
$this->changedFiles = $changedFiles;
}



/**
* @return UpdateListItem[]
*/
Expand All @@ -49,7 +69,7 @@ public function getUpdatedList()
}

/**
* @param UpdateListItem[]
* @param UpdateListItem[] $updatedList
*/
public function setUpdatedList(array $updatedList)
{
Expand Down
13 changes: 13 additions & 0 deletions templates/pull-request-body.twig
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ Some times an update also needs new or updated dependencies to be installed. Eve

</details>
{% endif %}
{% if changed_files %}
### Changed files

Here is a list of changed files between the version you use, and the version this pull request updates to:

<details>
<summary>List of changed files</summary>

{% for file in changed_files %}
{{ file }}
{% endfor %}
</details>
{% endif %}

{% if changelog %}
### Changelog
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/UnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public function testSetters()
$this->assertEquals('2', $update->getNewVersion());
$update->setCurrentVersion('1');
$this->assertEquals('1', $update->getCurrentVersion());
$update->setChangedFiles(['file1', 'file2']);
self::assertEquals(['file1', 'file2'], $update->getChangedFiles());
}

public function testLegacyFormat()
Expand Down

0 comments on commit 906b27a

Please sign in to comment.