Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get CI working & misc cleanups #117

Merged
merged 6 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@ jobs:
matrix:
runner:
- os: macos-14 # macos sonoma on m1; 3 vcpu, 7 GB memory
base-nixpkgs-channel: nixpkgs-23.11-darwin
base-nixpkgs-channel: nixpkgs-24.05-darwin
- os: ubuntu-22.04 # linux x86_64; 4 vcpu, 16 GB memory
base-nixpkgs-channel: nixos-23.11
base-nixpkgs-channel: nixos-24.05
ghc:
- ghc-9-2
- ghc-9-4
- ghc-9-6
runs-on: ${{ matrix.runner.os }}
steps:
- name: Install Nix
uses: cachix/install-nix-action@v26
uses: cachix/install-nix-action@v30
with:
nix_path: nixpkgs=channel:${{ matrix.runner.base-nixpkgs-channel }}
extra_nix_config: |
Expand All @@ -37,7 +35,7 @@ jobs:
run: nix-env -f '<nixpkgs>' -iA cachix

- name: Check out repository code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Documentation comments use the [Haddock][haddock] format to ensure they are rend

### Testing compilation

Our default `shell.nix` sets up an environment around the most recent version of GHC that we support. CI also runs tests against a couple of older versions of GHC. To test using any of these versions locally:
Our default `shell.nix` sets up an environment around the most recent version of GHC that we support. CI used to support running tests against a different versions of GHC. To test using any of these versions locally:

```sh
cachix use nri # set up cache so the next step goes faster
Expand Down
7 changes: 7 additions & 0 deletions nri-postgresql/cleanup-postgres.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

PGDATA="$(realpath ../_build/postgres/data)"
export PGDATA
export PGUSER=$USER
pg_ctl stop || true
rm -rf "$PGDATA"
3 changes: 1 addition & 2 deletions nri-postgresql/setup-postgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ mkdir -p "../_build/postgres/data"
PGDATA="$(realpath ../_build/postgres/data)"
export PGDATA
export PGUSER=$USER
pg_ctl stop || true
rm -rf "$PGDATA"
source cleanup-postgres.sh
initdb --no-locale --encoding=UTF8
pg_ctl start -o '-k . -p 5432'

Expand Down
15 changes: 9 additions & 6 deletions nri-postgresql/src/Postgres/Connection.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,15 @@ connectionIO settings = do
doAnything <- Platform.doAnythingHandler
pool <-
map Pool
<| Data.Pool.createPool
(pgConnect database `Exception.catch` handleError (toConnectionString database))
pgDisconnect
stripes
maxIdleTime
size
<| Data.Pool.newPool
( Data.Pool.defaultPoolConfig
(pgConnect database `Exception.catch` handleError (toConnectionString database))
pgDisconnect
(Prelude.realToFrac maxIdleTime)
(stripes * size)
|> Data.Pool.setNumStripes (Just stripes)
)

Prelude.pure
( Connection
doAnything
Expand Down
28 changes: 14 additions & 14 deletions run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,21 @@ popd
## block us, if it happens to be enabled. This is an instance for testing only.
mkdir -p ./_build/redis/data
redis-server --daemonize yes \
--dir ./_build/redis/data \
--save '' \
--stop-writes-on-bgsave-error no
--dir ./_build/redis/data \
--save '' \
--stop-writes-on-bgsave-error no

## start zookeeper (for kafka)
## start zookeeper (for kafka)
mkdir -p /tmp/zookeeper /tmp/zookeeper-logs
ZOOPIDFILE=/tmp/zookeeper-logs/pid ZOO_LOG_DIR=/tmp/zookeeper-logs zkServer.sh stop zoo_sample.cfg
ZOOPIDFILE=/tmp/zookeeper-logs/pid ZOO_LOG_DIR=/tmp/zookeeper-logs zkServer.sh stop zoo_sample.cfg
rm -rf /tmp/zookeeper/* /tmp/zookeeper-logs/*
ZOOPIDFILE=/tmp/zookeeper-logs/pid ZOO_LOG_DIR=/tmp/zookeeper-logs zkServer.sh start zoo_sample.cfg

## wait for zookeeper
echo "waiting for zookeeper to start"
until nc -vz localhost 2181
do
sleep 1
done
until nc -vz localhost 2181; do
sleep 1
done
echo "zookeeper available"

## start kafka
Expand All @@ -36,16 +35,17 @@ kafka-server-start.sh -daemon "$server_properties_path" --override num.partition

## wait for kafka
echo "waiting for kafka to start"
until nc -vz localhost 9092
do
sleep 1
until nc -vz localhost 9092; do
sleep 1
done
echo "kafka available"


cabal build --offline all
cabal test --offline all

# cleanup
kafka-server-stop.sh
ZOOPIDFILE=/tmp/zookeeper-logs/pid ZOO_LOG_DIR=/tmp/zookeeper-logs zkServer.sh stop zoo_sample.cfg
ZOOPIDFILE=/tmp/zookeeper-logs/pid ZOO_LOG_DIR=/tmp/zookeeper-logs zkServer.sh stop zoo_sample.cfg
pushd nri-postgresql
source cleanup-postgres.sh
popd
Loading