Skip to content

Commit 25bc375

Browse files
authored
[1.x] Remove StyleCI and update GH workflows (#31)
* replace StyleCI with Laravel Pint * Update github workflows * Dont install Pint on unsupported version of PHP
1 parent fb7e312 commit 25bc375

13 files changed

+319
-19
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Bug report
2+
description: Report a problem you're experiencing
3+
labels: bug,unconfirmed,low priority
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
Before opening a bug report, please search the existing issues (both open and closed).
9+
10+
---
11+
12+
Thank you for taking the time to file a bug report. To address this bug as fast as possible, we need some information.
13+
- type: input
14+
id: package-version
15+
attributes:
16+
label: Package Version
17+
description: Please provide the full version of the package you have installed.
18+
placeholder: v1.0.0
19+
validations:
20+
required: true
21+
- type: input
22+
id: laravel-version
23+
attributes:
24+
label: Laravel Version
25+
description: Please provide the full Laravel version of your project.
26+
placeholder: v10.0.0
27+
validations:
28+
required: true
29+
- type: input
30+
id: php-version
31+
attributes:
32+
label: PHP Version
33+
description: Please provide the full PHP version of your server.
34+
placeholder: PHP 8.3.0
35+
validations:
36+
required: true
37+
- type: textarea
38+
id: description
39+
attributes:
40+
label: Problem description
41+
description: What happened when you experienced the problem?
42+
validations:
43+
required: true
44+
- type: textarea
45+
id: expectation
46+
attributes:
47+
label: Expected behavior
48+
description: What did you expect to happen instead?
49+
validations:
50+
required: true
51+
- type: textarea
52+
id: steps
53+
attributes:
54+
label: Steps to reproduce
55+
description: Which steps do we need to take to reproduce the problem? Any code examples need to be **as short as possible**, remove any code that is unrelated to the bug. **This issue will be automatically closed and not reviewed if detailed replication steps are missing.**
56+
validations:
57+
required: true
58+
- type: input
59+
id: reproduction
60+
attributes:
61+
label: Reproduction repository
62+
description: The URL of a public GitHub repository which reproduces the problem. **Please do not link to your actual project**, what we need instead is a _minimal_ reproduction in a fresh project without any unnecessary code. This means it doesn\'t matter if your real project is private / confidential, since we want a link to a separate, isolated reproduction. This allows us to fix the problem much quicker. **This issue will be automatically closed and not reviewed if this is missing. Please make sure to format the URL starting with `https://github.com` - only repositories hosted on GitHub are accepted.**
63+
validations:
64+
required: true
65+
- type: textarea
66+
id: logs
67+
attributes:
68+
label: Relevant log output
69+
description: If applicable, provide relevant log output. No need for backticks here.
70+
render: shell

.github/ISSUE_TEMPLATE/config.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Feature request
4+
url: https://github.com/joelbutcher/laravel-facebook-graph/issues/new
5+
about: Share ideas for new features
6+
- name: Support question
7+
url: https://github.com/joelbutcher/laravel-facebook-graph/issues/new
8+
about: Ask the community for help
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: "Fix Code Styling"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
lint:
13+
uses: laravel/.github/.github/workflows/coding-standards.yml@main

.github/workflows/manage-issue.yml

+196
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
name: manage-issue
2+
3+
on:
4+
issues:
5+
types: [opened, edited]
6+
7+
jobs:
8+
check-repro:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/github-script@v3
12+
with:
13+
script: |
14+
const URL_REGEXP = /### Reproduction repository[\r\n]+([^#]+)###/m
15+
const REPRO_STEPS_REGEXP = /### Steps to reproduce[\r\n]+([^#]+)###/m
16+
const LABEL_NEEDS_MORE_INFORMATION = 'needs more info'
17+
18+
function debug(...args) {
19+
core.info(args.map(JSON.stringify).join(' '))
20+
}
21+
22+
if (context.payload.comment) {
23+
debug('Ignoring comment update.')
24+
25+
return
26+
}
27+
28+
const user = context.payload.sender.login
29+
const issue = context.payload.issue
30+
const body = issue.body
31+
const urlMatch = body.match(URL_REGEXP)
32+
const reproStepsMatch = body.match(REPRO_STEPS_REGEXP)
33+
const url = urlMatch !== null ? urlMatch[1].trim() : null
34+
const reproSteps = reproStepsMatch !== null ? reproStepsMatch[1].trim() : null
35+
36+
debug(`Found URL '${url}'`)
37+
debug(`Found repro steps '${reproSteps}'`)
38+
39+
async function createComment(comment) {
40+
comment = comment
41+
.split('\n')
42+
.map((line) => line.trim())
43+
.join('\n')
44+
.trim()
45+
46+
await github.issues.createComment({
47+
issue_number: context.issue.number,
48+
owner: context.repo.owner,
49+
repo: context.repo.repo,
50+
body: comment,
51+
})
52+
}
53+
54+
async function getGitHubActionComments() {
55+
debug(`Loading existing comments...`)
56+
57+
const comments = await github.issues.listComments({
58+
issue_number: context.issue.number,
59+
owner: context.repo.owner,
60+
repo: context.repo.repo,
61+
})
62+
63+
return comments.data.filter(comment => {
64+
debug(`comment by user: '${comment.user.login}'`)
65+
return comment.user.login === 'github-actions[bot]'
66+
})
67+
}
68+
69+
async function getIssueLabels() {
70+
const issues = await github.issues.listLabelsOnIssue({
71+
issue_number: context.issue.number,
72+
owner: context.repo.owner,
73+
repo: context.repo.repo,
74+
})
75+
76+
return issues.data
77+
}
78+
79+
async function updateIssue(state, state_reason = null) {
80+
await github.issues.update({
81+
owner: context.repo.owner,
82+
repo: context.repo.repo,
83+
issue_number: context.issue.number,
84+
state,
85+
state_reason,
86+
})
87+
}
88+
89+
async function closeWithComment(comment) {
90+
if (issue.state !== 'open') {
91+
debug(`Issue is not open`)
92+
93+
return
94+
}
95+
96+
const comments = await getGitHubActionComments()
97+
98+
if (comments.length > 0) {
99+
debug(`Already commented on issue won't comment again`)
100+
101+
return
102+
}
103+
104+
debug(`Missing required information`)
105+
106+
await github.issues.addLabels({
107+
issue_number: context.issue.number,
108+
owner: context.repo.owner,
109+
repo: context.repo.repo,
110+
labels: [LABEL_NEEDS_MORE_INFORMATION],
111+
})
112+
113+
await createComment(comment)
114+
115+
await updateIssue('closed', 'not_planned')
116+
}
117+
118+
async function openWithComment(comment) {
119+
if (issue.state !== 'closed') {
120+
debug(`Issue is already open`)
121+
122+
return
123+
}
124+
125+
const labels = await getIssueLabels()
126+
const label = labels.find(label => label.name === LABEL_NEEDS_MORE_INFORMATION)
127+
128+
if (! label) {
129+
debug(`Issue was not tagged as needs information`)
130+
131+
return
132+
}
133+
134+
const comments = await getGitHubActionComments()
135+
136+
if (comments.length === 0) {
137+
debug(`Issue was closed by someone else, won't reopen`)
138+
139+
return
140+
}
141+
142+
debug(`Reopening closed issue`)
143+
144+
await github.issues.removeLabel({
145+
issue_number: context.issue.number,
146+
owner: context.repo.owner,
147+
repo: context.repo.repo,
148+
name: LABEL_NEEDS_MORE_INFORMATION,
149+
})
150+
151+
await createComment(comment)
152+
153+
await updateIssue('open')
154+
}
155+
156+
const COMMENT_HEADER = `
157+
Hey @${user}! We're sorry to hear that you've hit this issue. 💙
158+
`.trim()
159+
160+
const NO_REPRO_URL = ((! url) || (! url.includes('https://github.com/')) || (url.includes('https://github.com/joelbutcher') && (! url.includes('https://github.com/joelbutcher/laravel-facebook-graph-demo'))))
161+
const NO_REPRO_STEPS = reproSteps.length < 25
162+
163+
if (NO_REPRO_URL || NO_REPRO_STEPS) {
164+
let comment = `
165+
${COMMENT_HEADER}
166+
167+
`
168+
169+
if (NO_REPRO_URL) {
170+
comment += `
171+
However, it looks like you forgot to fill in the reproduction repository URL. Can you edit your original post and then we'll look at your issue?
172+
173+
We need a public GitHub repository which contains a Laravel app with the minimal amount of Socialstream code to reproduce the problem. **Please do not link to your actual project**, what we need instead is a _minimal_ reproduction in a fresh project without any unnecessary code. This means it doesn\'t matter if your real project is private / confidential, since we want a link to a separate, isolated reproduction. That would allow us to download it and review your bug much easier, so it can be fixed quicker. Please make sure to include a database seeder with everything we need to set the app up quickly.
174+
`
175+
}
176+
177+
if (NO_REPRO_URL && NO_REPRO_STEPS) {
178+
comment += `
179+
180+
Also, `
181+
} else if (NO_REPRO_STEPS) {
182+
comment += `
183+
184+
However, `
185+
}
186+
187+
if (NO_REPRO_STEPS) {
188+
comment += `it doesn't look like you've provided much information on how to replicate the issue. Please edit your original post with clear steps we need to take.`
189+
}
190+
191+
closeWithComment(comment)
192+
} else {
193+
openWithComment(`
194+
Thank you for providing reproduction steps! Reopening the issue now.
195+
`)
196+
}

.github/workflows/tests.yml

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ jobs:
5555
tools: composer:v2
5656
coverage: none
5757

58+
- name: Remove Laravel Pint
59+
if: matrix.php == '7.3' || matrix.php == '7.4' || matrix.php == '8.0'
60+
run: composer remove --dev laravel/pint --no-update
61+
5862
- name: Install dependencies
5963
run: composer update --prefer-dist --no-interaction --no-progress
6064

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: update changelog
2+
3+
on:
4+
release:
5+
types: [released]
6+
7+
jobs:
8+
update:
9+
uses: laravel/.github/.github/workflows/update-changelog.yml@main

.styleci.yml

-5
This file was deleted.

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Release Notes

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"joelbutcher/facebook-graph-sdk": "^6.1.2"
2727
},
2828
"require-dev": {
29+
"laravel/pint": "^1.20",
2930
"mockery/mockery": "^1.4.2",
3031
"orchestra/testbench": "^6.0|^7.0|^9.0",
3132
"pestphp/pest": "^1.21|^2.34",

pint.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"preset": "per"
3+
}

src/FacebookServiceProvider.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected function mergeConfig(): void
6767
*/
6868
protected function getConfigPath(): string
6969
{
70-
return __DIR__.'/../config/config.php';
70+
return __DIR__ . '/../config/config.php';
7171
}
7272

7373
/**
@@ -90,7 +90,7 @@ protected function registerDefaultHttpClient(): void
9090
protected function registerUrlDetectionHandler(): void
9191
{
9292
$this->app->singleton(UrlDetectionInterface::class, function () {
93-
return new UrlDetectionHandler;
93+
return new UrlDetectionHandler();
9494
});
9595
}
9696

0 commit comments

Comments
 (0)