website: add sidebar item tests, bump node version to latest LTS

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer 2023-02-09 22:06:03 +01:00
parent ecd5fab082
commit b225f6f3ff
No known key found for this signature in database
8 changed files with 82 additions and 11 deletions

View File

@ -18,7 +18,7 @@ runs:
- name: Setup node - name: Setup node
uses: actions/setup-node@v3.1.0 uses: actions/setup-node@v3.1.0
with: with:
node-version: '16' node-version: '18'
cache: 'npm' cache: 'npm'
cache-dependency-path: web/package-lock.json cache-dependency-path: web/package-lock.json
- name: Setup dependencies - name: Setup dependencies

View File

@ -115,7 +115,7 @@ jobs:
go-version: "^1.17" go-version: "^1.17"
- uses: actions/setup-node@v3.6.0 - uses: actions/setup-node@v3.6.0
with: with:
node-version: '16' node-version: '18'
cache: 'npm' cache: 'npm'
cache-dependency-path: web/package-lock.json cache-dependency-path: web/package-lock.json
- name: Generate API - name: Generate API

View File

@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-node@v3.6.0 - uses: actions/setup-node@v3.6.0
with: with:
node-version: '16' node-version: '18'
cache: 'npm' cache: 'npm'
cache-dependency-path: web/package-lock.json cache-dependency-path: web/package-lock.json
- working-directory: web/ - working-directory: web/
@ -33,7 +33,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-node@v3.6.0 - uses: actions/setup-node@v3.6.0
with: with:
node-version: '16' node-version: '18'
cache: 'npm' cache: 'npm'
cache-dependency-path: web/package-lock.json cache-dependency-path: web/package-lock.json
- working-directory: web/ - working-directory: web/
@ -49,7 +49,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-node@v3.6.0 - uses: actions/setup-node@v3.6.0
with: with:
node-version: '16' node-version: '18'
cache: 'npm' cache: 'npm'
cache-dependency-path: web/package-lock.json cache-dependency-path: web/package-lock.json
- working-directory: web/ - working-directory: web/
@ -65,7 +65,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-node@v3.6.0 - uses: actions/setup-node@v3.6.0
with: with:
node-version: '16' node-version: '18'
cache: 'npm' cache: 'npm'
cache-dependency-path: web/package-lock.json cache-dependency-path: web/package-lock.json
- working-directory: web/ - working-directory: web/
@ -97,7 +97,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-node@v3.6.0 - uses: actions/setup-node@v3.6.0
with: with:
node-version: '16' node-version: '18'
cache: 'npm' cache: 'npm'
cache-dependency-path: web/package-lock.json cache-dependency-path: web/package-lock.json
- working-directory: web/ - working-directory: web/

View File

@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-node@v3.6.0 - uses: actions/setup-node@v3.6.0
with: with:
node-version: '16' node-version: '18'
cache: 'npm' cache: 'npm'
cache-dependency-path: website/package-lock.json cache-dependency-path: website/package-lock.json
- working-directory: website/ - working-directory: website/
@ -25,9 +25,24 @@ jobs:
- name: prettier - name: prettier
working-directory: website/ working-directory: website/
run: npm run prettier-check run: npm run prettier-check
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3.6.0
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: website/package-lock.json
- working-directory: website/
run: npm ci
- name: test
working-directory: website/
run: npm test
ci-website-mark: ci-website-mark:
needs: needs:
- lint-prettier - lint-prettier
- test
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- run: echo mark - run: echo mark

View File

@ -108,7 +108,7 @@ jobs:
go-version: "^1.17" go-version: "^1.17"
- uses: actions/setup-node@v3.6.0 - uses: actions/setup-node@v3.6.0
with: with:
node-version: '16' node-version: '18'
cache: 'npm' cache: 'npm'
cache-dependency-path: web/package-lock.json cache-dependency-path: web/package-lock.json
- name: Build web - name: Build web

View File

@ -14,7 +14,7 @@ jobs:
token: ${{ secrets.BOT_GITHUB_TOKEN }} token: ${{ secrets.BOT_GITHUB_TOKEN }}
- uses: actions/setup-node@v3.6.0 - uses: actions/setup-node@v3.6.0
with: with:
node-version: '16' node-version: '18'
registry-url: 'https://registry.npmjs.org' registry-url: 'https://registry.npmjs.org'
- name: Generate API Client - name: Generate API Client
run: make gen-client-ts run: make gen-client-ts

View File

@ -12,7 +12,8 @@
"deploy": "docusaurus deploy", "deploy": "docusaurus deploy",
"serve": "docusaurus serve", "serve": "docusaurus serve",
"prettier-check": "prettier --check .", "prettier-check": "prettier --check .",
"prettier": "prettier --write ." "prettier": "prettier --write .",
"test": "node --test"
}, },
"dependencies": { "dependencies": {
"@docusaurus/plugin-client-redirects": "2.3.1", "@docusaurus/plugin-client-redirects": "2.3.1",

View File

@ -0,0 +1,55 @@
import test from "node:test";
import assert from "node:assert";
import sidebar from "../sidebarsIntegrations.js";
import glob from "glob";
const getSidebarItems = () => {
const allItems = [];
const mapper = (category) => {
category.items.forEach((item) => {
if (item.constructor === String) {
allItems.push(item);
} else {
mapper(item);
}
});
};
sidebar.integrations.forEach(mapper);
return allItems.sort();
};
test("ensure all services have a sidebar entry", (t) => {
// All services in the sidebar
const services = getSidebarItems()
.filter((entry) => entry.startsWith("services/"))
.map((entry) => entry.replace("/index", ""))
.map((entry) => entry.replace("services/", ""));
const servicesFiles = glob
.sync("integrations/**/*.+(md|mdx)")
.filter((entry) => entry.startsWith("integrations/services/"))
.map((entry) => entry.replace("integrations/services/", ""))
.map((entry) => entry.replace(/\/index\.mdx?/, ""))
.filter((entry) => entry !== "index.mdx")
.sort();
servicesFiles.forEach((file, idx) => {
assert.strictEqual(file, services[idx]);
});
});
test("ensure all sources have a sidebar entry", (t) => {
// All sources in the sidebar
const sources = getSidebarItems()
.filter((entry) => entry.startsWith("sources/"))
.map((entry) => entry.replace("/index", ""))
.map((entry) => entry.replace("sources/", ""));
const sourceFiles = glob
.sync("integrations/**/*.+(md|mdx)")
.filter((entry) => entry.startsWith("integrations/sources/"))
.map((entry) => entry.replace("integrations/sources/", ""))
.map((entry) => entry.replace(/\/index\.mdx?/, ""))
.map((entry) => entry.replace(".md", ""))
.sort();
sourceFiles.forEach((file, idx) => {
assert.strictEqual(file, sources[idx]);
});
});