Skip to content
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

fix: all test cases not passing for commit on external repository #3838

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 19 additions & 69 deletions .github/workflows/if-nodejs-pr-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,93 +31,43 @@ jobs:
)
id: should_run
name: Should Run
run: echo "shouldrun=true" >> $GITHUB_OUTPUT
run: echo "shouldrun=true" >> $GITHUB_ENV
shell: bash
- if: steps.should_run.outputs.shouldrun == 'true'
name: Set git to use LF #to once and for all finish neverending fight between Unix and Windows

- if: env.shouldrun == 'true'
name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
shell: bash
- if: steps.should_run.outputs.shouldrun == 'true'

- if: env.shouldrun == 'true'
name: Checkout repository
uses: actions/checkout@v4
with:
# Checkout the merge commit instead of the pull request head commit for a pull request
# Fallback to the head commit if its not a pull request
ref: ${{ github.event.pull_request.number != '' && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.ref }}

- if: steps.should_run.outputs.shouldrun == 'true'
- if: env.shouldrun == 'true'
name: Check if Node.js project and has package.json
id: packagejson
run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT
shell: bash
- if: steps.packagejson.outputs.exists == 'true'
name: Check if .nvmrc exists
id: nvmrc
run: test -e .nvmrc && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT
shell: bash
- if: steps.nvmrc.outputs.exists == 'true'
name: Read Node.js version from .nvmrc
id: nodeversion
run: echo "version=$(cat .nvmrc)" >> $GITHUB_OUTPUT
shell: bash
- if: steps.packagejson.outputs.exists == 'true' && steps.nvmrc.outputs.exists == 'true'
name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '${{ steps.nodeversion.outputs.version }}'
- name: Install dependencies
run: npm ci
- if: steps.packagejson.outputs.exists == 'true'
name: Test
run: npm test --if-present
- if: steps.packagejson.outputs.exists == 'true' && matrix.os == 'ubuntu-latest'
name: Run linter
run: npm run lint --if-present
- if: steps.packagejson.outputs.exists == 'true'
name: Run release assets generation to make sure PR does not break it
run: test -e ./package.json && echo "exists=true" >> $GITHUB_ENV || echo "exists=false" >> $GITHUB_ENV
shell: bash
run: npm run generate:assets --if-present

# Run the test:md script and capture output
- if: ${{ steps.packagejson.outputs.exists == 'true' && matrix.os == 'ubuntu-latest' }}
name: Run markdown checks
id: markdown_check
run: |
ERRORS=$(npm run test:md | sed -n '/Errors in file/,$p')
echo "markdown_output<<EOF" >> $GITHUB_OUTPUT
echo "$ERRORS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

# Post a comment using sticky-pull-request-comment
- name: Comment on PR with markdown issues
if: ${{ steps.markdown_check.outputs.markdown_output != '' && matrix.os == 'ubuntu-latest' }}
uses: marocchino/sticky-pull-request-comment@3d60a5b2dae89d44e0c6ddc69dd7536aec2071cd
with:
header: markdown-check-error
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
message: |
### Markdown Check Results

We found issues in the following markdown files:
- if: env.packagejson == 'true'
name: Install dependencies
run: npm ci

```
${{ steps.markdown_check.outputs.markdown_output }}
```
- if: env.packagejson == 'true'
name: Run Tests
run: npm test --if-present

# Delete the comment if there are no issues
- if: ${{ steps.markdown_check.outputs.markdown_output == '' && matrix.os == 'ubuntu-latest' }}
name: Delete markdown check comment
uses: marocchino/sticky-pull-request-comment@3d60a5b2dae89d44e0c6ddc69dd7536aec2071cd
with:
header: markdown-check-error
delete: true
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- if: env.packagejson == 'true' && matrix.os == 'ubuntu-latest'
name: Run Linter
run: npm run lint --if-present

- if: steps.packagejson.outputs.exists == 'true'
- if: env.packagejson == 'true'
name: Upload Coverage to Codecov
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
files: ./coverage/lcov.info
Expand Down
51 changes: 16 additions & 35 deletions .github/workflows/lighthouse-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,51 +14,35 @@ jobs:
steps:
- if: >
!github.event.pull_request.draft && !(
(github.actor == 'asyncapi-bot' && (
startsWith(github.event.pull_request.title, 'ci: update global workflows') ||
startsWith(github.event.pull_request.title, 'chore: update code of conduct') ||
startsWith(github.event.pull_request.title, 'ci: update global contribution guide') ||
startsWith(github.event.pull_request.title, 'ci: update workflows for go projects') ||
startsWith(github.event.pull_request.title, 'ci: update workflows for nodejs projects') ||
startsWith(github.event.pull_request.title, 'ci: update release-related workflows for nodejs projects') ||
startsWith(github.event.pull_request.title, 'ci: update semantic release config file') ||
startsWith(github.event.pull_request.title, 'ci: update generic workflows') ||
startsWith(github.event.pull_request.title, 'ci: update workflows for docker-based projects') ||
startsWith(github.event.pull_request.title, 'chore(release):')
)) ||
(github.actor == 'allcontributors[bot]' &&
startsWith(github.event.pull_request.title, 'docs: add')
)
github.actor == 'asyncapi-bot' || github.actor == 'allcontributors[bot]'
)
id: should_run
name: Should Run
run: echo "shouldrun=true" >> $GITHUB_OUTPUT
run: echo "shouldrun=true" >> $GITHUB_ENV

