From e8668614a7917c88ddbd38973952ad2fe676f381 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Tue, 21 Nov 2023 19:45:44 +0100 Subject: [PATCH] Setup CI to lint workflows with action-validator --- .github/workflows/static_analysis.yaml | 17 +++++++++++++++++ package.json | 5 ++++- yarn.lock | 17 +++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/.github/workflows/static_analysis.yaml b/.github/workflows/static_analysis.yaml index f63fb7c40e..e9ea52dc91 100644 --- a/.github/workflows/static_analysis.yaml +++ b/.github/workflows/static_analysis.yaml @@ -64,6 +64,23 @@ jobs: - name: Run Linter run: "yarn run lint:style" + workflow_lint: + name: "Workflow Lint" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + cache: "yarn" + + # Does not need branch matching as only analyses this layer + - name: Install Deps + run: "yarn install --frozen-lockfile" + + - name: Run Linter + run: "yarn lint:workflows" + analyse_dead_code: name: "Analyse Dead Code" runs-on: ubuntu-latest diff --git a/package.json b/package.json index b0bbd3e184..f43718b061 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "start:https": "concurrently --kill-others-on-fail --prefix \"{time} [{name}]\" -n res,element-js \"yarn start:res\" \"yarn start:js --https\"", "start:res": "ts-node scripts/copy-res.ts -w", "start:js": "webpack serve --output-path webapp --output-filename=bundles/_dev_/[name].js --output-chunk-filename=bundles/_dev_/[name].js --mode development", - "lint": "yarn lint:types && yarn lint:js && yarn lint:style", + "lint": "yarn lint:types && yarn lint:js && yarn lint:style && yarn lint:workflows", "lint:js": "yarn lint:js:src && yarn lint:js:module_system", "lint:js:src": "eslint --max-warnings 0 src test && prettier --check .", "lint:js:module_system": "eslint --max-warnings 0 --config .eslintrc-module_system.js module_system", @@ -60,6 +60,7 @@ "lint:types:src": "tsc --noEmit --jsx react", "lint:types:module_system": "tsc --noEmit --project ./tsconfig.module_system.json", "lint:style": "stylelint \"res/css/**/*.pcss\"", + "lint:workflows": "find .github/workflows -type f \\( -iname '*.yaml' -o -iname '*.yml' \\) | xargs -I {} sh -c 'echo \"Linting {}\"; action-validator \"{}\"'", "test": "jest", "coverage": "yarn test --coverage", "analyse:unused-exports": "ts-node ./scripts/analyse_unused_exports.ts", @@ -84,6 +85,8 @@ "ua-parser-js": "^1.0.0" }, "devDependencies": { + "@action-validator/cli": "^0.5.3", + "@action-validator/core": "^0.5.3", "@babel/core": "^7.12.10", "@babel/eslint-parser": "^7.12.10", "@babel/eslint-plugin": "^7.12.10", diff --git a/yarn.lock b/yarn.lock index c883c572b2..a32d90615e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7,6 +7,18 @@ resolved "https://registry.yarnpkg.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf" integrity sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA== +"@action-validator/cli@^0.5.3": + version "0.5.3" + resolved "https://registry.yarnpkg.com/@action-validator/cli/-/cli-0.5.3.tgz#2d4fe473058f6ef17530b9bb5929f0eade4e8672" + integrity sha512-u/kv77ZC55PfAc9RQeP76xV1GysTisEJjO+b5TgCrBBcaKtGLt5Y7ki2GSdc7CDzncNc1oeoGcwaLMW6JSdQAw== + dependencies: + chalk "5.2.0" + +"@action-validator/core@^0.5.3": + version "0.5.3" + resolved "https://registry.yarnpkg.com/@action-validator/core/-/core-0.5.3.tgz#493b850ef7a2801830069d78f60cbefe0697423f" + integrity sha512-0ABelaY7nmpvV5q0z8Vl1cDeq2OZ1HyNXjXS54fBadLaCssZLbDvTa7M2uUaNMcEWV+Xl48WWbnqJWKePt9qHQ== + "@actions/core@^1.4.0": version "1.10.1" resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.10.1.tgz#61108e7ac40acae95ee36da074fa5850ca4ced8a" @@ -3927,6 +3939,11 @@ caniuse-lite@^1.0.30001541: resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001562.tgz#9d16c5fd7e9c592c4cd5e304bc0f75b0008b2759" integrity sha512-kfte3Hym//51EdX4239i+Rmp20EsLIYGdPkERegTgU19hQWCRhsRFGKHTliUlsry53tv17K7n077Kqa0WJU4ng== +chalk@5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.2.0.tgz#249623b7d66869c673699fb66d65723e54dfcfb3" + integrity sha512-ree3Gqw/nazQAPuJJEy+avdl7QfZMcUvmHIKgEZkGL+xOBzRvup5Hxo6LHuMceSxOabuJLJm5Yp/92R9eMmMvA== + chalk@^2.4.1, chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"