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

Feat/5 ci style #11

Merged
merged 8 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
104 changes: 48 additions & 56 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,59 +1,51 @@
{
"env": {
"browser": true,
"es2021": true
},
"root": true,
"extends": [
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended",
"plugin:markdown/recommended"
"env": {
"browser": true,
"es2021": true
},
"root": true,
"extends": [
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
"prettier/@typescript-eslint",
"eslint:recommended",
"plugin:markdown/recommended"
],
"overrides": [],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["typescript-sort-keys", "simple-import-sort", "unused-imports"],
"rules": {
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"typescript-sort-keys/string-enum": [
"error",
"asc",
{
"caseSensitive": true
}
],
"overrides": [],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"typescript-sort-keys",
"simple-import-sort",
"unused-imports"
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/naming-convention": [
"warn",
{
"selector": "enum",
"format": ["StrictPascalCase"]
}
],
"rules": {
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"typescript-sort-keys/string-enum": [
"error",
"asc",
{
"caseSensitive": true
}
],
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/naming-convention": [
"warn",
{
"selector": "enum",
"format": [
"StrictPascalCase"
]
}
],
"curly": [
"warn",
"all"
],
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "_",
"varsIgnorePattern": "_",
"caughtErrorsIgnorePattern": "_"
}
]
}
}
"curly": ["warn", "all"],
"no-unused-vars": "off",
"no-empty": "warn",
"@typescript-eslint/no-unused-vars": [
"warn", // TODO: change back to "error" after removing all unused vars.
{
"argsIgnorePattern": "_",
"varsIgnorePattern": "_",
"caughtErrorsIgnorePattern": "_"
}
]
}
}
9 changes: 9 additions & 0 deletions .github/lighthouse/lighthouse-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"ci": {
"collect": {
"settings": {
"preset": "desktop"
}
}
}
}
134 changes: 134 additions & 0 deletions .github/workflows/check-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: Check Benchmarks & Deploy
env:
VERCEL_TEAM_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
on:
push:

jobs:
check-uniswap-benchmarks:
name: Check uniswap Benchmarks
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 18.20.4
cache: 'yarn'
cache-dependency-path: yarn.lock

- name: Install Dependencies
run: yarn install

- name: Check Licensure
id: check_licensure
run: yarn run check-licensure

- name: Run Linter
run: yarn lint

- name: Check Type Correctness
run: yarn run tsc --noEmit

- name: Check Formatting
run: yarn prettier --check .

audit_with_lighthouse:
name: Audit with Lighthouse
runs-on: ubuntu-latest
if: github.ref != 'refs/head/main' && github.ref != 'refs/heads/prod'
permissions:
contents: write
pull-requests: write
defaults:
run:
working-directory: ./
steps:
# Step 1: Retrieve the Vercel Preview URL
- name: vercel-preview-url
uses: zentered/[email protected]
id: vercel_preview_url
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
with:
vercel_project_id: ${{ secrets.VERCEL_PROJECT_ID }}
vercel_team_id: ${{ secrets.VERCEL_ORG_ID }}

# Step 2: Wait for the Vercel deployment to be ready
- uses: UnlyEd/github-action-await-vercel@v1
id: await-vercel
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
with:
deployment-url: ${{ steps.vercel_preview_url.outputs.preview_url }}
timeout: 420
poll-interval: 15

- uses: actions/checkout@v3
- name: Audit preview URL with Lighthouse (mobile)
id: lighthouse_audit_mobile
uses: treosh/lighthouse-ci-action@v9
with:
urls: |
https://${{ steps.vercel_preview_url.outputs.preview_url }}
uploadArtifacts: true
temporaryPublicStorage: true

- name: Audit preview URL with Lighthouse (desktop)
id: lighthouse_audit
uses: treosh/lighthouse-ci-action@v9
with:
urls: |
https://${{ steps.vercel_preview_url.outputs.preview_url }}
uploadArtifacts: true
temporaryPublicStorage: true
configPath: .github/lighthouse/lighthouse-config.json

