Skip to content

Commit 97e0112

Browse files
committed
Add yml linting
1 parent 728436d commit 97e0112

File tree

7 files changed

+133
-64
lines changed

7 files changed

+133
-64
lines changed

.github/actions/in-progress.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ jobs:
129129
# strategy:
130130
# matrix:
131131
# package: ${{ fromJson(needs.find-packages.outputs.tabs) }}
132-
132+
133133
# steps:
134134
# - name: Check out source code
135135
# uses: actions/checkout@v4
@@ -161,7 +161,7 @@ jobs:
161161
test-tabs:
162162
name: Test and Typecheck tabs
163163
runs-on: ubuntu-latest
164-
needs:
164+
needs:
165165
- build-libs
166166
- find-packages
167167

@@ -215,7 +215,7 @@ jobs:
215215
directory: ${{ matrix.package.directory }}
216216
packageName: ${{ matrix.package.name }}
217217
testRequired: ${{ steps.filter.outputs.changed == 'true' }}
218-
218+
219219
- name: tsc and test
220220
if: steps.filter.outputs.changed == 'true'
221221
run: |

.github/workflows/pages-deploy.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,27 @@ jobs:
1616

1717
- name: Enable Corepack
1818
run: corepack enable
19-
19+
2020
- name: Use Node.js 💻
2121
uses: actions/setup-node@v4
2222
with:
2323
node-version: 22
2424
cache: yarn
25-
25+
2626
- name: Install Dependencies 📦
2727
run: yarn install --immutable
28-
28+
2929
- name: Build Modules 🔧
3030
run: yarn workspaces foreach -j 5 -ptW --from "./src/{bundles,tsc}/*" run build --tsc --lint
31-
31+
32+
- name: Build Docs
33+
run: yarn build:docs
34+
3235
- name: include java json
3336
run: cp -r src/java build
3437

3538
- name: Deploy 🚀
3639
uses: peaceiris/actions-gh-pages@v4
3740
with:
38-
github_token: ${{ secrets.GITHUB_TOKEN }}
41+
github_token: ${{ secrets.GITHUB_TOKEN }}
3942
publish_dir: ./build # The folder the action should deploy.

.github/workflows/pull-request.yml

Lines changed: 52 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -45,78 +45,77 @@ jobs:
4545
docs: ${{ steps.filter.outputs.docs || steps.filter.outputs.workflows }}
4646
playwright: ${{ steps.filter.outputs.devserver || steps.filter.outputs.libraries || steps.filter.outputs.tabs }}
4747

48-
4948
test:
5049
name: Verify that all tests, linting, type-checking and building succeeds.
5150
runs-on: ubuntu-latest
5251

5352
# execute after the paths-filter job is done
5453
needs: paths-filter
5554
steps:
56-
- name: Check out source code
57-
uses: actions/checkout@v4
58-
with:
59-
submodules: recursive
60-
61-
- name: Enable Corepack
62-
run: corepack enable
63-
64-
- name: Use Node.js 💻
65-
uses: actions/setup-node@v4
66-
with:
67-
node-version-file: .node-version
68-
cache: yarn
55+
- name: Check out source code
56+
uses: actions/checkout@v4
57+
with:
58+
submodules: recursive
59+
60+
- name: Enable Corepack
61+
run: corepack enable
62+
63+
- name: Use Node.js 💻
64+
uses: actions/setup-node@v4
65+
with:
66+
node-version-file: .node-version
67+
cache: yarn
6968

7069
# For whatever reason, repotools refuses to install correctly, so we have to install it separately and
7170
# build it in its entirety before proceeding with installing everything else
72-
- name: Setup Repotools
73-
run: yarn workspaces focus @sourceacademy/modules-repotools && yarn workspaces foreach -A --include "@sourceacademy/modules-repotools" run build
71+
- name: Setup Repotools
72+
run: yarn workspaces focus @sourceacademy/modules-repotools && yarn workspaces foreach -A --include "@sourceacademy/modules-repotools" run build
73+
74+
- name: Install dependencies
75+
run: yarn install --immutable
7476

