diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 99ced91..922e5ee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,48 +9,39 @@ name: Release jobs: build: name: Create Release - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - - name: Set RELEASE_VERSION - run: echo RELEASE_VERSION=$(echo ${GITHUB_REF:10}) >> $GITHUB_ENV - - - name: Checkout code - uses: actions/checkout@v1 - name: Setup PHP - uses: nanasess/setup-php@v3 + uses: shivammathur/setup-php@v2 with: + ## box.phar requires php72 php-version: '7.4' + tools: composer:v2 + extensions: pcntl + + - name: Set env + run: | + echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV + + - name: Checkout code + uses: actions/checkout@v3 - name: Validate composer.json and composer.lock run: composer validate - name: Build PHAR - run: ./scripts/build.sh + run: ./scripts/build.sh && mv dist/git-scan.phar dist/git-scan-${{ env.RELEASE_VERSION }}.phar continue-on-error: false - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + - name: Create release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} + draft: true + prerelease: false body: | Changes in this Release - First Change - Second Change - draft: true - prerelease: false - - - name: Upload PHAR - id: upload_release - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./bin/git-scan.phar - asset_name: git-scan-${{ env.RELEASE_VERSION }}.phar - asset_content_type: application/octet-stream + files: dist/git-scan-*.phar diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7b2eabe..8ce095f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,22 +11,31 @@ jobs: runs-on: ${{ matrix.operating-system }} strategy: matrix: - operating-system: [ ubuntu-18.04 ] - php: [ '7.2', '7.4', '8.0', '8.1' ] include: - - operating-system: windows-2019 - php: '7.2' - #operating-system: [ ubuntu-18.04, windows-2019 ] - #php: [ '7.2', '7.4', '8.0' ] + - operating-system: ubuntu-latest + php: 7.3 + phpunit: 8 + - operating-system: ubuntu-latest + php: 7.4 + phpunit: 8 + - operating-system: ubuntu-latest + php: 8.1 + phpunit: 9 + - operating-system: ubuntu-latest + php: 8.3 + phpunit: 9 + ## We used to test here, but we were forced to switch to newer actions. + ## But these actions don't seem to run on Windows... + #- operating-system: windows-2019 + # php: '7.3' + # phpunit: 8 name: PHP ${{ matrix.php }} steps: - uses: actions/checkout@v3 - - name: Setup PHP - uses: nanasess/setup-php@v3 + - uses: php-actions/composer@v6 + - name: PHPUnit Tests + uses: php-actions/phpunit@v3 with: - php-version: ${{ matrix.php }} - - name: Validate composer.json and composer.lock - run: composer validate - - name: Set example Git user - run: git config --global user.email "testbot@example.com" && git config --global user.name "Test Bot" - - run: ./scripts/test.sh + configuration: phpunit.xml.dist + version: ${{ matrix.phpunit }} + php_version: ${{ matrix.php }} diff --git a/box.json b/box.json index e86ac48..3178004 100644 --- a/box.json +++ b/box.json @@ -12,6 +12,6 @@ ], "git-version": "package_version", "main": "bin/git-scan", - "output": "bin/git-scan.phar", + "output": "dist/git-scan.phar", "stub": true } \ No newline at end of file diff --git a/composer.json b/composer.json index f0e9086..e495c02 100644 --- a/composer.json +++ b/composer.json @@ -9,11 +9,12 @@ } ], "require": { - "php": ">=7.2", + "php": ">=7.3.0", "symfony/console": "^4.4", "symfony/process": "^4.4", "symfony/filesystem": "^4.4", - "symfony/finder": "^4.4" + "symfony/finder": "^4.4", + "civicrm/composer-downloads-plugin": "~3.0" }, "autoload": { "psr-0": { @@ -24,6 +25,21 @@ "bin/git-scan" ], "config": { - "bin-dir": "bin" + "platform": { + "php": "7.3.0" + }, + "bin-dir": "bin", + "allow-plugins": { + "civicrm/composer-downloads-plugin": true + } + }, + "extra": { + "downloads": { + "box": { + "url": "https://github.com/humbug/box/releases/download/3.16.0/box.phar", + "path": "extern/box", + "type": "phar" + } + } } } diff --git a/composer.lock b/composer.lock index d81d8cc..b7b0a75 100644 --- a/composer.lock +++ b/composer.lock @@ -4,29 +4,40 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "03f507a3bd15876d586975fdddfa6af9", + "content-hash": "59bae10d7028af1914a2558243ed6135", "packages": [ { - "name": "psr/container", - "version": "1.1.1", + "name": "civicrm/composer-downloads-plugin", + "version": "v3.0.1", "source": { "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf" + "url": "https://github.com/civicrm/composer-downloads-plugin.git", + "reference": "3aabb6d259a86158d01829fc2c62a2afb9618877" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf", - "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf", + "url": "https://api.github.com/repos/civicrm/composer-downloads-plugin/zipball/3aabb6d259a86158d01829fc2c62a2afb9618877", + "reference": "3aabb6d259a86158d01829fc2c62a2afb9618877", "shasum": "" }, "require": { - "php": ">=7.2.0" + "composer-plugin-api": "^1.1 || ^2.0", + "php": ">=5.6", + "togos/gitignore": "~1.1.1" + }, + "require-dev": { + "composer/composer": "~1.0 || ~2.0", + "friendsofphp/php-cs-fixer": "^2.3", + "phpunit/phpunit": "^5.7", + "totten/process-helper": "^1.0.1" + }, + "type": "composer-plugin", + "extra": { + "class": "LastCall\\DownloadsPlugin\\Plugin" }, - "type": "library", "autoload": { "psr-4": { - "Psr\\Container\\": "src/" + "LastCall\\DownloadsPlugin\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -35,47 +46,41 @@ ], "authors": [ { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" + "name": "Rob Bayliss", + "email": "rob@lastcallmedia.com" + }, + { + "name": "Tim Otten", + "email": "totten@civicrm.org" } ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], - "time": "2021-03-05T17:36:06+00:00" + "description": "Composer plugin for downloading additional files within any composer package.", + "support": { + "source": "https://github.com/civicrm/composer-downloads-plugin/tree/v3.0.1" + }, + "time": "2020-11-02T05:26:23+00:00" }, { - "name": "psr/log", - "version": "1.1.4", + "name": "psr/container", + "version": "1.1.1", "source": { "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + "url": "https://github.com/php-fig/container.git", + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf", + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=7.2.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1.x-dev" - } - }, "autoload": { "psr-4": { - "Psr\\Log\\": "Psr/Log/" + "Psr\\Container\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -88,14 +93,16 @@ "homepage": "https://www.php-fig.org/" } ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", "keywords": [ - "log", - "psr", - "psr-3" + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" ], - "time": "2021-05-03T11:20:27+00:00" + "time": "2021-03-05T17:36:06+00:00" }, { "name": "symfony/console", @@ -184,72 +191,6 @@ ], "time": "2022-06-23T12:22:25+00:00" }, - { - "name": "symfony/debug", - "version": "v4.4.41", - "source": { - "type": "git", - "url": "https://github.com/symfony/debug.git", - "reference": "6637e62480b60817b9a6984154a533e8e64c6bd5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/6637e62480b60817b9a6984154a533e8e64c6bd5", - "reference": "6637e62480b60817b9a6984154a533e8e64c6bd5", - "shasum": "" - }, - "require": { - "php": ">=7.1.3", - "psr/log": "^1|^2|^3" - }, - "conflict": { - "symfony/http-kernel": "<3.4" - }, - "require-dev": { - "symfony/http-kernel": "^3.4|^4.0|^5.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Debug\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides tools to ease debugging PHP code", - "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "abandoned": "symfony/error-handler", - "time": "2022-04-12T15:19:55+00:00" - }, { "name": "symfony/deprecation-contracts", "version": "v2.5.2", @@ -865,17 +806,57 @@ } ], "time": "2022-05-30T19:17:29+00:00" + }, + { + "name": "togos/gitignore", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/TOGoS/PHPGitIgnore.git", + "reference": "32bc0830e4123f670adcbf5ddda5bef362f4f4d4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/TOGoS/PHPGitIgnore/zipball/32bc0830e4123f670adcbf5ddda5bef362f4f4d4", + "reference": "32bc0830e4123f670adcbf5ddda5bef362f4f4d4", + "shasum": "" + }, + "require": { + "php": ">=5.2" + }, + "require-dev": { + "togos/simpler-test": "1.1.1" + }, + "type": "library", + "autoload": { + "psr-0": { + "TOGoS_GitIgnore_": "src/main/php/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Parser for .gitignore (and sparse-checkout, and anything else using the same format) files", + "support": { + "issues": "https://github.com/TOGoS/PHPGitIgnore/issues", + "source": "https://github.com/TOGoS/PHPGitIgnore/tree/master" + }, + "time": "2019-04-19T19:16:58+00:00" } ], "packages-dev": [], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.2" + "php": ">=7.3.0" + }, + "platform-dev": {}, + "platform-overrides": { + "php": "7.3.0" }, - "platform-dev": [], - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.6.0" } diff --git a/scripts/build.sh b/scripts/build.sh index 1b3819e..dee5606 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +## This script generates git-scan.phar. +## NOTE: as written, it will *not* work within nix-shell, but it will work on non-nix environments. + ## Determine the absolute path of the directory with the file ## usage: absdirname function absdirname() { @@ -8,17 +11,11 @@ function absdirname() { popd >> /dev/null } -SCRIPTDIR=$(absdirname "$0") -PRJDIR=$(dirname "$SCRIPTDIR") -set -ex - -BOX_VERSION=3.16.0 -BOX_URL="https://github.com/humbug/box/releases/download/${BOX_VERSION}/box.phar" -BOX_DIR="$PRJDIR/extern/box-$BOX_VERSION" -BOX_BIN="$BOX_DIR/box" -[ ! -f "$BOX_BIN" ] && ( mkdir -p "$BOX_DIR" ; curl -L "$BOX_URL" -o "$BOX_BIN" ) +SCRDIR=$(absdirname "$0") +PRJDIR=$(dirname "$SCRDIR") +export PATH="$PRJDIR/extern:$PATH" -pushd "$PRJDIR" >> /dev/null - composer install --prefer-dist --no-progress --no-suggest --no-dev - php -d phar.read_only=0 "$BOX_BIN" build -v -popd >> /dev/null +set -ex +composer install --prefer-dist --no-progress --no-suggest --no-dev +which box +php -d phar.read_only=0 `which box` build -v diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 1803a22..d513015 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -18,3 +18,9 @@ #### Extra - Register classes in "tests" directory $loader->add('GitScan', __DIR__); + +$userEmail = trim(shell_exec('git config --get user.email')); +if (strpos($userEmail, '(none)') !== false || $userEmail === '') { + shell_exec('git config --global user.email "testbot@example.com"'); + shell_exec('git config --global user.name "Test Bot"'); +} \ No newline at end of file