Skip to content

Commit 6720aef

Browse files
jkachmarhasura-bot
jkachmar
authored andcommitted
server: Clean up Cabal project files
PR-URL: hasura/graphql-engine-mono#4105 GitOrigin-RevId: 423eecf04061ca8d5ee036a84ee6792036a149e4
1 parent 250bf6a commit 6720aef

23 files changed

+62
-45
lines changed

.circleci/server-upgrade-downgrade/run-dev.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ SERVER_DIR="$ROOT/../../server"
1414

1515
cd $SERVER_DIR
1616
set -x
17-
cabal new-build --project-file=cabal.project.dev-sh exe:graphql-engine
17+
cabal new-build \
18+
--project-file=cabal/dev-sh.project \
19+
exe:graphql-engine
1820
export SERVER_BINARY="$(cabal new-exec --verbose=0 which graphql-engine)"
1921
echo "server binary: $SERVER_BINARY"
2022
cd -

cabal.project

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
-- Global project configuration.
22
--
3-
-- This file can be overridden with cabal.project.local (see e.g. cabal.project.dev)
3+
-- This file can be overridden with cabal.project.local (see e.g. cabal/dev.project)
4+
--
5+
-- If you need to switch between several local configurations you can also create a
6+
-- symbolic link to this file in the project root directory; e.g.:
7+
-- $ ln -s cabal.project myconfig.project
8+
-- $ ln -s cabal.project.freeze myconfig.project.freeze
49
--
5-
-- If you need to switch between several local configurations you can also
6-
-- create a symlink to this file with a different name, e.g.:
7-
-- $ ln -s cabal.project cabal.project.myconfig
8-
-- $ ln -s cabal.project.freeze cabal.project.myconfig.freeze
910
-- ...and then create a new set of overrides in:
10-
-- cabal.project.myconfig.local
11+
-- myconfig.project.local
12+
--
1113
-- ...and then invoke cabal with
12-
-- $ cabal new-build --project-file=cabal.project.myconfig
14+
-- $ cabal new-build --project-file=myconfig.project
1315
--
1416
-- See: https://www.haskell.org/cabal/users-guide/nix-local-build.html#configuring-builds-with-cabal-project
1517

cabal.project.ci

-1
This file was deleted.

cabal.project.ci-haddock

-1
This file was deleted.

cabal.project.ci-haddock.freeze

-1
This file was deleted.

cabal.project.ci.freeze

-1
This file was deleted.

cabal.project.dev-sh

-1
This file was deleted.

cabal.project.dev-sh.freeze

-1
This file was deleted.

cabal/ci-haddock.project

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../cabal.project

cabal/ci-haddock.project.freeze

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../cabal.project.freeze

cabal.project.ci-haddock.local cabal/ci-haddock.project.local

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Instead we make this a parallel job, but use a configuration with optimizations
55
-- off so the haskell build will be relatively fast.
66

7-
-- NOTE!: we want to make sure this matches cabal.project.ci.local, so we can re-use the
7+
-- NOTE!: we want to make sure this matches `ci.project.local`, so we can re-use the
88
-- cached library dependencies and don't accidentally rebuild:
99
package *
1010
ghc-options:

cabal/ci.project

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../cabal.project

cabal/ci.project.freeze

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../cabal.project.freeze
File renamed without changes.

cabal/dev-sh.project

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../cabal.project

cabal/dev-sh.project.freeze

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../cabal.project.freeze

cabal.project.dev-sh.local cabal/dev-sh.project.local

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
-- This is the local cabal configuration file used by the 'scripts/dev.sh'
2-
-- development script, which uses `... --project-file=cabal.project.dev-sh`
1+
-- This is the local cabal configuration file used by the `scripts/dev.sh`
2+
-- development script, which uses `... --project-file=cabal/dev-sh.project`
33
-- which in turn consults this file.
44
--
55
-- You can temporarily override values here rather than modifying 'dev.sh'

