Skip to content

Commit

Permalink
Merge branch 'master' into issue-27155-ai-plugin-detection
Browse files Browse the repository at this point in the history
  • Loading branch information
oidacra authored Jan 5, 2024
2 parents c97e980 + f79dace commit 178733a
Show file tree
Hide file tree
Showing 163 changed files with 25,483 additions and 134,364 deletions.
171 changes: 41 additions & 130 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
@@ -1,154 +1,65 @@
name: Frontend
on:
pull_request:
types: [synchronize, opened, reopened, ready_for_review]
types: [opened, reopened, synchronize, ready_for_review]
paths:
- 'core-web/**'
push:
paths:
- 'core-web/**'
branches:
- master
- release-*
env:
EXCLUDED_PROJECTS: dot-rules,dot-layout-grid,dot-primeng-theme-styles,dot-rules,dotcms,dotcms-field-elements,dotcms-js,dotcms-models,dotcms-webcomponents,dotcdn-e2e,dotcms-block-editor,dotcms-block-editor-e2e,dotcms-ui-e2e,utils-testing,block-editor,utils,dojo-theme
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.CICD_GITHUB_TOKEN }}
PULL_REQUEST_URL: ${{ github.event.pull_request._links.html.href }}
IS_PULL_REQUEST: ${{ github.event_name == 'pull_request' }}
HEAD_REF: ${{ github.head_ref }}
jobs:
sonar:
outputs:
message: ${{ steps.persist_results.outputs.message }}
status: ${{ steps.persist_results.outputs.status }}
color: ${{ steps.persist_results.outputs.color }}
sonar_url: ${{ steps.persist_results.outputs.sonar_url }}
runs-on: ubuntu-20.04
name: SonarQube
steps:
- uses: actions/checkout@v3
- uses: sonarsource/sonarqube-scan-action@master
with:
projectBaseDir: core-web
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_DOTCMS_UI }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
- uses: sonarsource/sonarqube-quality-gate-action@master
id: sonarqube-quality-gate-check
with:
scanMetadataReportFile: core-web/.scannerwork/report-task.txt
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_DOTCMS_UI }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
- name: "Set results"
id: "persist_results"
if: always()
run: |
pull_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
final_sonar_url="dashboard?id=core-web&pullRequest=$pull_number"

echo "sonar_url=${final_sonar_url}" >>$GITHUB_OUTPUT
jobs:

# Check the value of the quality-gate-status output
if [ "${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }}" == "PASSED" ]; then
# Output success status, green color, and "All good!" message
echo "status=success" >>$GITHUB_OUTPUT
echo "color=#5E7D00" >>$GITHUB_OUTPUT
echo "message=All good!" >>$GITHUB_OUTPUT
elif [ "${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }}" == "FAILED" ]; then
# Output failure status, red color, and "Please check your PR" message
echo "status=failure" >>$GITHUB_OUTPUT
echo "color=#ff2400" >>$GITHUB_OUTPUT
echo "message=Please check your PR" >>$GITHUB_OUTPUT
else
# Output warning status, orange color, and "Maybe you can fix this warning" message
echo "status=warning" >>$GITHUB_OUTPUT
echo "color=#FFC107" >>$GITHUB_OUTPUT
echo "message=Maybe you can fix this warning" >>$GITHUB_OUTPUT
fi
notify-sonar:
runs-on: ubuntu-20.04
name: Notify Slack
needs: sonar
env:
SONAR_BRANCH_REPORT: ${{ needs.sonar.outputs.sonar_url }}
if: always()
steps:
- name: Send Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.UI_SLACK_WEBHOOK }}
SLACK_USERNAME: dotBot
SLACK_ICON: https://dotnet.libhunt.com/images/promo-ad-images/000/000/022/main.png?1640908816
SLACK_COLOR: ${{ needs.sonar.outputs.color }}
SLACK_TITLE: "SonarQube: ${{ needs.sonar.outputs.status }}"
SLACK_MESSAGE: ${{ needs.sonar.outputs.message }}
SLACK_FOOTER: ${{ env.PULL_REQUEST_URL }} - ${{ secrets.SONAR_HOST_URL }}/${{ env.SONAR_BRANCH_REPORT }}
check-all:
outputs:
name: ${{ steps.lint.outputs.name || steps.test.outputs.name || steps.build.outputs.name }}
status: ${{ steps.lint.outputs.status || steps.test.outputs.status || steps.build.outputs.status }}
color: ${{ steps.lint.outputs.color || steps.test.outputs.color || steps.build.outputs.color }}
message: ${{ steps.persist_results.outputs.message }}
runs-on: ubuntu-20.04

