From a73f32ea2879689bb1ceeee582e31e5332d156b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Fri, 23 Oct 2020 11:50:06 +0300 Subject: [PATCH 01/11] Setup .github/workflows/release.yml to release via github actions Copied from https://github.com/composer/composer/blob/49a28f606c289f59dd54187a87acb4f8837f90eb/.github/workflows/release.yml --- .github/workflows/release.yml | 75 +++++++++++++++++++++++++++++++++++ README.md | 1 + eventum-cvs-hook.php | 2 +- helpers.php | 23 ++++++++--- 4 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7255735 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,75 @@ +name: "Release" + +on: + push: + tags: + - "*" + +env: + COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --no-suggest --prefer-dist" + +jobs: + build: + name: Upload Release Asset + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + extensions: "intl" + ini-values: "memory_limit=-1" + php-version: "7.4" + + - name: "Install dependencies from composer.lock using composer binary provided by system" + run: "composer install ${{ env.COMPOSER_FLAGS }}" + + - name: "Run install again using composer binary from source" + run: "bin/composer install ${{ env.COMPOSER_FLAGS }}" + + - name: "Validate composer.json" + run: "bin/composer validate" + + - name: Build phar file + run: "php -d phar.readonly=0 bin/compile" + + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + draft: true + body: TODO + + - name: Upload phar + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./composer.phar + asset_name: composer.phar + asset_content_type: application/octet-stream + + # This step requires a secret token with `pull` access to composer/docker. The default + # secrets.GITHUB_TOKEN is scoped to this repository only which is not sufficient. + - name: "Open issue @ Docker repository" + uses: actions/github-script@v2 + with: + github-token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} + script: | + // github.ref value looks like 'refs/tags/TAG', cleanup + const tag = "${{ github.ref }}".replace(/refs\/tags\//, ''); + // create new issue on Docker repository + github.issues.create({ + owner: "${{ github.repository_owner }}", + repo: "docker", + title: `New Composer tag: ${ tag }`, + body: `https://github.com/${{ github.repository }}/releases/tag/${ tag }`, + }); diff --git a/README.md b/README.md index c1318c0..2f13565 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ REV="$2" ## Git + * Setup in your git repo `hooks/post-receive`: ```sh diff --git a/eventum-cvs-hook.php b/eventum-cvs-hook.php index 6dccada..fa4f8f9 100755 --- a/eventum-cvs-hook.php +++ b/eventum-cvs-hook.php @@ -46,7 +46,7 @@ function main($context) $commit_msg = cvs_commit_msg($context['stdin']); // parse the commit message and get all issue numbers we can find - $issues = match_issues($commit_msg); + $issues = match_issues($commit_msg, $context['eventum_url']); if (!$issues) { return; } diff --git a/helpers.php b/helpers.php index 50a0d45..09d6ec3 100644 --- a/helpers.php +++ b/helpers.php @@ -91,14 +91,27 @@ function fileparts($abspath) * parse the commit message and get all issue numbers we can find * * @param string $commit_msg + * @param string|null $eventum_url * @return array */ -function match_issues($commit_msg) +function match_issues($commit_msg, $eventum_url = null) { - preg_match_all('/(?:issue|bug) ?:? ?#?(\d+)/i', $commit_msg, $matches); - - if (count($matches[1]) > 0) { - return $matches[1]; + $url_quoted = $eventum_url ? preg_quote($eventum_url, '/') : ''; + + preg_match_all("/ + (?: + # match issue xxx and bug xxx + (?i:issue|bug)\s*:?\s*#? + | + # match url + {$url_quoted}/view\.php\?id= + ) + + (?P\d+) + /x", $commit_msg, $matches); + + if (count($matches['issue_id']) > 0) { + return $matches['issue_id']; } return null; From 008109f0747f739767a44f2819af4732c7826231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 25 Oct 2020 14:57:32 +0200 Subject: [PATCH 02/11] Add github action for tess Copied from https://github.com/GitLabPHP/Client/blob/d1e80b5d764ec0f042253f75863ed946ae914e13/.github/workflows/tests.yml --- .github/workflows/tests.yml | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..49b3771 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,45 @@ +name: Tests + +on: + push: + pull_request: + +jobs: + tests: + name: PHP ${{ matrix.php }} + runs-on: ubuntu-20.04 + + strategy: + matrix: + php: ['7.1', '7.2', '7.3', '7.4'] + + steps: + - name: Checkout Code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer:v2 + coverage: none + + - name: Setup Problem Matchers + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: Install Dependencies + uses: nick-invision/retry@v1 + with: + timeout_minutes: 5 + max_attempts: 5 + command: composer update --no-interaction --no-progress + + - name: Install PHPUnit + uses: nick-invision/retry@v1 + with: + timeout_minutes: 5 + max_attempts: 5 + command: composer bin phpunit update --no-interaction --no-progress + + - name: Execute PHPUnit + run: vendor/bin/phpunit From e2f7756bc30ae4458e642333d8824fc8d1f2c694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 25 Oct 2020 15:01:55 +0200 Subject: [PATCH 03/11] Add php 5.x versions --- .github/workflows/tests.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 49b3771..35e15bc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,7 +11,16 @@ jobs: strategy: matrix: - php: ['7.1', '7.2', '7.3', '7.4'] + php: + - 5.3 + - 5.4 + - 5.5 + - 5.6 + - 7.0 + - 7.1 + - 7.2 + - 7.3 + - 7.4 steps: - name: Checkout Code From 2185fab380fb7ee3b9f00bc8ed3870395e92a720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 25 Oct 2020 15:12:29 +0200 Subject: [PATCH 04/11] No composer, phpunit here, run just phar --- .github/workflows/tests.yml | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 35e15bc..2fbc6ae 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,25 +30,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - tools: composer:v2 coverage: none - - name: Setup Problem Matchers - run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - - name: Install Dependencies - uses: nick-invision/retry@v1 - with: - timeout_minutes: 5 - max_attempts: 5 - command: composer update --no-interaction --no-progress - - - name: Install PHPUnit - uses: nick-invision/retry@v1 - with: - timeout_minutes: 5 - max_attempts: 5 - command: composer bin phpunit update --no-interaction --no-progress - - - name: Execute PHPUnit - run: vendor/bin/phpunit + - name: Make PHAR + run: make From 9462a7c117120f3f9c45a44b0f92be1179c02700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 25 Oct 2020 15:13:55 +0200 Subject: [PATCH 05/11] Quote values for yaml --- .github/workflows/tests.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2fbc6ae..258128a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,15 +12,15 @@ jobs: strategy: matrix: php: - - 5.3 - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - 7.1 - - 7.2 - - 7.3 - - 7.4 + - "5.3" + - "5.4" + - "5.5" + - "5.6" + - "7.0" + - "7.1" + - "7.2" + - "7.3" + - "7.4" steps: - name: Checkout Code From 0e04da08eb9fbd0237fe8c6289fd61811b8ae39a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 25 Oct 2020 15:17:07 +0200 Subject: [PATCH 06/11] fixup! No composer, phpunit here, run just phar --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 258128a..e54a350 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -33,4 +33,4 @@ jobs: coverage: none - name: Make PHAR - run: make + run: make phar From d14ae157986c2e333d75b0e1e4286a38584fc20b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 25 Oct 2020 15:17:44 +0200 Subject: [PATCH 07/11] Add yaml header --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e54a350..47020f8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -34,3 +34,5 @@ jobs: - name: Make PHAR run: make phar + +# vim:ft=yaml:et:ts=2:sw=2 From f1bec6c6c81192dbe4915b946f7633bae556f765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 25 Oct 2020 15:18:21 +0200 Subject: [PATCH 08/11] Attempt to disable tools --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 47020f8..1f83592 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,6 +30,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} + tools: ~ coverage: none - name: Make PHAR From 2ff30c2dc3985136b80c341f4251dd3084a7e8f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 25 Oct 2020 15:35:44 +0200 Subject: [PATCH 09/11] Install box --- .github/workflows/tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1f83592..c637bf1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -33,6 +33,9 @@ jobs: tools: ~ coverage: none + - name: Install box + run: make box.phar + - name: Make PHAR run: make phar From 6e9201fc2b95bb939cf53163f3e78caab3bd86d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 25 Oct 2020 15:36:01 +0200 Subject: [PATCH 10/11] Disable composer tool install --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c637bf1..b57c2ac 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,7 +30,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - tools: ~ + tools: :composer coverage: none - name: Install box From 788d5177dcd1b448f492dc273a48570440045580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 25 Oct 2020 20:02:25 +0200 Subject: [PATCH 11/11] try none --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b57c2ac..432b940 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,7 +30,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - tools: :composer + tools: none coverage: none - name: Install box