-
Notifications
You must be signed in to change notification settings - Fork 0
feat(actions): export reusable github actions checker #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
f5daefc
feat: create individual actions
teodorus-nathaniel 388958f
feat: create single action aggregator
teodorus-nathaniel 9e1be5e
fix: use hardcoded repo name
teodorus-nathaniel 6b47acd
feat: call pr checks on push
teodorus-nathaniel 497409b
refactor: use relative path
teodorus-nathaniel e634075
chore: remove version pinning on local workflow
teodorus-nathaniel 00c58a4
fix: install config conventional locally
teodorus-nathaniel 64c0c30
chore: not run prettier check on this repo
teodorus-nathaniel 96b6850
feat: add checksum check
teodorus-nathaniel 0f97192
docs: add readme
teodorus-nathaniel 1ff46b8
chore: run prettier check here
teodorus-nathaniel be8820a
feat: add prettier in this repo for development
teodorus-nathaniel bbc4c39
chore: use pnpm 10
teodorus-nathaniel 9655732
feat: add package json path for version managing
teodorus-nathaniel 50517ca
feat: add additional custom package json path
teodorus-nathaniel 971bed7
fix: remove version in pnpm action setup
teodorus-nathaniel 25831c4
refactor: rename package_json_path to package_json_file
teodorus-nathaniel 1743656
chore: update readme
teodorus-nathaniel 20e0836
feat: add default value because running from workflow doesn't have th…
teodorus-nathaniel 5e252d1
refactor: extract the package json default to another step
teodorus-nathaniel 44a97bc
refactor: use default value in pr checks
teodorus-nathaniel 62ac472
docs: add custom package json file input
teodorus-nathaniel a8baa55
chore: use bun instead of pnpm
teodorus-nathaniel 4009909
feat: use bun instead of pnpm
teodorus-nathaniel c7c6b37
chore: remove unused inputs
teodorus-nathaniel f41359f
fix: wrong input usage of prettier
teodorus-nathaniel 554afed
chore: remove package json check
teodorus-nathaniel f8a62af
feat: add back prettier cehck in package json
teodorus-nathaniel 9fff902
chore: add clearer error message
teodorus-nathaniel 9d1d777
chore: add pr checks self
teodorus-nathaniel 44c76dc
chore: remove version
teodorus-nathaniel 10dc04c
chore: remove commit messages check
teodorus-nathaniel 9cbd22b
docs: update readme
teodorus-nathaniel 3c9ae2e
docs: remove package_json_file
teodorus-nathaniel fa737d1
docs: remove unnecessary constraint
teodorus-nathaniel 56a14cf
chore: use yml instead of json config
teodorus-nathaniel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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,34 @@ | ||
| name: Conventional Commit Check for PR Title | ||
|
|
||
| on: | ||
| workflow_call: | ||
|
|
||
| jobs: | ||
| commit-check: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Bun | ||
| uses: oven-sh/setup-bun@v2 | ||
| with: | ||
| bun-version: latest | ||
|
|
||
| - name: Install commitlint | ||
| run: | | ||
| bun i -g @commitlint/cli | ||
| bun i -D @commitlint/config-conventional | ||
teodorus-nathaniel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Create commitlint config if missing | ||
| run: | | ||
| if [ ! -f .commitlintrc.json ] && [ ! -f .commitlintrc.js ] && [ ! -f .commitlintrc.yml ] && [ ! -f .commitlintrc.yaml ] && ! grep -q '"commitlint"' "package.json" 2>/dev/null; then | ||
| echo "extends:" > .commitlintrc.yml | ||
| echo " - '@commitlint/config-conventional'" >> .commitlintrc.yml | ||
| fi | ||
|
|
||
| - name: Check PR title | ||
| if: github.event_name == 'pull_request' | ||
| env: | ||
| PR_TITLE: ${{ github.event.pull_request.title }} | ||
| run: | | ||
| echo "$PR_TITLE" | commitlint | ||
This file contains hidden or 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,23 @@ | ||
| name: Markdown Lint | ||
|
|
||
| on: | ||
| workflow_call: | ||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install rumdl pre-compiled binary | ||
| # EXPECTED_SHA256 is obtained from `curl -sL $DOWNLOAD_URL | sha256sum` | ||
| run: | | ||
| DOWNLOAD_URL="https://github.com/rvben/rumdl/releases/download/v0.0.185/rumdl-v0.0.185-x86_64-unknown-linux-gnu.tar.gz" | ||
teodorus-nathaniel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| EXPECTED_SHA256="5e6f28fa4935fb7d022c4f2d64f82b12206038d17e6570466afe7d7a3b135fba" | ||
| curl -sL $DOWNLOAD_URL -o /tmp/rumdl.tar.gz | ||
| echo "$EXPECTED_SHA256 /tmp/rumdl.tar.gz" | sha256sum -c - | ||
| tar -xzf /tmp/rumdl.tar.gz -C /usr/local/bin/ | ||
| chmod +x /usr/local/bin/rumdl | ||
| - name: Lint Markdown | ||
| run: rumdl check --output-format github . | ||
This file contains hidden or 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,9 @@ | ||
| name: PR Checks | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, reopened, synchronize, ready_for_review] | ||
|
|
||
| jobs: | ||
| checks: | ||
| uses: ./.github/workflows/pr-checks.yml |
This file contains hidden or 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,55 @@ | ||
| name: PR Checks | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| run-prettier: | ||
| description: "Run Prettier check" | ||
| required: false | ||
| type: boolean | ||
| default: true | ||
| run-markdown: | ||
| description: "Run Markdown check" | ||
| required: false | ||
| type: boolean | ||
| default: true | ||
| run-commits: | ||
| description: "Run Commit check" | ||
| required: false | ||
| type: boolean | ||
| default: true | ||
|
|
||
| jobs: | ||
| check-draft: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| should-run: ${{ steps.check.outputs.should-run }} | ||
| steps: | ||
| - id: check | ||
| run: | | ||
| if [ "${{ github.event_name }}" != "pull_request" ] || [ "${{ github.event.pull_request.draft }}" != "true" ]; then | ||
| echo "should-run=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "should-run=false" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| prettier: | ||
| needs: check-draft | ||
| if: | ||
| needs.check-draft.outputs.should-run == 'true' && inputs.run-prettier != | ||
| false | ||
| uses: ./.github/workflows/prettier.yml | ||
|
|
||
| markdown: | ||
| needs: check-draft | ||
| if: | ||
| needs.check-draft.outputs.should-run == 'true' && inputs.run-markdown != | ||
| false | ||
| uses: ./.github/workflows/markdown-check.yml | ||
|
|
||
| commits: | ||
| needs: check-draft | ||
| if: | ||
| needs.check-draft.outputs.should-run == 'true' && inputs.run-commits != | ||
| false | ||
| uses: ./.github/workflows/commit-check.yml |
This file contains hidden or 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,41 @@ | ||
| name: Prettier Check | ||
|
|
||
| on: | ||
| workflow_call: | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| jobs: | ||
| prettier: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Check for Prettier config | ||
| run: | | ||
| CONFIG_FILES=".prettierrc .prettierrc.json .prettierrc.js .prettierrc.yaml .prettierrc.yml .prettierrc.toml prettier.config.js prettier.config.mjs" | ||
| HAS_CONFIG=false | ||
|
|
||
| for file in $CONFIG_FILES; do | ||
| if [ -f "$file" ]; then | ||
| HAS_CONFIG=true | ||
| break | ||
| fi | ||
| done | ||
|
|
||
| if [ "$HAS_CONFIG" = false ] && ! grep -q '"prettier"' "package.json" 2>/dev/null; then | ||
| echo "::error file=.prettierrc::No Prettier configuration file found." | ||
| echo "A Prettier config file is required to ensure consistent formatting across all developers." | ||
| echo "Without a shared config, each developer's local Prettier settings will differ, causing unnecessary formatting changes in commits." | ||
| echo "Please create a .prettierrc file in your repository root." | ||
zolotokrylin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Setup Bun | ||
| uses: oven-sh/setup-bun@v2 | ||
| with: | ||
| bun-version: latest | ||
|
|
||
| - name: Install Prettier | ||
| run: bun i -g prettier | ||
|
|
||
| - name: Check formatting | ||
| run: prettier --check . | ||
This file contains hidden or 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 @@ | ||
| node_modules |
This file contains hidden or 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 @@ | ||
| pnpm-lock.yaml |
This file contains hidden or 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,5 @@ | ||
| { | ||
| "printWidth": 80, | ||
| "proseWrap": "always", | ||
| "singleQuote": false | ||
| } |
This file contains hidden or 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,157 @@ | ||
| # Github Actions | ||
| # GitHub Actions | ||
|
|
||
| Shared GitHub Actions workflows for consistent code quality checks across | ||
| repositories. | ||
|
|
||
| ## Available Workflows | ||
|
|
||
| This repository provides reusable workflows for: | ||
|
|
||
| - **Prettier Check** - Validates code formatting with Prettier | ||
| - **Markdown Lint** - Lints Markdown files using rumdl | ||
| - **Conventional Commit Check for PR Title** - Validates PR titles follow | ||
| conventional commit format | ||
| - **PR Checks** - Combined workflow that runs all checks (or selected ones) with | ||
| draft PR handling | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Option 1: Combined Workflow (Recommended for Simple Setup) | ||
|
|
||
| Use the combined `pr-checks.yml` workflow to run all checks at once. This | ||
| workflow automatically handles draft PRs and runs all checks by default. | ||
|
|
||
| #### Basic Usage | ||
|
|
||
| Create `.github/workflows/pr-checks.yml` in your repository: | ||
|
|
||
| ```yaml | ||
| name: PR Checks | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, reopened, synchronize, ready_for_review] | ||
|
|
||
| jobs: | ||
| checks: | ||
| uses: holdex/github-actions/.github/workflows/pr-checks.yml@main | ||
| ``` | ||
|
|
||
| #### Selective Checks | ||
|
|
||
| To run only specific checks, pass input flags: | ||
|
|
||
| ```yaml | ||
| name: PR Checks | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, reopened, synchronize, ready_for_review] | ||
|
|
||
| jobs: | ||
| checks: | ||
| uses: holdex/github-actions/.github/workflows/pr-checks.yml@main | ||
| with: | ||
| run-prettier: true | ||
| run-markdown: false # Skip markdown check | ||
| run-commits: true | ||
| ``` | ||
|
|
||
| ### Option 2: Individual Workflows | ||
|
|
||
| Use individual workflows for granular control over when each check runs. | ||
|
|
||
| #### Prettier Check | ||
|
|
||
| ```yaml | ||
| name: Prettier Check | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, reopened, synchronize] | ||
|
|
||
| jobs: | ||
| prettier: | ||
| uses: holdex/github-actions/.github/workflows/prettier.yml@main | ||
| ``` | ||
|
|
||
| **Requirements:** | ||
|
|
||
| - Prettier configuration file (`.prettierrc`, `.prettierrc.json`, etc.) or | ||
| `prettier` config in `package.json` | ||
|
|
||
| #### Markdown Lint | ||
|
|
||
| ```yaml | ||
| name: Markdown Lint | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, reopened, synchronize] | ||
|
|
||
| jobs: | ||
| markdown: | ||
| uses: holdex/github-actions/.github/workflows/markdown-check.yml@main | ||
| ``` | ||
|
|
||
| #### Conventional Commit Check | ||
|
|
||
| ```yaml | ||
| name: Commit Check | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, reopened, synchronize] | ||
|
|
||
| jobs: | ||
| commits: | ||
| uses: holdex/github-actions/.github/workflows/commit-check.yml@main | ||
| ``` | ||
|
|
||
| **Requirements:** | ||
|
|
||
| - Commitlint configuration file (`.commitlintrc.json`, etc.) or `commitlint` | ||
| config in `package.json` | ||
| - If no config exists, the workflow will create a default `.commitlintrc.json` | ||
| file | ||
|
|
||
| ## Workflow Details | ||
|
|
||
| ### PR Checks (`pr-checks.yml`) | ||
|
|
||
| The combined workflow includes: | ||
|
|
||
| - **Draft PR handling** - Automatically skips checks for draft PRs | ||
| - **Selective execution** - Control which checks run via inputs | ||
| - **Default behavior** - Runs all checks if no inputs specified | ||
|
|
||
| **Inputs:** | ||
|
|
||
| - `run-prettier` (boolean, default: `true`) - Run Prettier check | ||
| - `run-markdown` (boolean, default: `true`) - Run Markdown lint | ||
| - `run-commits` (boolean, default: `true`) - Run commit check | ||
|
|
||
| ### Prettier Check (`prettier.yml`) | ||
|
|
||
| - Validates that a Prettier configuration exists | ||
| - Checks code formatting using Prettier | ||
| - Supports all Prettier-supported file types | ||
| - Uses Bun for package management | ||
|
|
||
| ### Markdown Lint (`markdown-check.yml`) | ||
|
|
||
| - Uses `rumdl` v0.0.185 for fast Markdown linting | ||
| - Checks all Markdown files in the repository | ||
| - Reports issues with GitHub annotations | ||
|
|
||
| ### Conventional Commit Check (`commit-check.yml`) | ||
|
|
||
| - Validates PR titles follow conventional commit format | ||
| - Creates default commitlint config if missing (requires `package.json`) | ||
| - Uses Bun for package management | ||
|
|
||
| ## Requirements | ||
|
|
||
| - Node.js 22+ | ||
| - Bun (installed automatically in workflows) | ||
| - Uses the latest version of Bun |
This file contains hidden or 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 @@ | ||
| { | ||
| "lockfileVersion": 1, | ||
| "configVersion": 1, | ||
| "workspaces": { | ||
| "": { | ||
| "name": "github-actions", | ||
| "devDependencies": { | ||
| "prettier": "^3.7.4", | ||
| }, | ||
| }, | ||
| }, | ||
| "packages": { | ||
| "prettier": ["prettier@3.7.4", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-v6UNi1+3hSlVvv8fSaoUbggEM5VErKmmpGA7Pl3HF8V6uKY7rvClBOJlH6yNwQtfTueNkGVpOv/mtWL9L4bgRA=="], | ||
| } | ||
| } |
This file contains hidden or 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,16 @@ | ||
| { | ||
| "name": "github-actions", | ||
| "version": "1.0.0", | ||
| "description": "", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1", | ||
| "format": "prettier --write ." | ||
| }, | ||
| "keywords": [], | ||
| "author": "", | ||
| "license": "ISC", | ||
| "devDependencies": { | ||
| "prettier": "^3.7.4" | ||
| } | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.