Skip to content

Commit

Permalink
Merge branch 'master' into feature/refactor-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
eucyt authored Dec 25, 2024
2 parents 5a2bea5 + b61ddc8 commit 1bd3c53
Show file tree
Hide file tree
Showing 18 changed files with 162 additions and 30 deletions.
117 changes: 117 additions & 0 deletions .github/workflows/create-draft-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Create Draft Release with Auto-Generated Notes

on:
workflow_dispatch:
inputs:
version_type:
description: "Select the version type to increment (major, minor, patch)"
required: true
type: choice
options:
- patch
- minor
- major
release_title:
description: "Enter the title of the release"
required: true
type: string
acknowledge_draft:
description: "I understand that I must re-edit and finalize the draft release (Y/N)"
required: true
type: choice
options:
- "No"
- "Yes"

jobs:
validate-input:
runs-on: ubuntu-latest
steps:
- name: Validate Acknowledgement
if: ${{ github.event.inputs.acknowledge_draft != 'Yes' }}
run: |
echo "You must select 'Yes' to acknowledge your responsibility for finalizing the draft release."
exit 1
- name: Validate title (no empty)
if: ${{ github.event.inputs.release_title == '' }}
run: |
echo "You must enter a title for the release."
exit 1
create-draft-release:
runs-on: ubuntu-latest
needs: validate-input