strategy:
matrix:
task:
- lint
- test
- build

name: Frontend Checks
steps: # what steps it will perform
- uses: actions/checkout@v3 # checkout whatever branch the PR is using
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16.14.2
cache: npm
cache-dependency-path: core-web/package-lock.json
- uses: bahmutov/npm-install@v1 # trigger an `npm install`

- name: Setup Node
uses: actions/setup-node@v4
with:
working-directory: core-web
- name: Lint
id: lint
node-version: 18.17.0
cache: yarn
cache-dependency-path: 'core-web/yarn.lock'

- name: Install Dependencies
run: yarn --frozen-lockfile
working-directory: core-web
run: |
if ! (npx nx affected --target=lint --base=origin/master --head=HEAD --parallel --exclude=${{ env.EXCLUDED_PROJECTS }}) then
echo "name=:x: Lint" >>$GITHUB_OUTPUT
echo "status=failure" >>$GITHUB_OUTPUT
echo "color=#ff2400" >>$GITHUB_OUTPUT
exit 1;
fi
- name: Test
id: test

- name: Run Nx Affected ${{ matrix.task }}
working-directory: core-web
run: |
if ! (npx nx affected --target=test --base=origin/master --head=HEAD --parallel --exclude=${{ env.EXCLUDED_PROJECTS }}) then
echo "name=:x: Test" >>$GITHUB_OUTPUT
echo "status=failure" >>$GITHUB_OUTPUT
echo "color=#ff2400" >>$GITHUB_OUTPUT
exit 1;
fi
- name: Build
id: build
working-directory: core-web
run: |
if ! (npx nx build dotcms-ui) then
echo "name=:x: Build" >>$GITHUB_OUTPUT
echo "status=failure" >>$GITHUB_OUTPUT
echo "color=#ff2400" >>$GITHUB_OUTPUT
exit 1;
if [ "${{ matrix.task }}" = "test" ] || [ "${{ matrix.task }}" = "lint" ]; then
exclude_option="--exclude=${{ env.EXCLUDED_PROJECTS }}"
if ! (npx nx affected --target=${{ matrix.task }} --base=origin/master --head=HEAD --parallel $exclude_option) then
echo "name=:x: ${{ matrix.task }}" >>$GITHUB_OUTPUT
echo "status=failure" >>$GITHUB_OUTPUT
echo "color=#ff2400" >>$GITHUB_OUTPUT
exit 1;
fi
elif [ "${{ matrix.task }}" = "build" ]; then
if ! (npx nx build dotcms-ui) then
echo "name=:x: ${{ matrix.task }}" >>$GITHUB_OUTPUT
echo "status=failure" >>$GITHUB_OUTPUT
echo "color=#ff2400" >>$GITHUB_OUTPUT
exit 1;
fi
fi
notify-check-all:
runs-on: ubuntu-20.04
name: Notify Slack
needs: check-all
if: always()
steps:
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.UI_SLACK_WEBHOOK }}
SLACK_USERNAME: dotBot
SLACK_ICON: https://avatars.slack-edge.com/2020-09-21/1362682893351_5b474f175640cf5f5912_72.png
SLACK_COLOR: ${{ needs.check-all.outputs.color && needs.check-all.outputs.color || '#5E7D00' }}
SLACK_TITLE: "${{ needs.check-all.outputs.name && needs.check-all.outputs.name || ':white_check_mark: Frontend Checks' }}: (${{ needs.check-all.outputs.status && needs.check-all.outputs.status || 'Success' }})"
SLACK_MESSAGE: ${{ needs.check-all.outputs.message && needs.check-all.outputs.message || 'Everything went well, ready to merge'}}
SLACK_FOOTER: ${{ env.PULL_REQUEST_URL }}
115 changes: 90 additions & 25 deletions core-web/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nrwl/nx", "eslint-plugin-import", "ban"],
"plugins": ["@nx", "eslint-plugin-import", "ban"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nrwl/nx/enforce-module-boundaries": [
"@nx/enforce-module-boundaries": [
"error",
{
"allowCircularSelfDependency": true,
Expand All @@ -24,7 +24,7 @@
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nrwl/nx/typescript"],
"extends": ["plugin:@nx/typescript"],
"rules": {
"@typescript-eslint/keyword-spacing": [
"error",
Expand Down Expand Up @@ -69,12 +69,30 @@
"no-duplicate-imports": "error",
"ban/ban": [
2,
{ "name": ["describe", "only"], "message": "don't focus tests" },
{ "name": "fdescribe", "message": "don't focus tests" },
{ "name": ["it", "only"], "message": "don't focus tests" },
{ "name": "fit", "message": "don't focus tests" },
{ "name": ["test", "only"], "message": "don't focus tests" },
{ "name": "ftest", "message": "don't focus tests" }
{
"name": ["describe", "only"],
"message": "don't focus tests"
},
{
"name": "fdescribe",
"message": "don't focus tests"
},
{
"name": ["it", "only"],
"message": "don't focus tests"
},
{
"name": "fit",
"message": "don't focus tests"
},
{
"name": ["test", "only"],
"message": "don't focus tests"
},
{
"name": "ftest",
"message": "don't focus tests"
}
],
"import/order": [
"error",
Expand All @@ -91,20 +109,66 @@
"type"
],
"pathGroups": [
{ "pattern": "@angular/**", "group": "external", "position": "after" },
{ "pattern": "primeng/**", "group": "external", "position": "after" },
{ "pattern": "rxjs/**", "group": "external", "position": "after" },
{ "pattern": "@tiptap/**", "group": "external", "position": "after" },
{ "pattern": "@components/**", "group": "internal" },
{ "pattern": "@directives/**", "group": "internal" },
{ "pattern": "@dotcms-ui/**", "group": "internal" },
{ "pattern": "@dotcms/**", "group": "internal" },
{ "pattern": "@portlets/**", "group": "internal" },
{ "pattern": "@models/**", "group": "internal" },
{ "pattern": "@pipes/**", "group": "internal" },
{ "pattern": "@services/**", "group": "internal" },
{ "pattern": "@shared/**", "group": "internal" },
{ "pattern": "@tests/**", "group": "internal" }
{
"pattern": "@angular/**",
"group": "external",
"position": "after"
},
{
"pattern": "primeng/**",
"group": "external",
"position": "after"
},
{
"pattern": "rxjs/**",
"group": "external",
"position": "after"
},
{
"pattern": "@tiptap/**",
"group": "external",
"position": "after"
},
{
"pattern": "@components/**",
"group": "internal"
},
{
"pattern": "@directives/**",
"group": "internal"
},
{
"pattern": "@dotcms-ui/**",
"group": "internal"
},
{
"pattern": "@dotcms/**",
"group": "internal"
},
{
"pattern": "@portlets/**",
"group": "internal"
},
{
"pattern": "@models/**",
"group": "internal"
},
{
"pattern": "@pipes/**",
"group": "internal"
},
{
"pattern": "@services/**",
"group": "internal"
},
{
"pattern": "@shared/**",
"group": "internal"
},
{
"pattern": "@tests/**",
"group": "internal"
}
],
"pathGroupsExcludedImportTypes": ["internal"],
"alphabetize": {
Expand All @@ -117,8 +181,9 @@
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nrwl/nx/javascript"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
}
]
],
"extends": ["plugin:storybook/recommended"]
}
1 change: 1 addition & 0 deletions core-web/.husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@

cd core-web
npx pretty-quick --staged
npx nx format:write
npm run nx affected -- --target=lint --exclude=dot-rules,dot-layout-grid,dot-primeng-theme-styles,dot-rules,dotcms,dotcms-field-elements,dotcms-js,dotcms-models,dotcms-webcomponents,dotcdn-e2e,dotcms-block-editor,dotcms-block-editor-e2e,dotcms-ui-e2e,utils-testing,dojo-theme --fix=true
cd ..
2 changes: 1 addition & 1 deletion core-web/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16.14.2
v18.17.0
23 changes: 21 additions & 2 deletions core-web/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,31 @@ module.exports = {
},
'@storybook/addon-actions'
],
stories: []

// uncomment the property below if you want to apply some webpack config globally
// webpackFinal: async (config, { configType }) => {
// // Make whatever fine-grained changes you need that should apply to all storybook configs

// // Return the altered config
// return config;
// },
stories: [],

framework: {
name: '@storybook/angular',
options: {
builder: {
useSWC: true
}
}
},

docs: {
autodocs: true
},

swc: (config, options) => {
return {
...config
};
}
};
Loading

0 comments on commit 178733a

Please sign in to comment.