Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/auto_assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Set to true to add reviewers to pull requests
addReviewers: true

# Set to true to add assignees to pull requests
addAssignees: false

# A list of reviewers to be added to pull requests (GitHub user name)
reviewers:
- mimshins

# A number of reviewers added to the pull request
# Set 0 to add all the reviewers (default: 0)
numberOfReviewers: 0
# A list of assignees, overrides reviewers if set
assignees:
- amir78729
- mimshins

# A number of assignees to add to the pull request
# Set to 0 to add all of the assignees.
# Uses numberOfReviewers if unset.
numberOfAssignees: 2

# A list of keywords to be skipped the process that add reviewers if pull requests include it
skipKeywords:
- wip
4 changes: 2 additions & 2 deletions .github/workflows/development.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 🧑‍💻 Development
name: "🧑‍💻 Development"

on:
pull_request:
Expand Down Expand Up @@ -37,7 +37,7 @@ jobs:
run: pnpm install

- name: 🔍 lint code
run: pnpm lint
run: pnpm check:lint

test:
needs: lint
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 🔍 Review

on:
workflow_run:
workflows: ["🧑‍💻 Development"]
types:
- completed

permissions:
contents: read
pull-requests: write
actions: read

jobs:
add-reviews:
name: 👥 Auto-assign Reviewer and Assignee
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: 👤 assigning reviewer and assignee
uses: kentaro-m/auto-assign-action@v2.0.0

danger:
name: ⚡ Danger Check
runs-on: ubuntu-latest
timeout-minutes: 10
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: ☁️ checkout repository associated with PR
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch }}

- name: 🔧 setup pnpm
uses: pnpm/action-setup@v3
with:
version: 9

- name: 🔧 setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"

- name: 📦 install dependencies
run: pnpm install

- name: ⚡ run danger file
run: pnpm check:danger
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 14 additions & 0 deletions dangerfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {
checkLockFile,
checkPlayground,
DangerClient,
} from "@internals/danger";
import { danger } from "danger";