cabal.project.dev cabal/dev.project

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
-- A project configuration for general-purpose development: this builds documentation for
22
-- dependencies and disables optimizations for graphql-engine to improve compilation times.
33
--
4-
-- To enable this, you can do:
5-
-- $ ln -s cabal.project.dev cabal.project.local
6-
-- Or, if you want to customize the configuration:
7-
-- $ cp cabal.project.dev cabal.project.local
4+
-- From the project root, this configuration can be linked directly:
5+
-- $ ln -s cabal/dev.project cabal.project.local
6+
--
7+
-- ...or, it can be copied if you would like to customize any settings:
8+
-- $ cp cabal/cabal.project.dev cabal.project.local
89

910
with-compiler: ghc-8.10.7
1011

scripts/dev.sh

+25-15
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ shopt -s globstar
1010
# document describing how to do various dev tasks (or worse yet, not writing
1111
# one), make it runnable
1212
#
13-
# This makes use of 'cabal.project.dev-sh*' files when building. See
14-
# 'cabal.project.dev-sh.local'.
13+
# This makes use of 'cabal/dev-sh.project' files when building.
14+
# See 'cabal/dev-sh.project.local' for details.
1515
#
1616
# The configuration for the containers of each backend is stored in
1717
# separate files, see files in 'scripts/containers'
@@ -279,8 +279,10 @@ if [ "$MODE" = "graphql-engine" ]; then
279279
echo
280280
# Generate coverage, which can be useful for debugging or understanding
281281
if command -v hpc >/dev/null && command -v jq >/dev/null ; then
282-
# Get the appropriate mix dir (the newest one). This way this hopefully
283-
# works when cabal.project.dev-sh.local is edited to turn on optimizations.
282+
# Get the appropriate mix dir (the newest one); this way this hopefully
283+
# works when 'cabal/dev-sh.project.local' is edited to turn on
284+
# optimizations.
285+
#
284286
# See also: https://hackage.haskell.org/package/cabal-plan
285287
distdir=$(cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[] | select(."id" == "graphql-engine-1.0.0-inplace")? | ."dist-dir"')
286288
hpcdir="$distdir/hpc/dyn/mix/graphql-engine-1.0.0"
@@ -321,17 +323,17 @@ if [ "$MODE" = "graphql-engine" ]; then
321323
echo_pretty " $ $0 postgres"
322324
echo_pretty ""
323325

324-
RUN_INVOCATION=(cabal new-run --project-file=cabal.project.dev-sh --RTS --
326+
RUN_INVOCATION=(cabal new-run --project-file=cabal/dev-sh.project --RTS --
325327
exe:graphql-engine +RTS -N -T -s -RTS serve
326328
--enable-console --console-assets-dir "$PROJECT_ROOT/console/static/dist"
327329
)
328330

329331
echo_pretty 'About to do:'
330-
echo_pretty ' $ cabal new-build --project-file=cabal.project.dev-sh exe:graphql-engine'
332+
echo_pretty ' $ cabal new-build --project-file=cabal/dev-sh.project exe:graphql-engine'
331333
echo_pretty " $ ${RUN_INVOCATION[*]}"
332334
echo_pretty ''
333335

334-
cabal new-build --project-file=cabal.project.dev-sh exe:graphql-engine
336+
cabal new-build --project-file=cabal/dev-sh.project exe:graphql-engine
335337

336338
# We assume a PG is *already running*, and therefore bypass the
337339
# cleanup mechanism previously set.
@@ -477,8 +479,11 @@ elif [ "$MODE" = "test" ]; then
477479
# Formerly this was a `cabal build` but mixing cabal build and cabal run
478480
# seems to conflict now, causing re-linking, haddock runs, etc. Instead do a
479481
# `graphql-engine version` to trigger build
480-
cabal new-run --project-file=cabal.project.dev-sh -- exe:graphql-engine \
481-
--metadata-database-url="$PG_DB_URL" version
482+
cabal run \
483+
--project-file=cabal/dev-sh.project \
484+
-- exe:graphql-engine \
485+
--metadata-database-url="$PG_DB_URL" \
486+
version
482487
start_dbs
483488
fi
484489

@@ -492,7 +497,10 @@ elif [ "$MODE" = "test" ]; then
492497
echo "${UNIT_TEST_ARGS[@]}"
493498
HASURA_GRAPHQL_DATABASE_URL="$PG_DB_URL" \
494499
HASURA_MSSQL_CONN_STR="$MSSQL_CONN_STR" \
495-
cabal new-run --project-file=cabal.project.dev-sh test:graphql-engine-tests -- "${UNIT_TEST_ARGS[@]}"
500+
cabal run \
501+
--project-file=cabal/dev-sh.project \
502+
test:graphql-engine-tests \
503+
-- "${UNIT_TEST_ARGS[@]}"
496504
fi
497505

498506
if [ "$RUN_HLINT" = true ]; then
@@ -517,11 +525,13 @@ elif [ "$MODE" = "test" ]; then
517525

518526
# Using --metadata-database-url flag to test multiple backends
519527
# HASURA_GRAPHQL_PG_SOURCE_URL_* For a couple multi-source pytests:
520-
cabal new-run --project-file=cabal.project.dev-sh -- exe:graphql-engine \
521-
--metadata-database-url="$PG_DB_URL" serve \
522-
--stringify-numeric-types \
523-
--enable-console \
524-
--console-assets-dir ../console/static/dist \
528+
cabal new-run \
529+
--project-file=cabal/dev-sh.project \
530+
-- exe:graphql-engine \
531+
--metadata-database-url="$PG_DB_URL" serve \
532+
--stringify-numeric-types \
533+
--enable-console \
534+
--console-assets-dir ../console/static/dist \
525535
&> "$GRAPHQL_ENGINE_TEST_LOG" & GRAPHQL_ENGINE_PID=$!
526536

527537
echo -n "Waiting for graphql-engine"

server/.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ Pipfile.lock
2020
cabal.sandbox.config
2121
cabal.config
2222
# Configurable for local dev/experimentation:
23-
cabal.project.local*
23+
cabal.project.local
24+
cabal/*.local
2425
*.prof*
2526
*.aux
2627
*.hp

server/COMPILING-ON-M1.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
(cd tests-py/remote_schemas/nodejs && npm ci)
5252
```
5353

54-
5. Add the C dependencies in the `cabal.project.dev-sh.local` and `cabal.project.local` files (according to where the dependencies were installed by homebrew):
54+
5. Add the C dependencies in the `cabal/dev-sh.project.local` and `cabal.project.local` files (according to where the dependencies were installed by homebrew):
5555

5656
```sh
5757
package mysql
@@ -87,10 +87,10 @@
8787
/opt/homebrew/opt/openssl/lib
8888
```
8989

90-
Note: If you don't have special requirements of a `cabal.project.local` you can just add a symbolic link to `cabal.project.dev-sh.local`:
90+
Note: If you have not added any local project overrides in `cabal.project.local` you can just add a symbolic link to `cabal/dev-sh.project.local`:
9191

9292
```sh
93-
ln -s cabal.project.dev-sh.local cabal.project.local
93+
ln -s cabal/dev-sh.project.local cabal.project.local
9494
```
9595

9696

server/CONTRIBUTING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ After making your changes
4545

4646
...and the server:
4747

48-
$ ln -s cabal.project.dev cabal.project.local
48+
$ ln -s cabal/dev.project cabal.project.local
4949
$ cabal new-update
5050
$ cabal new-build graphql-engine
5151

52-
To set up the project configuration to coincide with the testing scripts below, thus avoiding recompilation when testing locally, rather use `cabal.project.dev-sh.local` instead of `cabal.project.dev`:
52+
To set up the project configuration to coincide with the testing scripts below, thus avoiding recompilation when testing locally, rather use `cabal/dev-sh.project.local` instead of `cabal/dev.project`:
5353

54-
$ ln -s cabal.project.dev-sh.local cabal.project.local
54+
$ ln -s cabal/dev-sh.project.local cabal.project.local
5555

5656
### IDE Support
5757

server/graphql-engine.cabal

+3-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ flag profiling
3838

3939
-- A single flag to enable all optimization-related settings at once, for all
4040
-- hasura code.
41-
-- We share this flag name across our .cabal projects so we can switch it on or
42-
-- off for all of them at the top level of our cabal.project(.*) files
41+
--
42+
-- We share this flag name across our Haskell projects so we can switch it on or
43+
-- off for all of them at in our Cabal project files.
4344
flag optimize-hasura
4445
description: Compile hasura code with appropriate optimizations
4546
default: True

0 commit comments

Comments
 (0)