|
| 1 | +# Copilot Instructions |
| 2 | + |
| 3 | +This GitHub Action is written in TypeScript and transpiled to JavaScript. Both |
| 4 | +the TypeScript sources and the **generated** JavaScript code are contained in |
| 5 | +this repository. The TypeScript sources are contained in the `src` directory and |
| 6 | +the JavaScript code is contained in the `dist` directory. A GitHub Actions |
| 7 | +workflow checks that the JavaScript code in `dist` is up-to-date. Therefore, you |
| 8 | +should not review any changes to the contents of the `dist` folder and it is |
| 9 | +expected that the JavaScript code in `dist` closely mirrors the TypeScript code |
| 10 | +it is generated from. |
| 11 | + |
| 12 | +## Repository Structure |
| 13 | + |
| 14 | +| Path | Description | |
| 15 | +| ---------------------- | -------------------------------------------------------- | |
| 16 | +| `__fixtures__/` | Unit Test Fixtures | |
| 17 | +| `__tests__/` | Unit Tests | |
| 18 | +| `.devcontainer/` | Development Container Configuration | |
| 19 | +| `.github/` | GitHub Configuration | |
| 20 | +| `.licenses/` | License Information | |
| 21 | +| `.vscode/` | Visual Studio Code Configuration | |
| 22 | +| `badges/` | Badges for readme | |
| 23 | +| `dist/` | Generated JavaScript Code | |
| 24 | +| `src/` | TypeScript Source Code | |
| 25 | +| `.env.example` | Environment Variables Example for `@github/local-action` | |
| 26 | +| `.licensed.yml` | Licensed Configuration | |
| 27 | +| `.markdown-lint.yml` | Markdown Linter Configuration | |
| 28 | +| `.node-version` | Node.js Version Configuration | |
| 29 | +| `.prettierrc.yml` | Prettier Formatter Configuration | |
| 30 | +| `.yaml-lint.yml` | YAML Linter Configuration | |
| 31 | +| `action.yml` | GitHub Action Metadata | |
| 32 | +| `CODEOWNERS` | Code Owners File | |
| 33 | +| `eslint.config.mjs` | ESLint Configuration | |
| 34 | +| `jest.config.js` | Jest Configuration | |
| 35 | +| `LICENSE` | License File | |
| 36 | +| `package.json` | NPM Package Configuration | |
| 37 | +| `README.md` | Project Documentation | |
| 38 | +| `rollup.config.ts` | Rollup Bundler Configuration | |
| 39 | +| `tsconfig.base.json` | Base TypeScript Configuration | |
| 40 | +| `tsconfig.eslint.json` | TypeScript Configuration for ESLint | |
| 41 | +| `tsconfig.json` | TypeScript Configuration | |
| 42 | + |
| 43 | +## Environment Setup |
| 44 | + |
| 45 | +Install dependencies by running: |
| 46 | + |
| 47 | +```bash |
| 48 | +npm install |
| 49 | +``` |
| 50 | + |
| 51 | +## Testing |
| 52 | + |
| 53 | +Ensure all unit tests pass by running: |
| 54 | + |
| 55 | +```bash |
| 56 | +npm run test |
| 57 | +``` |
| 58 | + |
| 59 | +Unit tests should exist in the `__tests__` directory. They are powered by |
| 60 | +`jest`. Fixtures should be placed in the `__fixtures__` directory. |
| 61 | + |
| 62 | +## Bundling |
| 63 | + |
| 64 | +Any time files in the `src` directory are changed, you should run the following |
| 65 | +command to bundle the TypeScript code into JavaScript: |
| 66 | + |
| 67 | +```bash |
| 68 | +npm run bundle |
| 69 | +``` |
| 70 | + |
| 71 | +## General Coding Guidelines |
| 72 | + |
| 73 | +- Follow standard TypeScript and JavaScript coding conventions and best |
| 74 | + practices |
| 75 | +- Changes should maintain consistency with existing patterns and style |
| 76 | +- Document changes clearly and thoroughly, including updates to existing |
| 77 | + comments when appropriate |
| 78 | +- Do not include basic, unnecessary comments that simply restate what the code |
| 79 | + is doing (focus on explaining _why_, not _what_) |
| 80 | +- Use consistent error handling patterns throughout the codebase |
| 81 | +- Use TypeScript's type system to ensure type safety and clarity |
| 82 | +- Keep functions focused and manageable |
| 83 | +- Use descriptive variable and function names that clearly convey their purpose |
| 84 | +- Use JSDoc comments to document functions, classes, and complex logic |
| 85 | +- After doing any refactoring, ensure to run `npm run test` to ensure that all |
| 86 | + tests still pass and coverage requirements are met |
| 87 | +- When suggesting code changes, always opt for the most maintainable approach. |
| 88 | + Try your best to keep the code clean and follow "Don't Repeat Yourself" (DRY) |
| 89 | + principles |
| 90 | +- Avoid unnecessary complexity and always consider the long-term maintainability |
| 91 | + of the code |
| 92 | +- When writing unit tests, try to consider edge cases as well as the main path |
| 93 | + of success. This will help ensure that the code is robust and can handle |
| 94 | + unexpected inputs or situations |
| 95 | +- Use the `@actions/core` package for logging over `console` to ensure |
| 96 | + compatibility with GitHub Actions logging features |
| 97 | + |
| 98 | +### Versioning |
| 99 | + |
| 100 | +GitHub Actions are versioned using branch and tag names. Please ensure the |
| 101 | +version in the project's `package.json` is updated to reflect the changes made |
| 102 | +in the codebase. The version should follow |
| 103 | +[Semantic Versioning](https://semver.org/) principles. |
| 104 | + |
| 105 | +## Pull Request Guidelines |
| 106 | + |
| 107 | +When creating a pull request (PR), please ensure that: |
| 108 | + |
| 109 | +- Keep changes focused and minimal (avoid large changes, or consider breaking |
| 110 | + them into separate, smaller PRs) |
| 111 | +- Formatting checks pass |
| 112 | +- Linting checks pass |
| 113 | +- Unit tests pass and coverage requirements are met |
| 114 | +- The action has been transpiled to JavaScript and the `dist` directory is |
| 115 | + up-to-date with the latest changes in the `src` directory |
| 116 | +- If necessary, the `README.md` file is updated to reflect any changes in |
| 117 | + functionality or usage |
| 118 | + |
| 119 | +The body of the PR should include: |
| 120 | + |
| 121 | +- A summary of the changes |
| 122 | +- A special note of any changes to dependencies |
| 123 | +- A link to any relevant issues or discussions |
| 124 | +- Any additional context that may be helpful for reviewers |
| 125 | + |
| 126 | +## Code Review Guidelines |
| 127 | + |
| 128 | +When performing a code review, please follow these guidelines: |
| 129 | + |
| 130 | +- If there are changes that modify the functionality/usage of the action, |
| 131 | + validate that there are changes in the `README.md` file that document the new |
| 132 | + or modified functionality |
0 commit comments