- name: Format Lighthouse score
id: format_lighthouse_score
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const mobileLinks = ${{ steps.lighthouse_audit_mobile.outputs.links }};
const mobileResult = ${{ steps.lighthouse_audit_mobile.outputs.manifest }}[0].summary;
const desktopLinks = ${{ steps.lighthouse_audit.outputs.links }};
const desktopResult = ${{ steps.lighthouse_audit.outputs.manifest }}[0].summary;
const previewUrl = "https://${{ steps.vercel_preview_url.outputs.preview_url }}";
const formatResult = (res) => Math.round((res * 100));
const score = res => res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴';
Object.keys(mobileResult).forEach(key => mobileResult[key] = formatResult(mobileResult[key]));
Object.keys(desktopResult).forEach(key => desktopResult[key] = formatResult(desktopResult[key]));
const comment = [
`## ⚡️ Lighthouse Report`,
`### Mobile ([view report](${Object.values(mobileLinks)[0]}))`,
'| Category | Score |',
'| --- | --- |',
`| ${score(mobileResult.performance)} Performance | ${mobileResult.performance} |`,
`| ${score(mobileResult.accessibility)} Accessibility | ${mobileResult.accessibility} |`,
`| ${score(mobileResult['best-practices'])} Best practices | ${mobileResult['best-practices']} |`,
`| ${score(mobileResult.seo)} SEO | ${mobileResult.seo} |`,
` `,
`### Desktop ([view report](${Object.values(desktopLinks)[0]}))`,
'| Category | Score |',
'| --- | --- |',
`| ${score(desktopResult.performance)} Performance | ${desktopResult.performance} |`,
`| ${score(desktopResult.accessibility)} Accessibility | ${desktopResult.accessibility} |`,
`| ${score(desktopResult['best-practices'])} Best practices | ${desktopResult['best-practices']} |`,
`| ${score(desktopResult.seo)} SEO | ${desktopResult.seo} |`,
` `,
`*Lighthouse ran on [${previewUrl}](${previewUrl})*`
].join('\n');
core.setOutput("comment", comment);
- name: Add comment to PR
uses: mshick/add-pr-comment@v1
with:
message: |
${{ steps.format_lighthouse_score.outputs.comment }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token-user-login: 'github-actions[bot]' # The user.login for temporary GitHub tokens
allow-repeats: false # This is the default
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18.20.4

- name: Install dependencies
run: yarn --frozen-lockfile
Expand Down
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
**/.git
**/.svn
**/.hg
*.mdx
*.mdx
*.md
*.hbs
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 18.20.4
8 changes: 4 additions & 4 deletions docs/contracts/permit2/_category_.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"label": "Permit2",
"position": 4,
"collapsed": true
}
"label": "Permit2",
"position": 4,
"collapsed": true
}
9 changes: 4 additions & 5 deletions docs/contracts/permit2/reference/_category_.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"label": "Technical Reference",
"position": 2,
"collapsed": false
}

"label": "Technical Reference",
"position": 2,
"collapsed": false
}
8 changes: 4 additions & 4 deletions docs/contracts/uniswapx/_category_.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"label": "UniswapX",
"position": 3,
"collapsed": true
}
"label": "UniswapX",
"position": 3,
"collapsed": true
}
9 changes: 4 additions & 5 deletions docs/contracts/uniswapx/guides/_category_.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"label": "Guides",
"position": 3,
"collapsed": false
}

"label": "Guides",
"position": 3,
"collapsed": false
}
8 changes: 4 additions & 4 deletions docs/contracts/universal-router/_category_.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"label": "Universal Router",
"position": 3,
"collapsed": true
}
"label": "Universal Router",
"position": 3,
"collapsed": true
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"label": "Interfaces"
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"label": "Pool"
}
}
2 changes: 1 addition & 1 deletion docs/contracts/v3/reference/core/libraries/_category_.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"label": "Libraries"
}
}
7 changes: 3 additions & 4 deletions docs/contracts/v4/quickstart/04-hooks/_category_.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"label": "Hooks",
"collapsed": true
}

"label": "Hooks",
"collapsed": true
}
9 changes: 7 additions & 2 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const math = require('remark-math')
const katex = require('rehype-katex')
const tailwindPlugin = require('./plugins/tailwind-config.cjs')
require('dotenv').config()

module.exports = {
Expand Down Expand Up @@ -214,8 +215,11 @@ module.exports = {
blogSidebarCount: 0,
},
theme: {
customCss: require.resolve('./src/css/custom.css'),
customCss2: require.resolve('./src/css/colors.css'),
customCss: [
require.resolve('./src/css/custom.css'),
require.resolve('./src/css/font.css'),
require.resolve('./src/css/types.css'),
],
},
},
],
Expand All @@ -229,6 +233,7 @@ module.exports = {
},
],
plugins: [
tailwindPlugin,
['@saucelabs/theme-github-codeblock', {}],
[
'@docusaurus/plugin-client-redirects',
Expand Down
Loading
Loading