Skip to content

Commit

Permalink
Merge pull request neetcode-gh#575 from Ahmad-A0/main
Browse files Browse the repository at this point in the history
Add format workflow
  • Loading branch information
Ahmad-A0 authored Jul 21, 2022
2 parents 8a8face + 1af0e81 commit 8df902e
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/format.yml
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
23 changes: 23 additions & 0 deletions .prettierrc
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": {}
}
]
}
Empty file added .rufo
Empty file.

0 comments on commit 8df902e

Please sign in to comment.