Skip to content

Commit 7299061

Browse files
authored
Merge pull request #78 from DiamondLightSource/21-Set-up-CI
Added simple linter and code formatter yaml
2 parents f85bc17 + 894d1f1 commit 7299061

22 files changed

+4981
-4253
lines changed

.github/workflows/_lint.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
on:
2+
workflow_call:
3+
4+
jobs:
5+
lint:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v4
9+
10+
- name: Set up Node.js
11+
uses: actions/setup-node@v4
12+
with:
13+
node-version: 20
14+
cache: "npm"
15+
16+
- name: Install dependencies
17+
run: npm ci
18+
19+
- name: Run audit
20+
run: npm audit --audit-level=high
21+
22+
- name: Run Prettier
23+
run: npm run prettier
24+
25+
- name: Run ESLint
26+
run: npm run lint
27+
28+
- name: Run TypeScript Compiler
29+
run: npm run tscheck

.github/workflows/testing-workflow.yaml renamed to .github/workflows/_tests.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: CI
22

3-
on: [push, pull_request]
3+
on:
4+
workflow_call:
45

56
jobs:
67
build:

.github/workflows/actions.yaml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
1-
# Simple workflow for deploying static content to GitHub Pages
21
name: Deploy static content to Pages
32

43
on:
5-
# Runs on pushes targeting the default branch
64
push:
75
branches: ["add-actions"]
8-
9-
# Allows you to run this workflow manually from the Actions tab
106
workflow_dispatch:
117

12-
# Sets the GITHUB_TOKEN permissions to allow deployment to GitHub Pages
138
permissions:
149
contents: read
1510
pages: write
1611
id-token: write
1712

18-
# Allow one concurrent deployment
1913
concurrency:
2014
group: "pages"
2115
cancel-in-progress: true
2216

2317
jobs:
24-
# Single deploy job since we're just deploying
2518
deploy:
2619
environment:
2720
name: github-pages
@@ -30,22 +23,27 @@ jobs:
3023
steps:
3124
- name: Checkout
3225
uses: actions/checkout@v4
26+
3327
- name: Set up Node
3428
uses: actions/setup-node@v4
3529
with:
3630
node-version: 20
3731
cache: "npm"
32+
3833
- name: Install dependencies
3934
run: npm ci
35+
4036
- name: Build
4137
run: npm run build
38+
4239
- name: Setup Pages
4340
uses: actions/configure-pages@v4
41+
4442
- name: Upload artifact
4543
uses: actions/upload-pages-artifact@v3
4644
with:
47-
# Upload dist folder
4845
path: "./dist"
46+
4947
- name: Deploy to GitHub Pages
5048
id: deployment
5149
uses: actions/deploy-pages@v4

.github/workflows/ci.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
lint:
9+
uses: ./.github/workflows/_lint.yaml
10+
11+
test:
12+
uses: ./.github/workflows/_tests.yaml
13+
14+
e2e:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Placeholder for end-to-end tests
18+
run: echo "End-to-end and browser tests would run here"
19+
20+
docs:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Placeholder for documentation generation
24+
run: echo "Documentation generation like storybook would run here"
25+
26+
performance:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Placeholder for performance tests
30+
run: echo "Performance like Lighthouse tests would run here"

.husky/pre-commit

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
npm run lint
2+
npm run prettier
3+
npm test

eslint.config.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,26 @@ import globals from "globals";
33
import reactHooks from "eslint-plugin-react-hooks";
44
import reactRefresh from "eslint-plugin-react-refresh";
55
import tseslint from "typescript-eslint";
6+
import jsxA11y from "eslint-plugin-jsx-a11y";
67

78
export default tseslint.config(
89
{ ignores: ["dist"] },
910
{
1011
extends: [js.configs.recommended, ...tseslint.configs.recommended],
1112
files: ["**/*.{ts,tsx}"],
12-
languageOptions: {
13-
ecmaVersion: 2020,
14-
globals: globals.browser,
15-
},
13+
languageOptions: { ecmaVersion: 2020, globals: globals.browser },
1614
plugins: {
1715
"react-hooks": reactHooks,
1816
"react-refresh": reactRefresh,
17+
"jsx-a11y": jsxA11y,
1918
},
2019
rules: {
2120
...reactHooks.configs.recommended.rules,
22-
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
21+
...jsxA11y.configs.recommended.rules,
22+
"react-refresh/only-export-components": [
23+
"warn",
24+
{ allowConstantExport: true },
25+
],
2326
"@typescript-eslint/no-unused-vars": [
2427
"error",
2528
{
@@ -33,5 +36,5 @@ export default tseslint.config(
3336
},
3437
],
3538
},
36-
}
39+
},
3740
);

0 commit comments

Comments
 (0)