75-
- name: Install dependencies
76-
run: yarn install --immutable
77+
- name: Install Playwright
78+
if: needs.paths-filter.outputs.playwright == 'true'
79+
run: yarn playwright install --with-deps
7780

78-
- name: Install Playwright
79-
if: needs.paths-filter.outputs.playwright == 'true'
80-
run: yarn playwright install --with-deps
81+
- name: Run tsc for libraries
82+
if: needs.paths-filter.outputs.libraries == 'true'
83+
run: yarn workspaces foreach -ptW --from "./lib/*" run tsc
8184

82-
- name: Run tsc for libraries
83-
if: needs.paths-filter.outputs.libraries == 'true'
84-
run: yarn workspaces foreach -ptW --from "./lib/*" run tsc
85+
- name: Run build for libraries
86+
run: yarn workspaces foreach -ptW --from "./lib/*" run build
8587

86-
- name: Run build for libraries
87-
run: yarn workspaces foreach -ptW --from "./lib/*" run build
88+
- name: Run test for libraries
89+
if: needs.paths-filter.outputs.libraries == 'true'
90+
run: yarn test:libs
8891

89-
- name: Run test for libraries
90-
if: needs.paths-filter.outputs.libraries == 'true'
91-
run: yarn test:libs
92+
- name: Build and run tsc for bundles and tabs
93+
if: needs.paths-filter.outputs.bundles == 'true' || needs.paths-filter.outputs.tabs == 'true'
94+
run: yarn workspaces foreach -j 5 -ptW --from "./src/{bundles,tabs}/*" run build --tsc
9295

93-
- name: Build and run tsc for bundles and tabs
94-
if: needs.paths-filter.outputs.bundles == 'true' || needs.paths-filter.outputs.tabs == 'true'
95-
run: yarn workspaces foreach -j 5 -ptW --from "./src/{bundles,tabs}/*" run build --tsc
96+
- name: Test bundles
97+
if: needs.paths-filter.outputs.bundles == 'true'
98+
run: yarn workspaces foreach -j 5 -ptW --from "./src/bundles/*" run test
9699

97-
- name: Test bundles
98-
if: needs.paths-filter.outputs.bundles == 'true'
99-
run: yarn workspaces foreach -j 5 -ptW --from "./src/bundles/*" run test
100+
- name: Test tabs
101+
if: needs.paths-filter.outputs.tabs == 'true'
102+
run: yarn workspaces foreach -j 5 -ptW --from "./src/tabs/*" run test
100103

101-
- name: Test tabs
102-
if: needs.paths-filter.outputs.tabs == 'true'
103-
run: yarn workspaces foreach -j 5 -ptW --from "./src/tabs/*" run test
104+
- name: Build manifest
105+
if: needs.paths-filter.outputs.devserver == 'true'
106+
run: yarn buildtools manifest
104107

105-
- name: Build manifest
106-
if: needs.paths-filter.outputs.devserver == 'true'
107-
run: yarn buildtools manifest
108+
- name: Build Docs Server
109+
if: needs.paths-filter.outputs.docs == 'true'
110+
run: yarn workspaces foreach -A --include "@sourceacademy/modules-docserver" run build
108111

109-
- name: Build Docs Server
110-
if: needs.paths-filter.outputs.docs == 'true'
111-
run: yarn workspaces foreach -A --include "@sourceacademy/modules-docserver" run build
112-
113-
- name: Run tsc for Dev Server
114-
if: needs.paths-filter.outputs.devserver == 'true'
115-
run: yarn tsc:devserver
112+
- name: Run tsc for Dev Server
113+
if: needs.paths-filter.outputs.devserver == 'true'
114+
run: yarn tsc:devserver
116115