void (async () => {
const dangerClient = new DangerClient(danger);

dangerClient.use(checkLockFile);
dangerClient.use(checkPlayground);
await dangerClient.analyze();
})();
28 changes: 20 additions & 8 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,26 @@ export default config(
},
},
{
files: ["*", "!**/scripts/**/*"],
rules: {
"no-alert": "error",
"no-console": "warn",
},
},
{
files: ["*", "!internals/danger/**/*"],
rules: {
"import/extensions": [
"error",
"always",
{
ignorePackages: true,
},
],
},
},
{
rules: {
"no-alert": "error",
"prefer-const": "error",
"default-case": "error",
"eol-last": "error",
Expand All @@ -71,13 +88,6 @@ export default config(
"no-unused-private-class-members": "warn",
"no-promise-executor-return": "error",
"no-unmodified-loop-condition": "warn",
"import/extensions": [
"error",
"always",
{
ignorePackages: true,
},
],
eqeqeq: ["error", "smart"],
"no-duplicate-imports": [
"error",
Expand Down Expand Up @@ -139,6 +149,8 @@ export default config(
},
],
},
},
{
settings: {
"import/resolver": {
typescript: {
Expand Down
109 changes: 109 additions & 0 deletions internals/danger/DangerClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import {
type DangerDSLType,
type DangerResults,
type GitDSL,
type GitHubDSL,
type GitLabDSL,
} from "danger";

declare let results: DangerResults;
declare const warn: (msg: string, file?: string, line?: number) => void;
declare const fail: (msg: string, file?: string, line?: number) => void;
declare const message: (msg: string, file?: string, line?: number) => void;
declare const markdown: (msg: string, file?: string, line?: number) => void;
export type PluginRuntime<Option extends Record<PropertyKey, any> = object> = (
client: DangerClient,
options?: Option,
) => void | Promise<void>;

class DangerClient {
public readonly gitlab: GitLabDSL;

public readonly github: GitHubDSL;

public readonly git: GitDSL;

public readonly results: DangerResults;

public readonly fail: typeof fail;

public readonly warn: typeof warn;

public readonly markdown: typeof markdown;

public readonly message: typeof message;

private footnoteString: number;

public readonly meta: Record<PropertyKey, unknown>;

private readonly plugins: Array<[PluginRuntime<any>, any]>;

constructor(danger: DangerDSLType) {
this.gitlab = danger.gitlab;
this.git = danger.git;
this.github = danger.github;
this.results = results;
this.fail = fail;
this.warn = warn;
this.markdown = markdown;
this.message = message;
this.meta = {};
this.plugins = [];
this.footnoteString = 0;
}

/** @see https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#footnotes */
private getFootnoteString(): string {
return `[^${++this.footnoteString}]`;
}

public failWithFootnote(content: string, footnote: string) {
const footnoteString = this.getFootnoteString();

this.fail(`${content} ${footnoteString}`);
this.markdown(`${footnoteString}: ${footnote}`);
}

public warnWithFootnote(content: string, footnote: string) {
const footnoteString = this.getFootnoteString();

this.warn(`${content} ${footnoteString}`);
this.markdown(`${footnoteString}: ${footnote}`);
}

public markdownWithFootnote(content: string, footnote: string) {
const footnoteString = this.getFootnoteString();

this.markdown(`${content} ${footnoteString}`);
this.markdown(`${footnoteString}: ${footnote}`);
}

public messageWithFootnote(content: string, footnote: string) {
const footnoteString = this.getFootnoteString();

this.message(`${content} ${footnoteString}`);
this.markdown(`${footnoteString}: ${footnote}`);
}

public use<Option extends Record<PropertyKey, any> = object>(
plugin: PluginRuntime<Option>,
options?: Option,
): this {
this.plugins.push([plugin, options]);

return this;
}

public async analyze(): Promise<DangerResults> {
for (const [method, pluginOption] of this.plugins) {
await method(this, pluginOption);
}

return this.results;
}
}

export default DangerClient;
/* eslint-enable @typescript-eslint/no-explicit-any */
2 changes: 2 additions & 0 deletions internals/danger/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as DangerClient } from "./DangerClient";
export * from "./plugins/index";
7 changes: 7 additions & 0 deletions internals/danger/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "@internals/danger",
"main": "index.ts",
"version": "0.0.0",
"private": true,
"type": "module"
}
25 changes: 25 additions & 0 deletions internals/danger/plugins/checkLockFile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { type PluginRuntime } from "../DangerClient";

export const checkLockFile: PluginRuntime = async client => {
const packageJsonDiff = await client.git.JSONDiffForFile("package.json");
const dependenciesChanged = !!(
packageJsonDiff?.devDependencies || packageJsonDiff?.dependencies
);

const modifiedFiles = [
...client.git.created_files,
...client.git.modified_files,
];

const lockfileChanged = modifiedFiles.includes("pnpm-lock.yaml");

if (dependenciesChanged !== lockfileChanged) {
client.failWithFootnote(
"🔒 The lock file looks outdated!",
[
"The dependencies in package.json have been modified, but the lock file (pnpm-lock.yaml) is not updated.",
"Ensure both files are synchronized to prevent potential dependency mismatches using `pnpm install` command",
].join("\n"),
);
}
};
16 changes: 16 additions & 0 deletions internals/danger/plugins/checkPlayground.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { type PluginRuntime } from "../DangerClient";

export const checkPlayground: PluginRuntime = client => {
const playgroundEditedFiles = [
...client.git.modified_files,
...client.git.created_files,
...client.git.deleted_files,
].filter(file => file.startsWith("playground"));

if (playgroundEditedFiles.length > 0) {
client.warnWithFootnote(
"🛝 Changes in `playground` was detected!",
"Some of the changes in this PR are related to project's playground. Check them before merging the PR.",
);
}
};
2 changes: 2 additions & 0 deletions internals/danger/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./checkLockFile";
export * from "./checkPlayground";
2 changes: 1 addition & 1 deletion internals/test-helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import AxeBuilder from "@axe-core/playwright";
import { AxeBuilder } from "@axe-core/playwright";
import { type Page, test as base } from "@playwright/test";

const test = base.extend({
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"build:docs": "wireit",
"test": "wireit",
"test:update-snapshots": "pnpm --filter @tapsioss/web-components run test:update-snapshots",
"lint": "wireit",
"check:danger": "danger ci --verbose --failOnErrors",
"check:lint": "wireit",
"fmt": "wireit",
"dev:packages": "pnpm run -r --parallel --filter=!@tapsioss/docs dev",
"dev:playground": "pnpm --filter @tapsioss/playground run start:dev",
Expand All @@ -45,7 +46,7 @@
],
"output": []
},
"lint": {
"check:lint": {
"dependencies": [
"lint:ts",
"lint:ecma"
Expand Down Expand Up @@ -225,6 +226,7 @@
}
},
"devDependencies": {
"@internals/danger": "workspace:*",
"@axe-core/playwright": "^4.10.1",
"@custom-elements-manifest/analyzer": "^0.10.4",
"@eslint/js": "^9.22.0",
Expand All @@ -240,6 +242,7 @@
"@types/stream-json": "^1.7.8",
"@vitejs/plugin-react": "^4.3.4",
"custom-elements-manifest": "^2.1.0",
"danger": "^12.3.4",
"eslint": "^9.22.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.9.1",
Expand Down
2 changes: 0 additions & 2 deletions packages/icons/scripts/build.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import globAsync from "fast-glob";
import Mustache from "mustache";
import { exec } from "node:child_process";
Expand Down Expand Up @@ -140,4 +139,3 @@ void (async () => {
await generatePaths();
console.timeEnd("build");
})();
/* eslint-enable no-console */
2 changes: 0 additions & 2 deletions packages/react-components/scripts/generate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import Mustache from "mustache";
import { exec } from "node:child_process";
import * as fs from "node:fs";
Expand Down Expand Up @@ -364,4 +363,3 @@ void (async () => {
console.timeEnd("generate");
});
})();
/* eslint-enable no-console */
2 changes: 0 additions & 2 deletions packages/react-icons/scripts/build.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import icons from "@tapsioss/icons";
import Mustache from "mustache";
import { exec } from "node:child_process";
Expand Down Expand Up @@ -89,4 +88,3 @@ void (async () => {
await generateComponents();
console.timeEnd("build");
})();
/* eslint-enable no-console */
Loading