2022-08-03 14:05:59 +03:00
|
|
|
# ghcid gets its own cache
|
2022-07-19 15:19:12 +03:00
|
|
|
GHCID_FLAGS = --builddir ./dist-newstyle/repl --repl-option -O0 --repl-option -fobject-code
|
2022-08-03 14:05:59 +03:00
|
|
|
GHCID_TESTS_FLAGS = --builddir ./dist-newstyle/repl-tests --repl-option -O0
|
|
|
|
|
2022-07-19 15:19:12 +03:00
|
|
|
PANE_WIDTH = $(shell tmux display -p "\#{pane_width}" || echo 80)
|
|
|
|
PANE_HEIGHT = $(shell tmux display -p "\#{pane_height}" || echo 30 )
|
|
|
|
|
2022-08-03 14:05:59 +03:00
|
|
|
# once ghcid's window errors are fixed we can remove this explicit width/height
|
|
|
|
# nonsense
|
|
|
|
# this needs to make it into ghcid: https://github.com/biegunka/terminal-size/pull/16
|
|
|
|
define run_ghcid_hspec_tests
|
|
|
|
@if [[ $$(uname -p) == 'arm' ]]; then \
|
Nix: Get the Nix shell working on macOS/aarch64.
Improvements to the Nix configuration so that macOS is supported.
Microsoft SQL Server is still not supported (yet; I have something in mind there), but the rest works. You can still use Homebrew to install the SQL Server drivers.
I had to make the following changes:
* I updated nixpkgs, because it's been a while.
* I made `ODBCINSTINI` optional so that it's not loaded on macOS, as it depends on `msodbcsql17`, which is broken on macOS.
* I upgraded OpenSSL.
* I set `DYLD_LIBRARY_PATH` on macOS so GHC finds OpenSSL; otherwise, it uses the wrong version of `libcrypto`, and fails with a fun error:
> WARNING: ghc is loading libcrypto in an unsafe way
* I patched GHC to fix compilation on macOS (copied from https://github.com/NixOS/nixpkgs/pull/149942).
To test this out, you can run `nix develop` (or install [direnv][] and add `use flake` to _.envrc.local_), and then try building HGE in the shell provided.
Fair warning: GHC needs to be built, and takes _aaages_ the first time. If this becomes useful to others, we can set up a shared cache.
[direnv]: https://direnv.net/
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5989
GitOrigin-RevId: 7130738d47709c37778b31c134061758ce23e959
2022-09-30 22:14:53 +03:00
|
|
|
HSPEC_MATCH="$(2)" ghcid -c "DYLD_LIBRARY_PATH=$$DYLD_LIBRARY_PATH cabal repl $(1) $(GHCID_TESTS_FLAGS)" \
|
2022-08-03 14:05:59 +03:00
|
|
|
--test "main" \
|
|
|
|
--width=$(PANE_WIDTH) \
|
|
|
|
--height=$(PANE_HEIGHT); \
|
|
|
|
else \
|
|
|
|
HSPEC_MATCH="$(2)" ghcid -c "cabal repl $(1) $(GHCID_TESTS_FLAGS)" \
|
|
|
|
--test "main"; \
|
|
|
|
fi
|
|
|
|
endef
|
2022-07-19 15:19:12 +03:00
|
|
|
|
2022-08-19 14:22:28 +03:00
|
|
|
define run_ghcid_main_tests
|
|
|
|
@if [[ $$(uname -p) == 'arm' ]]; then \
|
Nix: Get the Nix shell working on macOS/aarch64.
Improvements to the Nix configuration so that macOS is supported.
Microsoft SQL Server is still not supported (yet; I have something in mind there), but the rest works. You can still use Homebrew to install the SQL Server drivers.
I had to make the following changes:
* I updated nixpkgs, because it's been a while.
* I made `ODBCINSTINI` optional so that it's not loaded on macOS, as it depends on `msodbcsql17`, which is broken on macOS.
* I upgraded OpenSSL.
* I set `DYLD_LIBRARY_PATH` on macOS so GHC finds OpenSSL; otherwise, it uses the wrong version of `libcrypto`, and fails with a fun error:
> WARNING: ghc is loading libcrypto in an unsafe way
* I patched GHC to fix compilation on macOS (copied from https://github.com/NixOS/nixpkgs/pull/149942).
To test this out, you can run `nix develop` (or install [direnv][] and add `use flake` to _.envrc.local_), and then try building HGE in the shell provided.
Fair warning: GHC needs to be built, and takes _aaages_ the first time. If this becomes useful to others, we can set up a shared cache.
[direnv]: https://direnv.net/
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5989
GitOrigin-RevId: 7130738d47709c37778b31c134061758ce23e959
2022-09-30 22:14:53 +03:00
|
|
|
HSPEC_MATCH="$(3)" ghcid -c "DYLD_LIBRARY_PATH=$$DYLD_LIBRARY_PATH cabal repl $(1) $(GHCID_TESTS_FLAGS)" \
|
2022-08-19 14:22:28 +03:00
|
|
|
--test "main" \
|
|
|
|
--setup ":set args $(2)" \
|
|
|
|
--width=$(PANE_WIDTH) \
|
|
|
|
--height=$(PANE_HEIGHT); \
|
|
|
|
else \
|
2022-08-24 12:01:13 +03:00
|
|
|
HSPEC_MATCH="$(3)" ghcid -c "cabal repl $(1) $(GHCID_TESTS_FLAGS)" \
|
2022-08-19 14:22:28 +03:00
|
|
|
--test "main" \
|
|
|
|
--setup ":set args $(2)"; \
|
|
|
|
fi
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
2022-07-19 15:19:12 +03:00
|
|
|
define run_ghcid
|
|
|
|
@if [[ $$(uname -p) == 'arm' ]]; then \
|
|
|
|
ghcid -c "cabal repl $(1) $(GHCID_FLAGS)" --width=$(PANE_WIDTH) --height=$(PANE_HEIGHT); \
|
|
|
|
else \
|
|
|
|
ghcid -c "cabal repl $(1) $(GHCID_FLAGS)"; \
|
|
|
|
fi
|
|
|
|
endef
|
|
|
|
|
|
|
|
.PHONY: ghcid-library
|
|
|
|
## ghcid-library: build and watch library in ghcid
|
|
|
|
ghcid-library:
|
|
|
|
$(call run_ghcid,graphql-engine:lib:graphql-engine)
|
|
|
|
|
2022-08-19 14:22:28 +03:00
|
|
|
.PHONY: ghcid-tests
|
|
|
|
## ghcid-tests: build and watch main tests in ghcid
|
|
|
|
ghcid-tests:
|
|
|
|
$(call run_ghcid,graphql-engine:test:graphql-engine-tests)
|
|
|
|
|
2022-07-19 15:19:12 +03:00
|
|
|
.PHONY: ghcid-hspec
|
|
|
|
## ghcid-hspec: build and watch tests-hspec in ghcid
|
|
|
|
ghcid-hspec:
|
|
|
|
$(call run_ghcid,graphql-engine:tests-hspec)
|
|
|
|
|
2022-08-03 14:05:59 +03:00
|
|
|
.PHONY: ghcid-test-backends
|
|
|
|
## ghcid-test-backends: run all hspec tests in ghcid
|
|
|
|
ghcid-test-backends: remove-tix-file
|
|
|
|
$(call run_ghcid_hspec_tests,graphql-engine:tests-hspec)
|
|
|
|
|
|
|
|
.PHONY: ghcid-test-bigquery
|
|
|
|
## ghcid-test-bigquery: run tests for BigQuery backend in ghcid
|
|
|
|
# will require some setup detailed here: https://github.com/hasura/graphql-engine-mono/tree/main/server/tests-hspec#required-setup-for-bigquery-tests
|
|
|
|
ghcid-test-bigquery: start-postgres remove-tix-file
|
|
|
|
$(call run_ghcid_hspec_tests,graphql-engine:tests-hspec,BigQuery)
|
|
|
|
|
|
|
|
.PHONY: ghcid-test-sqlserver
|
|
|
|
## ghcid-test-sqlserver: run tests for SQL Server backend in ghcid
|
|
|
|
ghcid-test-sqlserver: start-postgres start-sqlserver remove-tix-file
|
|
|
|
$(call run_ghcid_hspec_tests,graphql-engine:tests-hspec,SQLServer)
|
|
|
|
|
|
|
|
.PHONY: ghcid-test-mysql
|
|
|
|
## ghcid-test-mysql: run tests for MySQL backend in ghcid
|
|
|
|
ghcid-test-mysql: start-postgres start-mysql remove-tix-file
|
|
|
|
$(call run_ghcid_hspec_tests,graphql-engine:tests-hspec,MySQL)
|
|
|
|
|
|
|
|
.PHONY: ghcid-test-citus
|
|
|
|
## ghcid-test-citus: run tests for Citus backend in ghcid
|
|
|
|
ghcid-test-citus: start-postgres start-citus remove-tix-file
|
|
|
|
$(call run_ghcid_hspec_tests,graphql-engine:tests-hspec,Citus)
|
|
|
|
|
2022-09-07 18:10:19 +03:00
|
|
|
.PHONY: ghcid-test-cockroach
|
|
|
|
## ghcid-test-cockroach: run tests for Cockroach backend in ghcid
|
|
|
|
ghcid-test-cockroach: start-postgres start-cockroach remove-tix-file
|
|
|
|
$(call run_ghcid_hspec_tests,graphql-engine:tests-hspec,Cockroach)
|
|
|
|
|
2022-08-25 15:08:07 +03:00
|
|
|
.PHONY: ghcid-test-data-connectors
|
|
|
|
## ghcid-test-data-connectors: run tests for DataConnectors in ghcid
|
|
|
|
ghcid-test-data-connectors: start-postgres start-dc-reference-agent remove-tix-file
|
|
|
|
$(call run_ghcid_hspec_tests,graphql-engine:tests-hspec,DataConnector)
|
|
|
|
|
2022-08-06 03:51:06 +03:00
|
|
|
.PHONY: ghcid-library-pro
|
|
|
|
## ghcid-library-pro: build and watch pro library in ghcid
|
|
|
|
ghcid-library-pro:
|
|
|
|
$(call run_ghcid,graphql-engine-pro:lib:graphql-engine-pro)
|
|
|
|
|
2022-08-19 14:22:28 +03:00
|
|
|
.PHONY: ghcid-test-unit
|
|
|
|
## ghcid-test-unit: build and run unit tests in ghcid
|
|
|
|
ghcid-test-unit: remove-tix-file
|
|
|
|
$(call run_ghcid_main_tests,graphql-engine:graphql-engine-tests,unit)
|