117-
- name: Test Dev Server
118-
if: needs.paths-filter.outputs.devserver == 'true'
119-
run: yarn test:devserver
116+
- name: Test Dev Server
117+
if: needs.paths-filter.outputs.devserver == 'true'
118+
run: yarn test:devserver
120119

121-
- name: Lint Everything
122-
run: yarn buildtools lintglobal
120+
- name: Lint Everything
121+
run: yarn buildtools lintglobal

.vscode/settings.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,15 @@
1616
}
1717
}
1818
}
19+
],
20+
"eslint.validate": [
21+
"javascript",
22+
"javascriptreact",
23+
"json",
24+
"mdx",
25+
"typescript",
26+
"typescriptreact",
27+
"yml",
28+
"yaml"
1929
]
2030
}

eslint.config.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import * as importPlugin from 'eslint-plugin-import';
1010
import jsdocPlugin from 'eslint-plugin-jsdoc';
1111
import reactPlugin from 'eslint-plugin-react';
1212
import reactHooksPlugin from 'eslint-plugin-react-hooks';
13+
import ymlPlugin from 'eslint-plugin-yml';
1314
import globals from 'globals';
1415
import jsonParser from 'jsonc-eslint-parser';
1516
import tseslint from 'typescript-eslint';
@@ -30,6 +31,7 @@ export default tseslint.config(
3031
'build/**',
3132
'docs/.vitepress/cache',
3233
'devserver/vite.config.ts', // Don't lint this because there's no tsconfig properly configured for it
34+
'node_modules',
3335
'lib/buildtools/bin',
3436
'lib/buildtools/src/build/__test_mocks__',
3537
'src/**/samples/**',
@@ -60,6 +62,7 @@ export default tseslint.config(
6062
}
6163
},
6264
// #endregion markdown
65+
6366
{
6467
name: 'Global Configuration (Excluding Markdown)',
6568
// We exclude markdown because the markdown code processor doesn't support
@@ -82,6 +85,22 @@ export default tseslint.config(
8285
],
8386
}
8487
},
88+
{
89+
name: 'YML Files',
90+
extends: [ymlPlugin.configs['flat/recommended']],
91+
files: ['**/*.yml', '**/*.yaml'],
92+
plugins: {
93+
yml: ymlPlugin
94+
},
95+
rules: {
96+
'yml/indent': 'warn',
97+
'yml/no-tab-indent': 'error',
98+
99+
// based on https://ota-meshi.github.io/eslint-plugin-yml/rules/spaced-comment.html
100+
'@stylistic/spaced-comment': 'off',
101+
'yml/spaced-comment': 'warn'
102+
}
103+
},
85104
{
86105
name: 'JSON Files',
87106
files: ['**/*.json'],

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"eslint-plugin-jsdoc": "^51.3.1",
6969
"eslint-plugin-react": "^7.37.4",
7070
"eslint-plugin-react-hooks": "^5.1.0",
71+
"eslint-plugin-yml": "^1.18.0",
7172
"http-server": "^0.13.0",
7273
"husky": "^9.1.7",
7374
"jsdom": "^26.1.0",

yarn.lock

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3561,6 +3561,7 @@ __metadata:
35613561
eslint-plugin-jsdoc: "npm:^51.3.1"
35623562
eslint-plugin-react: "npm:^7.37.4"
35633563
eslint-plugin-react-hooks: "npm:^5.1.0"
3564+
eslint-plugin-yml: "npm:^1.18.0"
35643565
http-server: "npm:^0.13.0"
35653566
husky: "npm:^9.1.7"
35663567
js-slang: "npm:^1.0.81"
@@ -8020,7 +8021,7 @@ __metadata:
80208021
languageName: node
80218022
linkType: hard
80228023

8023-
"escape-string-regexp@npm:^4.0.0":
8024+
"escape-string-regexp@npm:4.0.0, escape-string-regexp@npm:^4.0.0":
80248025
version: 4.0.0
80258026
resolution: "escape-string-regexp@npm:4.0.0"
80268027
checksum: 10c0/9497d4dd307d845bd7f75180d8188bb17ea8c151c1edbf6b6717c100e104d629dc2dfb687686181b0f4b7d732c7dfdc4d5e7a8ff72de1b0ca283a75bbb3a9cd9
@@ -8034,6 +8035,17 @@ __metadata:
80348035
languageName: node
80358036
linkType: hard
80368037

8038+
"eslint-compat-utils@npm:^0.6.0":
8039+
version: 0.6.5
8040+
resolution: "eslint-compat-utils@npm:0.6.5"
8041+
dependencies:
8042+
semver: "npm:^7.5.4"
8043+
peerDependencies:
8044+
eslint: ">=6.0.0"
8045+
checksum: 10c0/f3519e1460ec82c6967c4b0132801924bf5c17328999014f444ec12f075b151e992d1ebf378cb8eb0b2e00b3d04e0eaac80897209121fd115f857598b4588393
8046+
languageName: node
8047+
linkType: hard
8048+
80378049
"eslint-import-resolver-node@npm:^0.3.9":
80388050
version: 0.3.9
80398051
resolution: "eslint-import-resolver-node@npm:0.3.9"
@@ -8143,6 +8155,21 @@ __metadata:
81438155
languageName: node
81448156
linkType: hard
81458157

8158+
"eslint-plugin-yml@npm:^1.18.0":
8159+
version: 1.18.0
8160+
resolution: "eslint-plugin-yml@npm:1.18.0"
8161+
dependencies:
8162+
debug: "npm:^4.3.2"
8163+
escape-string-regexp: "npm:4.0.0"
8164+
eslint-compat-utils: "npm:^0.6.0"
8165+
natural-compare: "npm:^1.4.0"
8166+
yaml-eslint-parser: "npm:^1.2.1"
8167+
peerDependencies:
8168+
eslint: ">=6.0.0"
8169+
checksum: 10c0/ff6619bb488c98f3b6639c58f135f375bba6a4e4763cfeded461c6bbe654164678055981d1a27949568efc5ca9f3904e3abdda593b837cabb96f58948cc2d6be
8170+
languageName: node
8171+
linkType: hard
8172+
81468173
"eslint-scope@npm:^8.4.0":
81478174
version: 8.4.0
81488175
resolution: "eslint-scope@npm:8.4.0"
@@ -13496,7 +13523,7 @@ __metadata:
1349613523
languageName: node
1349713524
linkType: hard
1349813525

13499-
"semver@npm:^7.3.5, semver@npm:^7.5.3, semver@npm:^7.6.0, semver@npm:^7.7.2":
13526+
"semver@npm:^7.3.5, semver@npm:^7.5.3, semver@npm:^7.5.4, semver@npm:^7.6.0, semver@npm:^7.7.2":
1350013527
version: 7.7.2
1350113528
resolution: "semver@npm:7.7.2"
1350213529
bin:
@@ -15816,7 +15843,17 @@ __metadata:
1581615843
languageName: node
1581715844
linkType: hard
1581815845

15819-
"yaml@npm:^2.7.0, yaml@npm:^2.8.0":
15846+
"yaml-eslint-parser@npm:^1.2.1":
15847+
version: 1.3.0
15848+
resolution: "yaml-eslint-parser@npm:1.3.0"
15849+
dependencies:
15850+
eslint-visitor-keys: "npm:^3.0.0"
15851+
yaml: "npm:^2.0.0"
15852+
checksum: 10c0/160a8dcb97e65e08de85069898379fbecad85838384797df9695f4cb51e48a195e57b3f3fc5abb35eec7c8d1329c3b7b92b12999f5f20c314d9a7d8d549de105
15853+
languageName: node
15854+
linkType: hard
15855+
15856+
"yaml@npm:^2.0.0, yaml@npm:^2.7.0, yaml@npm:^2.8.0":
1582015857
version: 2.8.0
1582115858
resolution: "yaml@npm:2.8.0"
1582215859
bin:

0 commit comments

Comments
 (0)