Skip to content

Commit

Permalink
:octocat:
Browse files Browse the repository at this point in the history
  • Loading branch information
codemasher committed May 21, 2024
1 parent 1ba085c commit d1184de
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 38 deletions.
20 changes: 20 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/.build export-ignore
/.config export-ignore
/.github export-ignore
/.idea export-ignore
/.phan export-ignore
/.phpdoc export-ignore
/docs export-ignore
/examples export-ignore
/public export-ignore
/tests export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.readthedocs.yml export-ignore
/phpcs.xml.dist export-ignore
/phpdoc.xml.dist export-ignore
/phpmd.xml.dist export-ignore
/phpunit.xml.dist export-ignore

*.php diff=php
29 changes: 19 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:

name: "Continuous Integration"

env:
PHP_EXTENSIONS: curl, fileinfo, intl, json, mbstring, simplexml, sodium, zlib
PHP_INI_VALUES: memory_limit=-1, error_reporting=-1, display_errors=On

jobs:

static-code-analysis:
Expand All @@ -23,28 +27,29 @@ jobs:
php-version:
- "8.1"
- "8.2"
- "8.3"

env:
PHAN_ALLOW_XDEBUG: 0
PHAN_DISABLE_XDEBUG_WARN: 1

steps:
- name: "Checkout"
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: "Install PHP"
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: ast, ${{ env.PHP_EXTENSIONS }}
ini-values: ${{ env.PHP_INI_VALUES }}
coverage: none
tools: pecl
extensions: ast, curl, json, mbstring, openssl, sodium

- name: "Update dependencies with composer"
uses: ramsey/composer-install@v2
uses: ramsey/composer-install@v3

- name: "Run phan"
run: php vendor/bin/phan
run: php vendor/bin/phan --target-php-version=${{ matrix.php-version }}

tests:
name: "Unit Tests"
Expand All @@ -60,24 +65,28 @@ jobs:
php-version:
- "8.1"
- "8.2"
- "8.3"

steps:
- name: "Checkout"
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: "Install PHP with extensions"
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: ${{ env.PHP_EXTENSIONS }}
ini-values: ${{ env.PHP_INI_VALUES }}
coverage: pcov
tools: pecl
extensions: curl, json, mbstring, openssl, sodium

- name: "Install dependencies with composer"
uses: ramsey/composer-install@v2
uses: ramsey/composer-install@v3

- name: "Run tests with phpunit"
run: php vendor/bin/phpunit --configuration=phpunit.xml.dist

# - name: "Send code coverage report to Codecov.io"
# uses: codecov/codecov-action@v3
# uses: codecov/codecov-action@v4
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# files: .build/coverage/clover.xml
3 changes: 2 additions & 1 deletion .phan/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
// Note that the **only** effect of choosing `'5.6'` is to infer
// that functions removed in php 7.0 exist.
// (See `backward_compatibility_checks` for additional options)
'target_php_version' => '8.1',
'target_php_version' => null,
'minimum_target_php_version' => '8.1',

// A list of directories that should be parsed for class and
// method information. After excluding the directories
Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,17 @@ jobs:

runs-on: ubuntu-latest

# requiired for stefanzweifel/git-auto-commit-action
permissions:
contents: write

env:
MASTODON_TOKEN: ${{ secrets.MASTODON_TOKEN }}
MASTODON_INSTANCE: ${{ secrets.MASTODON_INSTANCE }}

steps:
- name: "Checkout sources"
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: "Install PHP"
uses: shivammathur/setup-php@v2
Expand All @@ -58,7 +62,7 @@ jobs:
extensions: curl, json, mbstring, openssl, sodium

- name: "Install dependencies with composer"
uses: ramsey/composer-install@v2
uses: ramsey/composer-install@v3

- name: "Fetch cacert.pem from curl.haxx.se"
run: wget -O config/cacert.pem https://curl.se/ca/cacert.pem
Expand All @@ -68,10 +72,13 @@ jobs:

# please note that this requires read/write permissions for the actions runner!
- name: "Commit log"
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: ":octocat: posted toot"
file_pattern: 'data/posted.json'
commit_user_name: "github-actions[bot]"
commit_user_email: "41898282+github-actions[bot]@users.noreply.github.com"
commit_author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
```
## related projects
Expand Down
7 changes: 4 additions & 3 deletions cli/run.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
$options = new TootBotOptions;

// HTTPOptions
$options->ca_info = realpath(__DIR__.'/../config/cacert.pem'); // https://curl.haxx.se/ca/cacert.pem
$options->user_agent = 'phpTootBot/1.0 +https://github.com/php-tootbot/php-tootbot';
$options->retries = 3;
$options->ca_info = realpath(__DIR__.'/../config/cacert.pem'); // https://curl.haxx.se/ca/cacert.pem
$options->user_agent = 'phpTootBot/1.0 +https://github.com/php-tootbot/php-tootbot';
$options->timeout = 10;
$options->retries = 3;

// OAuthOptionsTrait
// these settings are only required for authentication/remote token acquisition
Expand Down
15 changes: 6 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,25 @@
"homepage":"https://github.com/php-tootbot/php-tootbot/graphs/contributors"
}
],
"minimum-stability": "dev",
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": "^8.1",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-openssl": "*",
"php-tootbot/php-tootbot": "dev-main#b2284114241e355be65aa817ac318e298eb2007e"
"chillerlan/php-settings-container": "^3.2",
"php-tootbot/php-tootbot": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^10.2",
"phpunit/phpunit": "^10.5",
"phan/phan": "^5.4"
},
"autoload": {
"psr-4": {
"PHPTootBot\\MyTootBot\\": "src/"
"PHPTootBot\\MyTootBot\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"PHPTootBot\\MyTootBotTest\\": "tests/"
"PHPTootBot\\MyTootBotTest\\": "tests"
}
},
"scripts": {
Expand Down
21 changes: 10 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResultFile=".build/phpunit.result.cache"
colors="true"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".build/phpunit.cache"
cacheResultFile=".build/phpunit.result.cache"
colors="true"
beStrictAboutCoverageMetadata="true"
>
<testsuites>
<testsuite name="tootbot-template test suite">
<directory suffix=".php">./tests/</directory>
<!--
<exclude>tests/SomeAbstractClass.php</exclude>
-->
<testsuite name="tootbot test suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>./src</directory>
<directory>src</directory>
</include>
</source>
<coverage>
Expand All @@ -25,7 +24,7 @@
</report>
</coverage>
<php>
<!-- whether the test runs on CI - set to false to allow debug output -->
<!-- whether the test runs on CI -->
<const name="TEST_IS_CI" value="true"/>
</php>
</phpunit>
2 changes: 1 addition & 1 deletion tests/MyTootBotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use PHPUnit\Framework\TestCase;

/**
*
* Tests the `MyTootBot` class
*/
class MyTootBotTest extends TestCase{

Expand Down

0 comments on commit d1184de

Please sign in to comment.