Comment on lines +21 to 22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Setting Environment Variable for 'shouldrun'.
Using $GITHUB_ENV to set shouldrun is consistent with our updated practices. Please check and remove any trailing spaces that might be present after this command to satisfy YAML linting requirements.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 22-22: trailing spaces

(trailing-spaces)

- if: steps.should_run.outputs.shouldrun == 'true'
uses: actions/checkout@v3
- if: env.shouldrun == 'true'
uses: actions/checkout@v4

- if: steps.should_run.outputs.shouldrun == 'true'
- if: env.shouldrun == 'true'
name: Await Netlify Preview
uses: jakepartusch/wait-for-netlify-action@f1e137043864b9ab9034ae3a5adc1c108e3f1a48 #version 1.4 https://github.com/JakePartusch/wait-for-netlify-action/releases/tag/v1.4
uses: jakepartusch/[email protected]
id: netlify
with:
site_name: asyncapi-website
max_timeout: 600

- if: steps.should_run.outputs.shouldrun == 'true'
- if: env.shouldrun == 'true'
name: Lighthouse Audit
id: lighthouse_audit
uses: treosh/lighthouse-ci-action@03becbfc543944dd6e7534f7ff768abb8a296826 #version 10.1 https://github.com/treosh/lighthouse-ci-action/releases/tag/10.1.0
uses: treosh/[email protected]
with:
urls: |
https://deploy-preview-$PR_NUMBER--asyncapi-website.netlify.app/
https://deploy-preview-${{ github.event.pull_request.number }}--asyncapi-website.netlify.app/
configPath: ./.github/workflows/lighthouserc.json
uploadArtifacts: true
temporaryPublicStorage: true
env:
PR_NUMBER: ${{ github.event.pull_request.number}}

- if: steps.should_run.outputs.shouldrun == 'true'
- if: env.shouldrun == 'true'
name: Lighthouse Score Report
id: lighthouse_score_report
uses: actions/github-script@v6
Expand All @@ -71,23 +55,20 @@ jobs:
Object.keys(result).forEach(key => result[key] = formatResult(result[key]))
const score = res => res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴'
const comment = [
`⚡️ [Lighthouse report](${Object.values(links)[0]}) for the changes in this PR:`,
`⚡️ [Lighthouse report](${Object.values(links)[0]}) for this PR:`,
'| Category | Score |',
'| --- | --- |',
`| ${score(result.performance)} Performance | ${result.performance} |`,
`| ${score(result.accessibility)} Accessibility | ${result.accessibility} |`,
`| ${score(result['best-practices'])} Best practices | ${result['best-practices']} |`,
`| ${score(result['best-practices'])} Best Practices | ${result['best-practices']} |`,
`| ${score(result.seo)} SEO | ${result.seo} |`,
`| ${score(result.pwa)} PWA | ${result.pwa} |`,
' ',
`*Lighthouse ran on [${Object.keys(links)[0]}](${Object.keys(links)[0]})*`
`| ${score(result.pwa)} PWA | ${result.pwa} |`
].join('\n')
core.setOutput("comment", comment);
core.setOutput("comment", comment);

- if: steps.should_run.outputs.shouldrun == 'true'
- if: env.shouldrun == 'true'
name: LightHouse Statistic Comment
id: lighthouse_statistic_comment
uses: marocchino/sticky-pull-request-comment@efaaab3fd41a9c3de579aba759d2552635e590fd # version 2.8 https://github.com/marocchino/sticky-pull-request-comment/releases/tag/v2.8.0
uses: marocchino/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
number: ${{ github.event.pull_request.number }}
Expand Down
29 changes: 12 additions & 17 deletions .github/workflows/lint-pr-title.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# This action is centrally managed in https://github.com/asyncapi/.github/
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo

# Centrally managed in asyncapi/.github repo
name: Lint PR title

