mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-09-20 06:58:39 +03:00
Factor tool versions out into server/VERSIONS.json.
This helps us use the same versions locally as in CI. If you're using the Nix setup, it guarantees it. PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5111 GitOrigin-RevId: 6e00cd7a78593df1e60fac37cc1195aba60e488f
This commit is contained in:
parent
3c2af43817
commit
0e4d709285
24
.github/workflows/hlint.yml
vendored
24
.github/workflows/hlint.yml
vendored
@ -3,7 +3,7 @@ on:
|
||||
label:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'server/**'
|
||||
- "server/**"
|
||||
|
||||
jobs:
|
||||
hlint:
|
||||
@ -11,32 +11,36 @@ jobs:
|
||||
if: "!contains(github.event.pull_request.labels.*.name, 'ignore-server-hlint-checks') && github.event.label.name != 'ignore-server-hlint-checks'"
|
||||
env:
|
||||
working-directory: .
|
||||
HLINT_BASE_URL: https://dl.haskellworks.io/binaries/hlint
|
||||
HLINT_VERSION: 3.1.6
|
||||
HLINT_BASE_URL: https://github.com/ndmitchell/hlint/releases/download
|
||||
HLINT_ARCH: x86_64
|
||||
HLINT_OS: linux
|
||||
HLINT_URL: $HLINT_BASE_URL/hlint-${HLINT_VERSION}-${HLINT_ARCH}-${HLINT_OS}.tar.gz
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Download hlint
|
||||
working-directory: ${{env.working-directory}}
|
||||
run: |
|
||||
echo "Downloading from ${{env.HLINT_URL}}"
|
||||
curl "${{env.HLINT_URL}}" -o "./hlint-${{env.HLINT_VERSION}}-${{env.HLINT_ARCH}}-${{env.HLINT_OS}}.tar.gz"
|
||||
tar -zxvf "./hlint-${{env.HLINT_VERSION}}-${{env.HLINT_ARCH}}-${{env.HLINT_OS}}.tar.gz" -C "."
|
||||
HLINT_VERSION="$(jq -r '.hlint' ./server/VERSIONS.json)"
|
||||
HLINT_URL="${{env.HLINT_BASE_URL}}/v${HLINT_VERSION}/hlint-${HLINT_VERSION}-${{env.HLINT_ARCH}}-${{env.HLINT_OS}}.tar.gz"
|
||||
echo "Downloading from ${HLINT_URL}"
|
||||
curl --fail --location --output "./hlint.tar.gz" "${HLINT_URL}"
|
||||
tar xvf \
|
||||
hlint.tar.gz \
|
||||
--directory='.' \
|
||||
--strip-components=1 \
|
||||
"hlint-${HLINT_VERSION}/hlint"
|
||||
|
||||
- name: Run hlint
|
||||
shell: bash
|
||||
run: |
|
||||
CHANGED_HS_FILES=$(git diff --name-only origin/${{github.base_ref}}...${{github.sha}} -- "${{env.working-directory}}/server/*.hs" | xargs -i -d '\n' sh -c 'ls -d {} 2>/dev/null || true')
|
||||
CHANGED_HS_FILES=$(git diff --name-only origin/${{github.base_ref}}...${{github.sha}} -- "./*.hs" | xargs -i -d '\n' sh -c 'ls -d {} 2>/dev/null || true')
|
||||
echo "$CHANGED_HS_FILES"
|
||||
JQ_SCRIPT='.[] | "::" + (if (.severity=="Warning" or .severity=="Error") then "error" else "warning" end) + " file=\(.file),line=\(.startLine),col=\(.startColumn)::\(.severity):" + " \(.hint)%0AFound:%0A \(.from | gsub("\n";"%0A "))%0A" + try ("Perhaps:%0A " + (.to | gsub("\n";"%0A ")) + "%0A") catch "" + try (if .note | length > 0 then "Note:%0A " + (.note | join("\n") | gsub("\n";"%0A ")) else "" end) catch ""'
|
||||
if [[ "$CHANGED_HS_FILES" ]]
|
||||
then
|
||||
OUT=$(mktemp)
|
||||
echo "$CHANGED_HS_FILES" | xargs ${{env.working-directory}}/hlint --no-exit-code --json --hint=${{env.working-directory}}/.hlint.yaml | jq -r "$JQ_SCRIPT" | tee $OUT
|
||||
echo "$CHANGED_HS_FILES" | xargs ${{env.working-directory}}/hlint --no-exit-code --json --hint=./.hlint.yaml | jq -r "$JQ_SCRIPT" | tee $OUT
|
||||
test -z "$(grep -E '^::error' $OUT)"
|
||||
fi
|
||||
|
@ -9,20 +9,28 @@ SHELL_FILES = $(shell git ls-files '*.sh')
|
||||
CHANGED_SHELL_FILES = $(shell git diff --diff-filter=d --name-only `git merge-base HEAD origin/main` | grep '.*\.sh$$')
|
||||
|
||||
HLINT = hlint
|
||||
HLINT_VERSION = $(shell $(HLINT) --numeric-version)
|
||||
HLINT_CHECK_VERSION = $(shell jq '.hlint' ./server/VERSIONS.json)
|
||||
|
||||
NIX_FMT = nixpkgs-fmt
|
||||
|
||||
ORMOLU_CHECK_VERSION = 0.3.0.0
|
||||
ORMOLU_ARGS = --cabal-default-extensions
|
||||
ORMOLU = ormolu
|
||||
ORMOLU_ARGS = --cabal-default-extensions
|
||||
ORMOLU_VERSION = $(shell $(ORMOLU) --version | awk 'NR==1 { print $$2 }')
|
||||
ORMOLU_CHECK_VERSION = $(shell jq '.ormolu' ./server/VERSIONS.json)
|
||||
|
||||
SHELLCHECK = shellcheck
|
||||
|
||||
.PHONY: check-hlint-version
|
||||
check-hlint-version:
|
||||
@if ! [ "$(HLINT_VERSION)" = "$(HLINT_CHECK_VERSION)" ]; then \
|
||||
echo "WARNING: hlint version mismatch, expected $(HLINT_CHECK_VERSION) but got $(HLINT_VERSION)"; \
|
||||
fi
|
||||
|
||||
.PHONY: check-ormolu-version
|
||||
check-ormolu-version:
|
||||
@if ! [ "$(ORMOLU_VERSION)" = "$(ORMOLU_CHECK_VERSION)" ]; then \
|
||||
echo "WARNING: ormolu version mismatch, expected $(ORMOLU_CHECK_VERSION)"; \
|
||||
echo "WARNING: ormolu version mismatch, expected $(ORMOLU_CHECK_VERSION) but got $(ORMOLU_VERSION)"; \
|
||||
fi
|
||||
|
||||
.PHONY: format-hs
|
||||
@ -89,13 +97,13 @@ check-format-changed: check-format-hs-changed check-format-nix
|
||||
|
||||
.PHONY: lint-hs
|
||||
## lint-hs: lint Haskell code using `hlint`
|
||||
lint-hs:
|
||||
lint-hs: check-hlint-version
|
||||
@echo running hlint
|
||||
@$(HLINT) $(HS_FILES)
|
||||
|
||||
.PHONY: lint-hs-changed
|
||||
## lint-hs-changed: lint Haskell code using `hlint` (changed files only)
|
||||
lint-hs-changed:
|
||||
lint-hs-changed: check-hlint-version
|
||||
@echo running hlint
|
||||
@if [ -n "$(CHANGED_HS_FILES)" ]; then \
|
||||
$(HLINT) $(CHANGED_HS_FILES); \
|
||||
|
@ -8,6 +8,9 @@ own machine and how to contribute.
|
||||
- [GHC](https://www.haskell.org/ghc/) 8.10.7 and [cabal-install](https://cabal.readthedocs.io/en/latest/)
|
||||
- There are various ways these can be installed, but [ghcup](https://www.haskell.org/ghcup/) is a good choice if you’re not sure.
|
||||
- There are few system packages required like `libpq-dev`, `libssl-dev`, etc. The best place to get the entire list is from the packager [Dockerfile](../.buildkite/dockerfiles/ci-builders/server-builder.dockerfile)
|
||||
- Additional Haskell tools (expected versions can be found in _VERSIONS.json_):
|
||||
- [HLint](https://github.com/ndmitchell/hlint), for linting Haskell code
|
||||
- [Ormolu](https://github.com/tweag/ormolu), for formatting Haskell code
|
||||
|
||||
For building console and running test suite:
|
||||
|
||||
@ -32,7 +35,6 @@ If your npm is too old (>= 5.7 required):
|
||||
|
||||
or update your nodejs.
|
||||
|
||||
|
||||
## Development workflow
|
||||
|
||||
You should fork the repo on github and then `git clone https://github.com/<your-username>/graphql-engine`.
|
||||
@ -58,6 +60,7 @@ To set up the project configuration to coincide with the testing scripts below,
|
||||
$ ln -s cabal/dev-sh.project.local cabal.project.local
|
||||
|
||||
#### Compiling on MacOS
|
||||
|
||||
If you are on MacOS, or experiencing any errors related to missing dependencies on MacOS, please try [this alternative setup guide](COMPILING-ON-MACOS.md).
|
||||
|
||||
### IDE Support
|
||||
@ -97,7 +100,7 @@ You can run the test suite with:
|
||||
|
||||
$ scripts/dev.sh test
|
||||
|
||||
This should run in isolation. The output format is described in the [pytest documentation](https://docs.pytest.org/en/latest/usage.html#detailed-summary-report). Errors and failures are indicated by `F`s and `E`s.
|
||||
This should run in isolation. The output format is described in the [pytest documentation](https://docs.pytest.org/en/latest/usage.html#detailed-summary-report). Errors and failures are indicated by `F`s and `E`s.
|
||||
|
||||
Optionally, launch a new container for alternative (MSSQL) backend with:
|
||||
|
||||
@ -127,11 +130,11 @@ This will launch a server on port 8080, and it will serve the console assets if
|
||||
|
||||
`graphql-engine` has several test suites, among them:
|
||||
|
||||
1. A small set of unit tests and integration tests written in Haskell, in `server/src-test`.
|
||||
1. A small set of unit tests and integration tests written in Haskell, in `server/src-test`.
|
||||
|
||||
2. A new integration test suite written in Haskell, in `server/tests-hspec`.
|
||||
2. A new integration test suite written in Haskell, in `server/tests-hspec`.
|
||||
|
||||
3. An extensive set of end-to-end tests written in Python, in `server/tests-py`.
|
||||
3. An extensive set of end-to-end tests written in Python, in `server/tests-py`.
|
||||
|
||||
All sets of tests require running databases:
|
||||
|
||||
@ -142,6 +145,7 @@ All sets of tests require running databases:
|
||||
##### Running py tests
|
||||
|
||||
The easiest way to run the Python integration test suite is by running:
|
||||
|
||||
```sh
|
||||
scripts/dev.sh test --integration
|
||||
```
|
||||
@ -151,6 +155,7 @@ For more details please check out the [README](./tests-py/README.md).
|
||||
##### Running the Haskell test suite
|
||||
|
||||
There are three categories of unit tests:
|
||||
|
||||
- true unit tests
|
||||
- Postgres unit tests (require a postgres instance)
|
||||
- MSSQL unit tests (require a MSSQL instance)
|
||||
@ -262,6 +267,7 @@ instructions help in setting up a local hoogle server that enables searching thr
|
||||
### Step 1: Installing hoogle
|
||||
|
||||
Installing `hoogle` is fairly simple with `cabal`.
|
||||
|
||||
```bash
|
||||
cabal install hoogle
|
||||
```
|
||||
|
4
server/VERSIONS.json
Normal file
4
server/VERSIONS.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"hlint": "3.3.6",
|
||||
"ormolu": "0.3.1.0"
|
||||
}
|
Loading…
Reference in New Issue
Block a user