steps:
- uses: actions/checkout@v4
- name: Fetch Latest Release
id: get-latest-release
uses: actions/github-script@v7
with:
script: |
const latestRelease = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
}).catch(() => null);
if (latestRelease) {
core.setOutput('latest_tag', latestRelease.data.tag_name);
} else {
core.setOutput('latest_tag', 'v0.0.0'); // Default for first release
}
- name: Calculate New Version
id: calculate-version
uses: actions/github-script@v7
with:
script: |
const latestTag = '${{ steps.get-latest-release.outputs.latest_tag }}';
const versionType = '${{ github.event.inputs.version_type }}';
const [major, minor, patch] = latestTag.replace('v', '').split('.').map(Number);
let newVersion;
if (versionType === 'major') {
newVersion = `v${major + 1}.0.0`;
} else if (versionType === 'minor') {
newVersion = `v${major}.${minor + 1}.0`;
} else {
newVersion = `v${major}.${minor}.${patch + 1}`;
}
core.setOutput('new_version', newVersion);
- name: Generate Release Notes
id: generate-release-notes
uses: actions/github-script@v7
with:
script: |
const { data: releaseNotes } = await github.rest.repos.generateReleaseNotes({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: "${{ steps.calculate-version.outputs.new_version }}"
});
const actor = context.actor;
const noteToAdd = `**@${actor} 👈 TODO: Write detailed release note for this version before release**\n`;
const footer = `---\nThis release is prepared by @${actor}`;
const modifiedBody = releaseNotes.body.replace(
'## What\'s Changed',
`## What's Changed\n\n${noteToAdd}`
)
.concat(`\n\n${footer}`);
console.log(`releaseNotes (modified): ${JSON.stringify(modifiedBody, null, 2)}`);
core.setOutput("release_body", modifiedBody);
- name: Create Draft Release
run: |
gh release create "${{ steps.calculate-version.outputs.new_version }}" \
--title "${{ steps.calculate-version.outputs.new_version }} ${{ github.event.inputs.release_title }}" \
--notes "${{ steps.generate-release-notes.outputs.release_body }}" \
--draft \
--repo "${{ github.repository }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 changes: 20 additions & 4 deletions .github/workflows/diff-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,34 @@ jobs:
## Run if diff exists and event is not pull request, and make PR
- if: ${{ github.event_name != 'pull_request' && env.DIFF_IS_EMPTY != 'true' }}
run: |
BRANCH_NAME="update-diff-${{ env.CURRENT_DATETIME }}"
git config user.name github-actions
git config user.email [email protected]
git checkout -b update-diff-${{ env.CURRENT_DATETIME }}
git checkout -b $BRANCH_NAME
git add line-openapi
git add src/**
git commit --allow-empty -m "Codes are generated by openapi generator"
git add docs/**
git commit --allow-empty -m "Update document"
git commit --allow-empty -m "Update document"
git push origin $BRANCH_NAME
git push origin update-diff-${{ env.CURRENT_DATETIME }}
gh pr create -B ${{ github.ref_name }} -t "Codes are generated by openapi generator" -b "" --label "line-openapi-update"
# Determine PR title and body
if [ "$CHANGE_TYPE" == "submodule-update" ]; then
# Fetch PR info from submodule
npx zx ./line-openapi/tools/get-pr-info.mjs
PR_INFO=$(cat pr_info.json)
TITLE=$(echo "$PR_INFO" | jq -r '.title')
BODY=$(echo "$PR_INFO" | jq -r '.url')$'\n\n'$(echo "$PR_INFO" | jq -r '.body')
else
# Default PR title and body
TITLE="Codes are generated by openapi generator"
BODY="⚠Reviewer: Please edit this description to include relevant information about the changes.⚠"
fi
gh pr create -B ${{ github.ref_name }} -H $BRANCH_NAME -t "$TITLE" -b "$BODY" --label "line-openapi-update"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
},
"require-dev": {
"phpmd/phpmd": "2.15.0",
"squizlabs/php_codesniffer": "3.11.1",
"squizlabs/php_codesniffer": "3.11.2",
"orchestra/testbench": "*",
"guzzlehttp/guzzle": "^7.3",
"guzzlehttp/psr7": "^1.7 || ^2.0",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan": "^2.0",
"phpunit/phpunit": "^10.2"
},
"autoload": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,7 @@ <h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
: <span class="phpdocumentor-signature__argument__return-type">array&lt;string, <a href="classes/LINE-Clients-MessagingApi-Model-SubstitutionObject.html"><abbr title="\LINE\Clients\MessagingApi\Model\SubstitutionObject">SubstitutionObject</abbr></a>&gt;|null</span>
</dt>
<dd class="phpdocumentor-argument-list__definition">
<section class="phpdocumentor-description"><p>A mapping that specifies substitutions for parts enclosed in } within the 'text' field.</p>
<section class="phpdocumentor-description"><p>A mapping that specifies substitutions for parts enclosed in } within the <code class="prettyprint">text</code> field.</p>
</section>

</dd>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,7 @@ <h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
: <span class="phpdocumentor-signature__argument__return-type">array&lt;string, <a href="classes/LINE-Clients-MessagingApi-Model-SubstitutionObject.html"><abbr title="\LINE\Clients\MessagingApi\Model\SubstitutionObject">SubstitutionObject</abbr></a>&gt;|null</span>
</dt>
<dd class="phpdocumentor-argument-list__definition">
<section class="phpdocumentor-description"><p>A mapping that specifies substitutions for parts enclosed in } within the 'text' field.</p>
<section class="phpdocumentor-description"><p>A mapping that specifies substitutions for parts enclosed in } within the <code class="prettyprint">text</code> field.</p>
</section>

</dd>
Expand Down
8 changes: 4 additions & 4 deletions docs/classes/LINE-Laravel-Tests-Facades-FacadesTest.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ <h5 class="phpdocumentor-tag-list__heading" id="tags">
</dt>
<dd class="phpdocumentor-tag-list__definition">

<section class="phpdocumentor-description"><p>(PHPMD.CouplingBetweenObjects)</p>
<section class="phpdocumentor-description"><p>(&quot;PHPMD.CouplingBetweenObjects&quot;)</p>
</section>

</dd>
Expand Down Expand Up @@ -294,7 +294,7 @@ <h5 class="phpdocumentor-tag-list__heading" id="tags">
</dt>
<dd class="phpdocumentor-tag-list__definition">

<section class="phpdocumentor-description"><p>(PHPMD.UnusedFormalParameter)</p>
<section class="phpdocumentor-description"><p>(&quot;PHPMD.UnusedFormalParameter&quot;)</p>
</section>

</dd>
Expand Down Expand Up @@ -352,7 +352,7 @@ <h5 class="phpdocumentor-tag-list__heading" id="tags">
</dt>
<dd class="phpdocumentor-tag-list__definition">

<section class="phpdocumentor-description"><p>(PHPMD.UnusedFormalParameter)</p>
<section class="phpdocumentor-description"><p>(&quot;PHPMD.UnusedFormalParameter&quot;)</p>
</section>

</dd>
Expand Down Expand Up @@ -410,7 +410,7 @@ <h5 class="phpdocumentor-tag-list__heading" id="tags">
</dt>
<dd class="phpdocumentor-tag-list__definition">

<section class="phpdocumentor-description"><p>(PHPMD.UnusedFormalParameter)</p>
<section class="phpdocumentor-description"><p>(&quot;PHPMD.UnusedFormalParameter&quot;)</p>
</section>

</dd>
Expand Down
2 changes: 1 addition & 1 deletion docs/classes/LINE-Parser-EventRequestParser.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ <h5 class="phpdocumentor-tag-list__heading" id="tags">
</dt>
<dd class="phpdocumentor-tag-list__definition">

<section class="phpdocumentor-description"><p>(PHPMD.CouplingBetweenObjects)</p>
<section class="phpdocumentor-description"><p>(&quot;PHPMD.CouplingBetweenObjects&quot;)</p>
</section>

</dd>
Expand Down
2 changes: 1 addition & 1 deletion docs/classes/LINE-Parser-Tests-EventRequestParserTest.html
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ <h4 class="phpdocumentor-element__name" id="method_getSignature">
<aside class="phpdocumentor-element-found-in">
<abbr class="phpdocumentor-element-found-in__file" title="src/parser/test/EventRequestParserTest.php"><a href="files/src-parser-test-eventrequestparsertest.html"><abbr title="src/parser/test/EventRequestParserTest.php">EventRequestParserTest.php</abbr></a></abbr>
:
<span class="phpdocumentor-element-found-in__line">1715</span>
<span class="phpdocumentor-element-found-in__line">1714</span>

</aside>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
use LINE\Constants\MessageType;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings("PHPMD.CouplingBetweenObjects")
*/
class FlexSampleRestaurant
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
use LINE\Constants\MessageType;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings("PHPMD.CouplingBetweenObjects")
*/
class FlexSampleShopping
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
use LINE\Webhook\Model\MessageEvent;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings("PHPMD.CouplingBetweenObjects")
*/
class ImageMessageHandler implements EventHandler
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
use LINE\Webhook\Model\TextMessageContent;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings("PHPMD.CouplingBetweenObjects")
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
* @SuppressWarnings("PHPMD.ExcessiveMethodLength")
*/
class TextMessageHandler implements EventHandler
{
Expand Down
2 changes: 1 addition & 1 deletion src/clients/messaging-api/lib/Model/TextMessageV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ public function getSubstitution()
/**
* Sets substitution
*
* @param array<string,\LINE\Clients\MessagingApi\Model\SubstitutionObject>|null $substitution A mapping that specifies substitutions for parts enclosed in {} within the 'text' field.
* @param array<string,\LINE\Clients\MessagingApi\Model\SubstitutionObject>|null $substitution A mapping that specifies substitutions for parts enclosed in {} within the `text` field.
*
* @return self
*/
Expand Down
2 changes: 1 addition & 1 deletion src/clients/messaging-api/lib/Model/TextMessageV2AllOf.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ public function getSubstitution()
/**
* Sets substitution
*
* @param array<string,\LINE\Clients\MessagingApi\Model\SubstitutionObject>|null $substitution A mapping that specifies substitutions for parts enclosed in {} within the 'text' field.
* @param array<string,\LINE\Clients\MessagingApi\Model\SubstitutionObject>|null $substitution A mapping that specifies substitutions for parts enclosed in {} within the `text` field.
*
* @return self
*/
Expand Down
8 changes: 4 additions & 4 deletions src/laravel/test/Facades/FacadesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
namespace LINE\Laravel\Tests\Facades;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings("PHPMD.CouplingBetweenObjects")
*/
class FacadesTest extends \Orchestra\Testbench\TestCase
{
/**
* Load package service provider
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
* @param \Illuminate\Foundation\Application $app
* @return array
*/
Expand All @@ -38,7 +38,7 @@ protected function getPackageProviders($app)
/**
* Load package alias
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
* @param \Illuminate\Foundation\Application $app
* @return array
*/
Expand Down Expand Up @@ -69,7 +69,7 @@ public function testConfigLoaded()
/**
* Testing LINEBot facade instance
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
* @return void
*/
public function testLINEBotFacadeInstance()
Expand Down
2 changes: 1 addition & 1 deletion src/parser/lib/EventRequestParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
use LINE\Webhook\Model\UserMentionee;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings("PHPMD.CouplingBetweenObjects")
*/
class EventRequestParser
{
Expand Down
3 changes: 1 addition & 2 deletions src/parser/test/EventRequestParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1234,11 +1234,10 @@ public function testParseEventRequest()
$this->assertEquals('__unknown__', $event->jsonSerialize()->type); // with unprocessed event body
$this->assertEquals(12345678901234, $event->getTimestamp());
$this->assertEquals('active', $event->getMode());
$this->assertTrue($source instanceof UserSource);
$this->assertInstanceOf(UserSource::class, $source);
$this->assertEquals('userid', $source->getUserId());
$this->assertEquals('testwebhookeventid', $event->getWebhookEventId());
$this->assertFalse($event->getDeliveryContext()->getIsRedelivery());
$this->assertEquals(true, $source instanceof UserSource);
}

{
Expand Down

0 comments on commit 1bd3c53

Please sign in to comment.