-
Notifications
You must be signed in to change notification settings - Fork 27
PLASMA-7373: add Next.js build check #3022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TitanKuzmich
wants to merge
7
commits into
dev
Choose a base branch
from
PLASMA-7373-next-build
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0ebc2dd
docs: update docs errors
TitanKuzmich bc0fbaa
feat: update common libs file
TitanKuzmich c9e8826
chore: add next build command
TitanKuzmich 66d3ef2
feat: add Next.js check
TitanKuzmich e84229f
feat: remove custom command parse
TitanKuzmich fbae36e
feat: remove extra tgz
TitanKuzmich 6283b48
feat: add tgz to gitignore
TitanKuzmich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,207 @@ | ||
| name: Next.js build check | ||
|
|
||
| # Проверяет, что конечный пакет (packages/<pkg>) реально собирается внутри Next.js-приложения | ||
| # для конкретного build-варианта из его package.json#exports. | ||
| # | ||
| # Запуск: | ||
| # - комментарий в PR: /next-build <package> [build] | ||
| # (build не указан -> прогоняются все варианты из exports) | ||
| # - вручную через workflow_dispatch | ||
|
|
||
| on: | ||
| issue_comment: | ||
| types: [created] | ||
| workflow_dispatch: | ||
| inputs: | ||
| package: | ||
| description: 'Имя папки пакета под packages/, например sdds-serv' | ||
| required: true | ||
| type: string | ||
| build: | ||
| description: 'Ключ из exports, например "." или "styled-components". Пусто = все варианты.' | ||
| required: false | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.issue.number || github.event.inputs.package }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| parse-command: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| issues: write | ||
| pull-requests: read | ||
| outputs: | ||
| allowed: ${{ steps.parse.outputs.allowed }} | ||
| package: ${{ steps.parse.outputs.package }} | ||
| build: ${{ steps.parse.outputs.build }} | ||
| pr-number: ${{ steps.parse.outputs.pr-number }} | ||
| head-sha: ${{ steps.parse.outputs.head-sha }} | ||
| steps: | ||
| - name: Parse command and check authorization | ||
| id: parse | ||
| uses: actions/github-script@v9 | ||
| with: | ||
| script: | | ||
| if (context.eventName === 'workflow_dispatch') { | ||
| core.setOutput('allowed', 'true'); | ||
| core.setOutput('package', context.payload.inputs.package); | ||
| core.setOutput('build', context.payload.inputs.build || ''); | ||
| core.setOutput('pr-number', ''); | ||
| core.setOutput('head-sha', context.sha); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| const comment = context.payload.comment; | ||
| const issue = context.payload.issue; | ||
|
|
||
| if (!issue?.pull_request) { | ||
| core.setOutput('allowed', 'false'); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| const match = comment.body.match(/^\/next-build\s+([A-Za-z0-9_-]+)(?:\s+(\S+))?\s*$/m); | ||
|
|
||
| if (!match) { | ||
| core.setOutput('allowed', 'false'); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| const { data: access } = await github.rest.repos.getCollaboratorPermissionLevel({ | ||
| ...context.repo, | ||
| username: comment.user.login, | ||
| }); | ||
| const permissionLevels = { | ||
| none: 0, | ||
| read: 1, | ||
| triage: 2, | ||
| write: 3, | ||
| maintain: 4, | ||
| admin: 5, | ||
| }; | ||
|
|
||
| if ((permissionLevels[access.permission] || 0) < permissionLevels.write) { | ||
| core.setOutput('allowed', 'false'); | ||
| core.warning( | ||
| `/next-build triggered by ${comment.user.login} (${access.permission}) — not authorized, skipping.`, | ||
| ); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| const { data: pr } = await github.rest.pulls.get({ | ||
| ...context.repo, | ||
| pull_number: issue.number, | ||
| }); | ||
|
|
||
| core.setOutput('allowed', 'true'); | ||
| core.setOutput('package', match[1]); | ||
| core.setOutput('build', match[2] || ''); | ||
| core.setOutput('pr-number', String(issue.number)); | ||
| core.setOutput('head-sha', pr.head.sha); | ||
|
|
||
| await github.rest.reactions.createForIssueComment({ | ||
| ...context.repo, | ||
| comment_id: comment.id, | ||
| content: 'eyes', | ||
| }); | ||
|
|
||
| build: | ||
| name: Build (${{ needs.parse-command.outputs.package }} / ${{ needs.parse-command.outputs.build || 'all' }}) | ||
| needs: parse-command | ||
| if: ${{ needs.parse-command.outputs.allowed == 'true' }} | ||
| runs-on: ubuntu-22.04 | ||
| permissions: | ||
| contents: read | ||
| outputs: | ||
| results: ${{ steps.run-checks.outputs.results }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| show-progress: false | ||
| ref: ${{ needs.parse-command.outputs.head-sha }} | ||
| persist-credentials: false | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| package-manager-cache: false | ||
|
|
||
| - name: Validate package exists | ||
| env: | ||
| PKG: ${{ needs.parse-command.outputs.package }} | ||
| run: | | ||
| if [[ ! "$PKG" =~ ^[A-Za-z0-9_-]+$ ]]; then | ||
| echo "::error::Недопустимое имя пакета: $PKG" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ ! -f "packages/$PKG/package.json" ]; then | ||
| echo "::error::packages/$PKG не найден" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Install dependencies and build target package | ||
| env: | ||
| PKG: ${{ needs.parse-command.outputs.package }} | ||
| run: npm run setup:ci -- --scope="@salutejs/$PKG" --include-dependencies | ||
|
|
||
| - name: Run Next.js build check(s) | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| id: run-checks | ||
| env: | ||
| PKG: ${{ needs.parse-command.outputs.package }} | ||
| BUILD: ${{ needs.parse-command.outputs.build }} | ||
| run: | | ||
| set -e | ||
| STATUS=0 | ||
| RESULTS_FILE=$(mktemp) | ||
|
|
||
| if [ -n "$BUILD" ]; then | ||
| KEYS="$BUILD" | ||
| else | ||
| KEYS=$(node -e "console.log(Object.keys(require('./packages/${PKG}/package.json').exports).join(' '))") | ||
| fi | ||
|
|
||
| for KEY in $KEYS; do | ||
| if npx ts-node --project utils/next-build-check/tsconfig.json utils/next-build-check/cli.ts --package="$PKG" --build="$KEY" --ci; then | ||
| echo "- ✅ \`$KEY\`" >> "$RESULTS_FILE" | ||
| else | ||
| echo "- ❌ \`$KEY\`" >> "$RESULTS_FILE" | ||
| STATUS=1 | ||
| fi | ||
| done | ||
|
|
||
| { | ||
| echo "results<<NEXT_BUILD_RESULTS_EOF" | ||
| cat "$RESULTS_FILE" | ||
| echo "NEXT_BUILD_RESULTS_EOF" | ||
| } >> "$GITHUB_OUTPUT" | ||
|
|
||
| exit $STATUS | ||
|
|
||
| comment-result: | ||
| name: Report result | ||
| needs: [parse-command, build] | ||
| if: ${{ always() && github.event_name == 'issue_comment' && needs.parse-command.outputs.allowed == 'true' }} | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| pull-requests: write | ||
| steps: | ||
| - uses: marocchino/sticky-pull-request-comment@v2 | ||
| with: | ||
| number: ${{ needs.parse-command.outputs.pr-number }} | ||
| header: Next.js build check | ||
| message: | | ||
| **Пакет:** `${{ needs.parse-command.outputs.package }}` | ||
| **Build:** `${{ needs.parse-command.outputs.build || 'все варианты из exports' }}` | ||
|
|
||
| ${{ needs.build.outputs.results }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,3 +15,4 @@ s3_build | |
| temp | ||
| **/.DS_Store | ||
| **/.swc | ||
| *.tgz | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,4 @@ emotion/es | |
| styled-components/* | ||
| build-sb-draft | ||
| emotion/* | ||
| *.tgz | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,4 @@ emotion/es | |
| styled-components/* | ||
| build-sb-draft | ||
| emotion/* | ||
| *.tgz | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,4 @@ emotion/es | |
| styled-components/* | ||
| build-sb-draft | ||
| emotion/* | ||
| *.tgz | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,5 +31,6 @@ emotion/es | |
| styled-components/* | ||
| build-sb-draft | ||
| emotion/* | ||
| *.tgz | ||
|
|
||
| /ai-components-build-sb | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,4 @@ emotion/es | |
| styled-components/* | ||
| build-sb-draft | ||
| emotion/* | ||
| *.tgz | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,4 @@ emotion/es | |
| styled-components/* | ||
| build-sb-draft | ||
| emotion/* | ||
| *.tgz | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,4 @@ emotion/es | |
| styled-components/* | ||
| build-sb-draft | ||
| emotion/* | ||
| *.tgz | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,4 @@ emotion/es | |
| styled-components/* | ||
| build-sb-draft | ||
| emotion/* | ||
| *.tgz | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,4 @@ emotion/es | |
| styled-components/* | ||
| build-sb-draft | ||
| emotion/* | ||
| *.tgz | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,4 @@ emotion/es | |
| styled-components/* | ||
| build-sb-draft | ||
| emotion/* | ||
| *.tgz | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,4 @@ emotion/es | |
| styled-components/* | ||
| build-sb-draft | ||
| emotion/* | ||
| *.tgz | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,4 @@ emotion/es | |
| styled-components/* | ||
| build-sb-draft | ||
| emotion/* | ||
| *.tgz | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,4 @@ emotion/es | |
| styled-components/* | ||
| build-sb-draft | ||
| emotion/* | ||
| *.tgz | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,4 @@ emotion/es | |
| styled-components/* | ||
| build-sb-draft | ||
| emotion/* | ||
| *.tgz | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,4 @@ emotion/es | |
| styled-components/* | ||
| build-sb-draft | ||
| emotion/* | ||
| *.tgz | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,5 @@ emotion/es | |
| styled-components/* | ||
| build-sb-draft | ||
| emotion/* | ||
| *.tgz | ||
| *.tgz | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export const PACKAGES: string[]; | ||
| export const PACKAGE_MAP: Record<string, string>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| const PACKAGES = [ | ||
| 'b2c', | ||
| 'giga', | ||
| 'web', | ||
| 'cs', | ||
| 'insol', | ||
| 'insol-next', | ||
| 'netology', | ||
| 'bizcom', | ||
| 'serv', | ||
| 'scan', | ||
| 'os', | ||
| 'platform-ai', | ||
| 'finai', | ||
| 'dfa', | ||
| 'homeds', | ||
| ]; | ||
|
|
||
| const PACKAGE_MAP = { | ||
| b2c: 'plasma-b2c', | ||
| giga: 'plasma-giga', | ||
| web: 'plasma-web', | ||
| cs: 'sdds-cs', | ||
| insol: 'sdds-insol', | ||
| 'insol-next': 'sdds-insol-next', | ||
| netology: 'sdds-netology', | ||
| bizcom: 'sdds-bizcom', | ||
| serv: 'sdds-serv', | ||
| scan: 'sdds-scan', | ||
| os: 'sdds-os', | ||
| 'platform-ai': 'sdds-platform-ai', | ||
| finai: 'sdds-finai', | ||
| dfa: 'sdds-dfa', | ||
| homeds: 'plasma-homeds', | ||
| }; | ||
|
|
||
| module.exports = { PACKAGES, PACKAGE_MAP }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.