Skip to content

Commit

Permalink
Sonarqube Monorepo integration
Browse files Browse the repository at this point in the history
* Apply linting everywhere
* syncpack config
* Add sonar project files
* Add vitest
* Github action to test each project has changed.
If a project has not changed the sonarqube analysis
is skipped
  • Loading branch information
NigelBreslaw authored Dec 27, 2023
1 parent ba84d31 commit f19943d
Show file tree
Hide file tree
Showing 19 changed files with 985 additions and 139 deletions.
73 changes: 72 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: ishtar-ci

on:
push:
pull_request:
branches:
- main
Expand All @@ -22,4 +23,74 @@ jobs:
- name: format
run: pnpm format:check
- name: build
run: pnpm build
run: pnpm build

changes:
runs-on: ubuntu-latest
outputs:
dashboard: ${{ steps.changes.outputs.dashboard }}
react-frontend: ${{ steps.changes.outputs.react-frontend }}
docs: ${{ steps.changes.outputs.docs }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
dashboard:
- 'apps/dashboard/**'
react-frontend:
- 'apps/dashboard/**'
docs:
- 'docs/starlight/**'
dashboard:
name: Sonarqube Dashboard
needs: changes
if: ${{ needs.changes.outputs.dashboard == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
with:
projectBaseDir: apps/dashboard/
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_DASHBOARD }}

docs:
name: Sonarqube Docs
needs: changes
if: ${{ needs.changes.outputs.docs == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
with:
projectBaseDir: docs/starlight/
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_DOCS }}

react-frontend:
name: Sonarqube React Frontend
needs: changes
if: ${{ needs.changes.outputs.react-frontend == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
with:
projectBaseDir: apps/react-frontend/
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_REACT_FRONTEND }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dist
dist-ssr
.astro/
*.local
coverage

# Editor directories and files
.vscode/*
Expand Down
13 changes: 13 additions & 0 deletions .syncpackrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"semverGroups": [
{
"range": ""
}
],
"versionGroups": [
{
"dependencies": ["@gg-monorepo"],
"isIgnored": true
}
]
}
28 changes: 17 additions & 11 deletions apps/dashboard/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
{
"name": "dashboard",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"name": "@gg-monorepo/dashboard",
"version": "0.0.1",
"dependencies": {
"solid-js": "1.8.7"
},
"devDependencies": {
"typescript": "5.3.3",
"vite": "5.0.10",
"vite-plugin-solid": "2.8.0"
}
"vite-plugin-solid": "2.8.0",
"vitest": "^1.1.0"
},
"private": true,
"scripts": {
"build": "tsc && vite build",
"coverage": "vitest run --coverage",
"dev": "vite",
"format:check": "biome format ./src",
"format:write": "biome format --write ./src",
"lint": "biome lint ./src",
"lint:fix": "biome check --apply ./src",
"preview": "vite preview"
},
"type": "module"
}
14 changes: 14 additions & 0 deletions apps/dashboard/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
sonar.projectKey=nigelbreslaw_guardian-ghost_dashboard
sonar.organization=nigelbreslaw
sonar.javascript.lcov.reportPaths=coverage/lcov.info

# This is the name and version displayed in the SonarCloud UI.
#sonar.projectName=nigelbreslaw_guardian-ghost_dashboard
#sonar.projectVersion=1.0


# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
#sonar.sources=.

# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
53 changes: 25 additions & 28 deletions apps/dashboard/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
import { createSignal } from 'solid-js'
import solidLogo from './assets/solid.svg'
import viteLogo from '/vite.svg'
import './App.css'
import { createSignal } from "solid-js";
import viteLogo from "/vite.svg";
import "./App.css";
import solidLogo from "./assets/solid.svg";

function App() {
const [count, setCount] = createSignal(0)
const [count, setCount] = createSignal(0);

return (
<>
<div>
<a href="https://vitejs.dev" target="_blank">
<img src={viteLogo} class="logo" alt="Vite logo" />
</a>
<a href="https://solidjs.com" target="_blank">
<img src={solidLogo} class="logo solid" alt="Solid logo" />
</a>
</div>
<h1>Placeholder for dashboard!</h1>
<div class="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count()}
</button>
<p>
Developer stats coming soon.
</p>
</div>

</>
)
return (
<>
<div>
<a href="https://vitejs.dev" target="_blank" rel="noreferrer">
<img src={viteLogo} class="logo" alt="Vite logo" />
</a>
<a href="https://solidjs.com" target="_blank" rel="noreferrer">
<img src={solidLogo} class="logo solid" alt="Solid logo" />
</a>
</div>
<h1>Placeholder for dashboard!</h1>
<div class="card">
<button type="button" onClick={() => setCount((count) => count + 1)}>
count is {count()}
</button>
<p>Developer stats coming soon.</p>
</div>
</>
);
}

export default App
export default App;
10 changes: 5 additions & 5 deletions apps/dashboard/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* @refresh reload */
import { render } from 'solid-js/web'
import { render } from "solid-js/web";

import './index.css'
import App from './App'
import App from "./App";
import "./index.css";

const root = document.getElementById('root')
const root = document.getElementById("root");

render(() => <App />, root!)
render(() => <App />, root!);
9 changes: 9 additions & 0 deletions apps/dashboard/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from 'vitest/config'

export default defineConfig({
test: {
coverage: {
reporter: ['lcov'],
},
},
})
33 changes: 18 additions & 15 deletions apps/react-frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
{
"name": "@gg-monorepo/react-frontend",
"version": "0.0.1",
"dependencies": {
"react": "18.2.0",
"react-dom": "18.2.0",
"source-map-explorer": "2.5.3"
},
"devDependencies": {
"@types/react": "18.2.45",
"@types/react-dom": "18.2.18",
"@vitejs/plugin-react-swc": "3.5.0",
"typescript": "5.3.3",
"vite": "5.0.10",
"vite-plugin-mkcert": "1.17.1",
"vitest": "^1.1.0"
},
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"analyze": "source-map-explorer dist/**/*.js",
"build": "vite build",
"coverage": "vitest run --coverage",
"dev": "vite",
"dev:bun": "bunx --bun vite",
"format:check": "biome format ./src",
"format:write": "biome format --write ./src",
"lint": "biome lint ./src",
"lint:fix": "biome check --apply ./src",
"preview": "vite preview",
"typecheck": "tsc"
},
"dependencies": {
"react": "18.2.0",
"react-dom": "18.2.0",
"source-map-explorer": "2.5.3"
},
"devDependencies": {
"@types/react": "18.2.45",
"@types/react-dom": "18.2.18",
"@vitejs/plugin-react-swc": "3.5.0",
"typescript": "5.3.3",
"vite": "5.0.10",
"vite-plugin-mkcert": "1.17.1"
}
"type": "module"
}
14 changes: 14 additions & 0 deletions apps/react-frontend/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
sonar.projectKey=nigelbreslaw_guardian-ghost_react-frontend
sonar.organization=nigelbreslaw
sonar.javascript.lcov.reportPaths=coverage/lcov.info

# This is the name and version displayed in the SonarCloud UI.
#sonar.projectName=nigelbreslaw_guardian-ghost_react-frontend
#sonar.projectVersion=1.0


# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
#sonar.sources=.

# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
9 changes: 9 additions & 0 deletions apps/react-frontend/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from 'vitest/config'

export default defineConfig({
test: {
coverage: {
reporter: ['lcov'],
},
},
})
3 changes: 3 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"organizeImports": {
"enabled": true
},
"formatter": {
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
Expand Down
28 changes: 17 additions & 11 deletions docs/starlight/package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
{
"name": "@gg-monorepo/starlight",
"type": "module",
"version": "0.0.1",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro check && astro build",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"@astrojs/starlight": "0.15.1",
"astro": "4.0.7",
"sharp": "0.33.1"
},
"devDependencies": {
"@astrojs/check": "0.3.4",
"typescript": "5.3.3"
}
}
"typescript": "5.3.3",
"vitest": "^1.1.0"
},
"scripts": {
"astro": "astro",
"build": "astro check && astro build",
"coverage": "vitest run --coverage",
"dev": "astro dev",
"format:check": "biome format ./src",
"format:write": "biome format --write ./src",
"lint": "biome lint ./src",
"lint:fix": "biome check --apply ./src",
"preview": "astro preview",
"start": "astro dev"
},
"type": "module"
}
14 changes: 14 additions & 0 deletions docs/starlight/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
sonar.projectKey=nigelbreslaw_guardian-ghost_starlight
sonar.organization=nigelbreslaw
sonar.javascript.lcov.reportPaths=coverage/lcov.info

# This is the name and version displayed in the SonarCloud UI.
#sonar.projectName=nigelbreslaw_guardian-ghost_starlight
#sonar.projectVersion=1.0


# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
#sonar.sources=.

# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
6 changes: 3 additions & 3 deletions docs/starlight/src/content/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineCollection } from 'astro:content';
import { docsSchema, i18nSchema } from '@astrojs/starlight/schema';
import { docsSchema, i18nSchema } from "@astrojs/starlight/schema";
import { defineCollection } from "astro:content";

export const collections = {
docs: defineCollection({ schema: docsSchema() }),
i18n: defineCollection({ type: 'data', schema: i18nSchema() }),
i18n: defineCollection({ type: "data", schema: i18nSchema() }),
};
Loading

0 comments on commit f19943d

Please sign in to comment.