-
Notifications
You must be signed in to change notification settings - Fork 497
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a CI check for code formatting (#151)
This PR adds a GitHub action (🎉) that checks for the latest refmt syntax. This is done thanks to @thomsj which brought up the problems with formatting in the repo! 👏 #105 (comment) The current implementation is not ideal: it installs esy and then installs OCaml and @esy-ocaml/reason. A better way to do it is to distribute refmt as a standalone binary from the latest Reason release. This will be fast to install and therefore fast to integrate with CI. An approach to do so is to add an artifact to the CircleCI runs, and then use something like circleci-artifacts.now.sh to fetch the artifact, extract it and profit 💰 In the meantime, it takes <4m to run it, which is much faster than the Azure Linux build, not to mention the Windows one.
- Loading branch information
Showing
27 changed files
with
1,836 additions
and
6 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,63 @@ | ||
name: Check formatting | ||
on: [push] | ||
|
||
# consider using docker: ocaml/opam2:4.06 | ||
# - sudo apt-get update && apt-get install -y m4 | ||
# - opam update && opam install reason | ||
# - refmt # is new | ||
|
||
jobs: | ||
# build: | ||
# name: build project | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - uses: actions/checkout@master | ||
# with: | ||
# fetch-depth: 1 | ||
# - uses: actions/setup-node@v1 | ||
# with: | ||
# node-version: '10.x' | ||
# - run: npm install -g esy@latest | ||
# - run: esy i | ||
# - run: esy b | ||
# - run: esy export-dependencies | ||
# - run: tar -czf build.tar.gz _export | ||
# - uses: actions/upload-artifact@master | ||
# with: | ||
# name: cache-linux-build-dependencies | ||
# path: build.tar.gz | ||
|
||
test_refmt: | ||
name: run refmt | ||
runs-on: ubuntu-latest | ||
# needs: [build] | ||
steps: | ||
- uses: actions/checkout@master | ||
with: | ||
fetch-depth: 1 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: '10.x' | ||
# - run: npm install -g esy@latest | ||
# - uses: actions/download-artifact@master | ||
# with: | ||
# name: cache-linux-build-dependencies | ||
# - run: tar -xzf cache-linux-build-dependencies/build.tar.gz | ||
# - run: esy import-build _export/* | ||
# - run: esy i | ||
# - run: esy fmt | ||
- run: npm i -g esy@latest | ||
- run: esy @fmt i | ||
- run: esy @fmt refmt --in-place */*.re | ||
# - run: ./scripts/fmt_all.sh | ||
# name: refmt all the files | ||
- run: | | ||
if [ -n "$(git status --porcelain)" ]; then | ||
echo "There are differences:" | ||
git status --porcelain | ||
echo "----" | ||
echo "" | ||
echo 'Please run `esy fmt` locally to fix the issues.' | ||
exit 1 | ||
fi | ||
name: "Throw if something changed" |
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,3 @@ | ||
|
||
# Set eol to LF so files aren't converted to CRLF-eol on Windows. | ||
* text eol=lf |
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,3 @@ | ||
|
||
# Reset any possible .gitignore, we want all esy.lock to be un-ignored. | ||
!* |
Oops, something went wrong.