-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from DiamondLightSource/vbe/gh-actions
Add GH actions
- Loading branch information
Showing
38 changed files
with
3,241 additions
and
1,944 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Build and Publish storybook to GitHub Pages | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
jobs: | ||
deploy: | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.build-publish.outputs.page_url }} | ||
|
||
permissions: | ||
pages: write | ||
id-token: write | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: ["22.12.0"] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: pnpm/action-setup@v4 | ||
with: | ||
run_install: | | ||
args: [ --force ] | ||
- name: Set Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: pnpm | ||
|
||
- name: Build and publish | ||
id: build-publish | ||
uses: bitovi/[email protected] | ||
with: | ||
checkout: false | ||
path: storybook/storybook-static | ||
install_command: echo Already done | ||
build_command: pnpm build:storybook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created | ||
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages | ||
|
||
name: Node.js Package | ||
|
||
on: | ||
push: | ||
tags: | ||
- v* | ||
|
||
|
||
jobs: | ||
publish-npm: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup pnpm | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
run_install: | | ||
args: [ --force ] | ||
- name: Setup node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '22.12.0' | ||
registry-url: https://registry.npmjs.org/ | ||
scope: '@diamondlightsource' | ||
cache: pnpm | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Build | ||
run: pnpm build | ||
|
||
- name: Test | ||
run: pnpm jest | ||
|
||
- name: Publish | ||
run: pnpm publish -r --no-git-checks --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN_DLS}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# This workflow will install dependencies, run tests and lint | ||
|
||
name: Run CI | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
tags: ['v*'] | ||
pull_request: | ||
types: [ opened, synchronize ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node-version: ["22.12.0"] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install dependencies | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
run_install: | | ||
args: [ --force ] | ||
- name: Set Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: pnpm | ||
|
||
- name: Run Typescript tests and lint client code | ||
run: | | ||
pnpm lint | ||
pnpm jest | ||
pnpm build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,38 @@ | ||
import {useColorScheme} from "@mui/material"; | ||
import { useColorScheme } from "@mui/material"; | ||
import * as React from "react"; | ||
import {useEffect} from "react"; | ||
import { useEffect } from "react"; | ||
|
||
interface Globals { | ||
theme: string; | ||
themeMode: string; | ||
} | ||
|
||
interface Context { | ||
globals: Globals; | ||
} | ||
|
||
export interface ThemeSwapperProps { | ||
context: any, | ||
context: Context; | ||
children: React.ReactNode; | ||
} | ||
|
||
export const TextLight = 'Mode: Light' | ||
export const TextDark = 'Mode: Dark' | ||
export const TextLight = "Mode: Light"; | ||
export const TextDark = "Mode: Dark"; | ||
|
||
const ThemeSwapper = ( {context, children}: ThemeSwapperProps ) => { | ||
const ThemeSwapper = ({ context, children }: ThemeSwapperProps) => { | ||
const { mode, setMode } = useColorScheme(); | ||
//if( !mode ) return | ||
|
||
useEffect(() => { | ||
const selectedThemeMode = context.globals.themeMode || TextLight; | ||
setMode((selectedThemeMode == TextLight) ? "light" : "dark") | ||
},[context.globals.themeMode]); | ||
|
||
return <div style={{backgroundColor: mode === "light" ? "#fafafa" : "#050505"}}> | ||
{children} | ||
</div> | ||
setMode(selectedThemeMode == TextLight ? "light" : "dark"); | ||
}, [context.globals.themeMode]); | ||
|
||
return ( | ||
<div style={{ backgroundColor: mode === "light" ? "#fafafa" : "#050505" }}> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
export { ThemeSwapper }; | ||
export { ThemeSwapper, Context }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
module.exports = { | ||
presets: [ | ||
"@babel/preset-env", | ||
["@babel/preset-react",{runtime: 'automatic'}], | ||
"@babel/preset-typescript", | ||
], | ||
}; | ||
export const presets = [ | ||
"@babel/preset-env", | ||
["@babel/preset-react", { runtime: "automatic" }], | ||
"@babel/preset-typescript", | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { FlatCompat } from "@eslint/eslintrc"; | ||
import js from "@eslint/js"; | ||
import tsPlugin from "@typescript-eslint/eslint-plugin"; | ||
import tsParser from "@typescript-eslint/parser"; | ||
import reactPlugin from "eslint-plugin-react"; | ||
import prettierPlugin from "eslint-plugin-prettier"; | ||
|
||
const compat = new FlatCompat(); | ||
|
||
export default [ | ||
{ignores: [ | ||
"**/storybook-static/**", | ||
"**/*.css", | ||
"**/*.json", | ||
"**/*.d.ts", | ||
"**/dist/*", | ||
"**/*.html", | ||
"**/*.svg", | ||
"**/*.md", | ||
"babel.config.js", | ||
"eslint.config.js", | ||
"jest.config.js", | ||
"rollup.config.mjs", | ||
]}, | ||
js.configs.recommended, | ||
...compat.extends("plugin:@typescript-eslint/recommended"), | ||
...compat.extends("plugin:react/recommended"), | ||
...compat.extends("prettier"), | ||
{ | ||
languageOptions: { | ||
parser: tsParser, | ||
parserOptions: { | ||
project: "tsconfig.eslint.json" | ||
}, | ||
}, | ||
plugins: { | ||
"@typescript-eslint": tsPlugin, | ||
prettier: prettierPlugin, | ||
react: reactPlugin, | ||
}, | ||
rules: { | ||
"react/react-in-jsx-scope": "off", | ||
"no-console": "off", | ||
"prettier/prettier": "error", | ||
"@typescript-eslint/no-unused-vars": [ | ||
"error", | ||
{ argsIgnorePattern: "^_" }, | ||
], | ||
}, | ||
settings: { | ||
react: { | ||
version: "18", | ||
}, | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
module.exports = { | ||
testEnvironment: "jsdom", | ||
moduleNameMapper: { | ||
'^.+.(svg)$': 'jest-transform-stub', | ||
} | ||
}; | ||
export const testEnvironment = "jsdom"; | ||
export const moduleNameMapper = { | ||
"^.+.(svg)$": "jest-transform-stub", | ||
}; |
Oops, something went wrong.