Skip to content

Commit

Permalink
chore: format using Make (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevgo authored Sep 22, 2022
1 parent 2325311 commit 935cc04
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 24 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@ name: Format

on:
pull_request:
types: [opened, reopened]
push:

jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: cache-node
uses: actions/cache@v3
- uses: actions/setup-go@v3
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
- run: npm ci --legacy-peer-deps
if: steps.cache-node.outputs.cache-hit != 'true'
- run: npm run format
go-version: 1.19
- run: make format
- name: Indicate formatting issues
run: git diff HEAD --exit-code
run: git diff HEAD --exit-code --color
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
format: .bin/shfmt node_modules # formats the source code
echo formatting ...
.bin/shfmt --write .
npm run format
npm exec -- prettier --write .

help: # shows all available Make commands
cat Makefile | grep '^[^ ]*:' | grep -v '^\.bin/' | grep -v '^node_modules' | grep -v '.SILENT:' | grep -v help | sed 's/:.*#/#/' | column -s "#" -t
Expand All @@ -11,7 +11,6 @@ test: .bin/shellcheck .bin/shfmt node_modules # runs all linters
find . -name '*.sh' | xargs .bin/shellcheck
echo Verifying formatting ...
.bin/shfmt --list .
npm run format:check

.bin/shellcheck: Makefile
echo installing Shellcheck ...
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
"url": "git+https://github.com/ory/meta.git"
},
"scripts": {
"format": "prettier --write .",
"format:check": "prettier --check .",
"text-run": "text-run"
},
"prettier": "ory-prettier-styles",
"devDependencies": {
"ory-prettier-styles": "1.3.0",
"prettier": "^2.7.1",
"prettier": "2.7.1",
"prettier-plugin-packagejson": "^2.2.18",
"text-runner": "5.0.2"
}
Expand Down
12 changes: 3 additions & 9 deletions templates/repository/common/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,9 @@ request, go through this checklist:
changes against the `master` branch.
1. Run the full project test suite with the `go test -tags sqlite ./...` (or
equivalent) command and confirm that it passes.
1. Run `make format` if a `Makefile` is available, `gofmt -s` if the project is
written in Go, `npm run format` if the project is written for NodeJS.
1. Run `make format`
1. Add a descriptive prefix to commits. This ensures a uniform commit history
and helps structure the changelog.
Please refer to this
and helps structure the changelog. Please refer to this
[list of prefixes for $PROJECT](https://github.com/$REPOSITORY/blob/master/.github/semantic.yml)
for an overview.

Expand Down Expand Up @@ -234,11 +232,7 @@ Please disclose vulnerabilities exclusively to

## Code style

Please follow these guidelines when formatting source code:

- Go code should match the output of `gofmt -s` and pass `golangci-lint run`.
- NodeJS and JavaScript code should be prettified using `npm run format` where
appropriate.
Please run `make format` to format all source code following the Ory standard.

### Working with forks

Expand Down

0 comments on commit 935cc04

Please sign in to comment.