-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(check-for-non-releasable-actions): find reusable workflows too
We need to release reusable workflows just like we do for Actions. The current linter didn't check for that, so it's added here. This required an extra library to parse the YAML, and GitHub scripts can't install new dependencies, so it's broken out to a small `internal/` composite action which can. Now we have two Typescript actions, it made sense to centralise some of the setup. We have a shared `eslint` config now, and `bun` workspaces for each of the modules so they can cross-reference.
- Loading branch information
Showing
20 changed files
with
599 additions
and
89 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
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 +1,14 @@ | ||
.idea/ | ||
|
||
# JS / Bun bits | ||
**/node_modules/ | ||
**/.*.bun-build | ||
|
||
# Test files | ||
**/coverage/ | ||
|
||
# Generated build output | ||
**/dist/ | ||
|
||
# Don't commit any log files | ||
**/*.log |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
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,40 +1,3 @@ | ||
import eslint from "@eslint/js"; | ||
import eslintPluginJest from "eslint-plugin-jest"; | ||
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended"; | ||
import js from "@eslint/js"; | ||
import tseslint from "typescript-eslint"; | ||
import config from "@grafana/eslint-config-shared-workflows"; | ||
|
||
export default tseslint.config( | ||
js.configs.recommended, | ||
eslint.configs.recommended, | ||
...tseslint.configs.strictTypeChecked, | ||
eslintPluginPrettierRecommended, | ||
{ | ||
// Allow unused vars if they start with an underscore | ||
rules: { | ||
"@typescript-eslint/no-unused-vars": [ | ||
"error", | ||
{ | ||
varsIgnorePattern: "^_", | ||
argsIgnorePattern: "^_", | ||
}, | ||
], | ||
}, | ||
languageOptions: { | ||
parserOptions: { | ||
projectService: true, | ||
}, | ||
}, | ||
}, | ||
{ | ||
files: ["**/*.js", "**/*.mjs"], | ||
...tseslint.configs.disableTypeChecked, | ||
}, | ||
{ | ||
files: ["test/**/*.ts"], | ||
...eslintPluginJest.configs["flat/recommended"], | ||
}, | ||
{ | ||
ignores: ["coverage/", "dist/", "node_modules/"], | ||
}, | ||
); | ||
export default config; |
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 |
---|---|---|
|
@@ -44,7 +44,8 @@ | |
"eslint-plugin-prettier": "5.2.1", | ||
"prettier": "3.4.1", | ||
"typescript": "5.7.2", | ||
"typescript-eslint": "8.16.0" | ||
"typescript-eslint": "8.16.0", | ||
"@grafana/eslint-config-shared-workflows": "workspace:*" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
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,15 @@ | ||
# check-for-non-releasable-actions | ||
|
||
To install dependencies: | ||
|
||
```bash | ||
bun install | ||
``` | ||
|
||
To run: | ||
|
||
```bash | ||
bun run main.ts | ||
``` | ||
|
||
This project was created using `bun init` in bun v1.1.36. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. |
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,24 @@ | ||
name: Check for actions and reusable workflows without a release | ||
description: Check for actions and reusable workflows that don't have a release-please configuration. | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Install bun package manager | ||
uses: oven-sh/setup-bun@4bc047ad259df6fc24a6c9b0f9a0cb08cf17fbe5 # v2.0.1 | ||
with: | ||
bun-version-file: actions/lint-pr-title/package.json | ||
|
||
- name: Install dependencies | ||
shell: sh | ||
working-directory: ${{ github.action_path }} | ||
run: | | ||
bun install --frozen-lockfile --production | ||
- name: Lint PR title | ||
shell: sh | ||
working-directory: ${{ github.action_path }} | ||
env: | ||
NODE_ENV: "production" | ||
run: | | ||
bun run --cwd ../.. internal/check-for-non-releasable-actions/index.ts |
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,3 @@ | ||
import config from "@grafana/eslint-config-shared-workflows"; | ||
|
||
export default config; |
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,35 @@ | ||
import { readFile, readdir } from "fs/promises"; | ||
|
||
/** | ||
* A representation of a directory entry, which can be either a file or a | ||
* directory. This is a subset of the `fs.Dirent` interface containing just the | ||
* parts we need. | ||
*/ | ||
export interface DirectoryEntry { | ||
name: string; | ||
isDirectory: () => boolean; | ||
isFile: () => boolean; | ||
} | ||
|
||
/** | ||
* Abstraction of the filesystem for reading directories and files. This is to | ||
* allow for easier testing by providing an in-memory filesystem implementation. | ||
*/ | ||
export interface FileSystem { | ||
readDirectory: (path: string) => Promise<DirectoryEntry[]>; | ||
readFile: (path: string) => Promise<string>; | ||
} | ||
|
||
/** | ||
* Implementation of the filesystem using Node.js's built-in `fs` module, used | ||
* in production. | ||
*/ | ||
export class NodeFileSystem implements FileSystem { | ||
async readDirectory(path: string): Promise<DirectoryEntry[]> { | ||
return readdir(path, { withFileTypes: true }); | ||
} | ||
|
||
async readFile(path: string): Promise<string> { | ||
return readFile(path, "utf-8"); | ||
} | ||
} |
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,6 @@ | ||
import { NodeFileSystem } from "./filesystem"; | ||
import { main } from "./main"; | ||
import config from "../../release-please-config.json" assert { type: "json" }; | ||
|
||
const fs = new NodeFileSystem(); | ||
process.exit(await main(fs, config)); |
Oops, something went wrong.