forked from neetcode-gh/leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request neetcode-gh#575 from Ahmad-A0/main
Add format workflow
- Loading branch information
Showing
3 changed files
with
88 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: Format Files | ||
|
||
# cpp | ||
# csharp - https://github.com/dotnet/format ? | ||
# java - prettier-plugin-java | ||
# javascript - prettier | ||
# python - black | ||
# ruby - rufo | ||
# swift - https://github.com/apple/swift-format ? | ||
# typescript - prettier | ||
|
||
on: | ||
# pull_request_target: | ||
# types: [opened, synchronize] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
Format: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [16.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
fetch-depth: 1 | ||
|
||
- name: Use Node.js (dependency) | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Install Rufo (dependency) | ||
run: | | ||
sudo apt update | ||
sudo gem install rufo | ||
- name: Install Prettier | ||
run: | | ||
npm install -g prettier | ||
npm install -g prettier-plugin-java | ||
- name: Install Black | ||
uses: BSFishy/pip-action@v1 | ||
with: | ||
packages: black | ||
|
||
- name: Format | ||
run: | | ||
prettier --config "$GITHUB_WORKSPACE/.prettierrc" --write "$GITHUB_WORKSPACE/javascript/*.js" 2>&1 || true | ||
prettier --config "$GITHUB_WORKSPACE/.prettierrc" --write "$GITHUB_WORKSPACE/typescript/*.ts" 2>&1 || true | ||
prettier --config "$GITHUB_WORKSPACE/.prettierrc" --write "$GITHUB_WORKSPACE/java/*.java" 2>&1 || true | ||
rufo "$GITHUB_WORKSPACE/ruby" 2>&1 || true | ||
python -m black "$GITHUB_WORKSPACE/python/" 2>&1 || true | ||
- name: Push | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Bot-A0" | ||
git add . | ||
git commit -m "🎨 Format files (🛠️ from Github Actions)" || true | ||
git push || true |
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,23 @@ | ||
{ | ||
"semi": true, | ||
"singleQuote": true, | ||
"endOfLine": "lf", | ||
"overrides": [ | ||
{ | ||
"files": ["javascript/*.js"], | ||
"options": {} | ||
}, | ||
{ | ||
"files": ["typescript/*.ts"], | ||
"options": {} | ||
}, | ||
{ | ||
"files": ["ruby/*.rb"], | ||
"options": {} | ||
}, | ||
{ | ||
"files": ["java/*.java"], | ||
"options": {} | ||
} | ||
] | ||
} |