Check linting, format, test and linked issue #325
Workflow file for this run
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
| name: Check linting, format, test and linked issue | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| types: [opened, ready_for_review] | |
| branches: | |
| - stage | |
| - prod | |
| jobs: | |
| standards: | |
| name: Check coding standards | |
| if: github.event.pull_request.draft == false | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 3 | |
| permissions: | |
| issues: read | |
| pull-requests: write | |
| steps: | |
| - name: Checkout repository content | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v3 | |
| with: | |
| version: 10 | |
| - name: Check for folder changes | |
| id: filter | |
| uses: dorny/paths-filter@v2 | |
| with: | |
| filters: | | |
| ui: | |
| - 'packages/ui/**' | |
| app: | |
| - 'packages/app/**' | |
| - name: Install run dependencies if packages have changes | |
| if: steps.filter.outputs.ui == 'true' || steps.filter.outputs.app == 'true' | |
| run: pnpm install | |
| - name: linting | |
| if: steps.filter.outputs.ui == 'true' || steps.filter.outputs.app == 'true' | |
| run: pnpm lint | |
| - name: prettier check | |
| if: always() && ( steps.filter.outputs.ui == 'true' || steps.filter.outputs.app == 'true' ) | |
| run: pnpm check | |
| - name: frontend coverage report and build check | |
| if: always() && steps.filter.outputs.ui == 'true' | |
| run: | | |
| pnpm --filter ui coverage | |
| pnpm build | |
| - name: backend coverage report | |
| if: always() && steps.filter.outputs.app == 'true' | |
| run: pnpm --filter app coverage | |
| - name: Check linked issues | |
| if: always() | |
| id: linked-issues | |
| uses: nearform-actions/github-action-check-linked-issues@v1 | |
| with: | |
| exclude-branches: "release/**, dependabot/**" | |
| - name: Transfer Labels from Linked Issues | |
| if: always() && steps.linked-issues.outcome == 'success' | |
| uses: actions/github-script@v6 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const { owner, repo } = context.repo; | |
| const pr_number = context.issue.number; | |
| const linkedIssuesJson = '${{ steps.linked-issues.outputs.issues }}'; | |
| const linkedIssuesRaw = JSON.parse(linkedIssuesJson); | |
| const linkedIssues = linkedIssuesRaw.map(issueRef => { | |
| const parts = issueRef.split('#'); | |
| return parseInt(parts[parts.length - 1]); | |
| }).filter(num => !isNaN(num)); | |
| const allLabels = new Set(); | |
| for (const issueNumber of linkedIssues) { | |
| const linkedIssue = await github.rest.issues.get({ | |
| owner, | |
| repo, | |
| issue_number: issueNumber | |
| }); | |
| linkedIssue.data.labels.forEach(label => { | |
| allLabels.add(label.name); | |
| }); | |
| } | |
| if (allLabels.size === 0) { | |
| return; | |
| } | |
| const labelsArray = Array.from(allLabels); | |
| await github.rest.issues.addLabels({ | |
| owner, | |
| repo, | |
| issue_number: pr_number, | |
| labels: labelsArray | |
| }); | |
| - name: Assign PR to Author | |
| if: always() | |
| uses: actions/github-script@v6 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const { owner, repo } = context.repo; | |
| const issue_number = context.issue.number; | |
| const assignee = context.payload.pull_request.user.login; | |
| const { data: pullRequest } = await github.rest.pulls.get({ | |
| owner, | |
| repo, | |
| pull_number: issue_number | |
| }); | |
| if (pullRequest.assignees.length === 0) { | |
| try { | |
| await github.rest.orgs.checkMembershipForUser({ | |
| org: owner, | |
| username: assignee | |
| }); | |
| await github.rest.issues.addAssignees({ | |
| owner, | |
| repo, | |
| issue_number, | |
| assignees: [assignee] | |
| }); | |
| } catch (error) { | |
| console.log(`User ${assignee} is not a member of the organization.`); | |
| } | |
| } |