on:
Expand All @@ -12,35 +10,32 @@ jobs:
name: Lint PR title
runs-on: ubuntu-latest
steps:
# Since this workflow is REQUIRED for a PR to be mergable, we have to have this 'if' statement in step level instead of job level.
- if: ${{ !contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]", "allcontributors[bot]"]'), github.actor) }}
uses: amannn/action-semantic-pull-request@c3cd5d1ea3580753008872425915e343e351ab54 #version 5.2.0 https://github.com/amannn/action-semantic-pull-request/releases/tag/v5.2.0
- if: >
!contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]", "allcontributors[bot]"]'), github.actor)
uses: amannn/[email protected]
id: lint_pr_title
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN}}
with:
subjectPattern: ^(?![A-Z]).+$
subjectPatternError: |
The subject "{subject}" found in the pull request title "{title}" should start with a lowercase character.
The subject "{subject}" in the PR title "{title}" should start with a lowercase letter.

# Comments the error message from the above lint_pr_title action
- if: ${{ always() && steps.lint_pr_title.outputs.error_message != null && !contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]", "allcontributors[bot]"]'), github.actor)}}
- if: ${{ always() && steps.lint_pr_title.outputs.error_message != null }}
name: Comment on PR
uses: marocchino/sticky-pull-request-comment@3d60a5b2dae89d44e0c6ddc69dd7536aec2071cd #use 2.5.0 https://github.com/marocchino/sticky-pull-request-comment/releases/tag/v2.5.0
uses: marocchino/[email protected]
with:
header: pr-title-lint-error
GITHUB_TOKEN: ${{ secrets.GH_TOKEN}}
message: |

We require all PRs to follow [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/).
More details 👇🏼
We require all PRs to follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
```
${{ steps.lint_pr_title.outputs.error_message}}
${{ steps.lint_pr_title.outputs.error_message }}
```
# deletes the error comment if the title is correct

- if: ${{ steps.lint_pr_title.outputs.error_message == null }}
name: delete the comment
uses: marocchino/sticky-pull-request-comment@3d60a5b2dae89d44e0c6ddc69dd7536aec2071cd #use 2.5.0 https://github.com/marocchino/sticky-pull-request-comment/releases/tag/v2.5.0
name: Delete PR title lint comment
uses: marocchino/[email protected]
with:
header: pr-title-lint-error
delete: true
Expand Down
2 changes: 1 addition & 1 deletion components/AlgoliaSearch.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-underscore-dangle */
import type { DocSearchHit, InternalDocSearchHit, StoredDocSearchHit } from '@docsearch/react';
import { DocSearchModal } from '@docsearch/react';
import type { DocSearchHit, InternalDocSearchHit, StoredDocSearchHit } from '@docsearch/react/dist/esm/types';
import clsx from 'clsx';
import Head from 'next/head';
import Link from 'next/link';
Expand Down
2 changes: 1 addition & 1 deletion components/CommunityEvents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const CommunityEvents = () => {
</div>
<div className='mt-10'>
{!events || events.length === 0 ? (
<div className='flex content-center justify-center'>
<div className='flex place-content-center'>
<Paragraph typeStyle={ParagraphTypeStyle.md} className='mx-auto mt-5 max-w-2xl'>
No Events. Check back later!
</Paragraph>
Expand Down
6 changes: 3 additions & 3 deletions components/navigation/MobileNavMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default function MobileNavMenu({
<div className='space-y-2 px-5 py-2' onClick={() => showMenu('learning')} data-testid='MobileNav-docs'>
<h4 className='flex justify-between font-medium text-gray-800'>
{' '}
<Link href='/docs' className='cursor-pointer flex'>
<Link href='/docs' className='flex cursor-pointer'>
Docs
</Link>
<NavItemDropdown />
Expand All @@ -95,7 +95,7 @@ export default function MobileNavMenu({
<div className='space-y-2 px-5 py-2' onClick={() => showMenu('tooling')} data-testid='MobileNav-tools'>
<h4 className='flex justify-between font-medium text-gray-800'>
{' '}
<Link href='/tools' className='cursor-pointer flex'>
<Link href='/tools' className='flex cursor-pointer'>
Tools
</Link>
<NavItemDropdown />
Expand All @@ -104,7 +104,7 @@ export default function MobileNavMenu({
</div>
<div className='space-y-2 px-5 py-2' onClick={() => showMenu('community')} data-testid='MobileNav-community'>
<h4 className='flex justify-between font-medium text-gray-800'>
<Link href='/community' className='cursor-pointer flex'>
<Link href='/community' className='flex cursor-pointer'>
Community
</Link>
<NavItemDropdown />
Expand Down
Loading