Skip to content

Commit 061fbb1

Browse files
Merge pull request softwarefactory-project#26 from TristanCacqueray/conduit-service
Use conduit server for testing
2 parents 6e044bf + f6eb45a commit 061fbb1

File tree

6 files changed

+45
-30
lines changed

6 files changed

+45
-30
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
ghc: ['8.10']
12+
ghc: ['8.10', '9.2']
1313
name: Haskell GHC ${{ matrix.ghc }}
1414
steps:
1515
- uses: actions/checkout@v2

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ Some tests requires a local matrix server, run integration service:
4343

4444
```ShellSession
4545
# In another terminal:
46-
$ nix develop -c dendrite-start
46+
$ nix develop -c conduit-start
4747
# Before running cabal test:
48-
$ export $(nix develop -c dendrite-setup)
48+
$ export $(nix develop -c conduit-setup)
4949
$ cabal test all
5050
```
5151

flake.lock

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
nixConfig.bash-prompt = "[nix]λ ";
77

88
inputs = {
9-
nixpkgs.url = "github:NixOS/nixpkgs";
9+
nixpkgs.url =
10+
"github:NixOS/nixpkgs/00d73d5385b63e868bd11282fb775f6fe4921fb5";
1011
flake-utils.url = "github:numtide/flake-utils";
1112
};
1213

1314
outputs = { self, nixpkgs, flake-utils }:
1415
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
1516
let
1617
config = { };
17-
compilerVersion = "8107";
18+
compilerVersion = "924";
1819
compiler = "ghc" + compilerVersion;
1920
overlays = [
2021
(final: prev: {
@@ -33,31 +34,44 @@
3334
})
3435
];
3536
pkgs = import nixpkgs { inherit config overlays system; };
36-
dendriteHome = "/tmp/dendrite-home";
37+
conduitHome = "/tmp/conduit-home";
3738

38-
# A script to start a local matrix server with dendrite
39-
dendriteStart = pkgs.writeScriptBin "dendrite-start" ''
39+
conduitConfig = pkgs.writeTextFile {
40+
name = "conduit.toml";
41+
text = ''
42+
[global]
43+
server_name = "localhost"
44+
database_path = "${conduitHome}"
45+
database_backend = "rocksdb"
46+
port = 6167
47+
max_request_size = 20_000_000
48+
allow_registration = true
49+
allow_federation = false
50+
trusted_servers = []
51+
#log = "info,state_res=warn,rocket=off,_=off,sled=off"
52+
address = "127.0.0.1"
53+
'';
54+
};
55+
56+
# A script to start a local matrix server with conduit
57+
conduitStart = pkgs.writeScriptBin "conduit-start" ''
4058
#!/bin/sh -e
41-
mkdir -p ${dendriteHome}
42-
cd ${dendriteHome}
43-
if ! test -f dendrite.yaml; then
44-
${pkgs.dendrite}/bin/generate-config > dendrite.yaml
45-
sed -e 's|/var/log/dendrite|${dendriteHome}/logs|' -i dendrite.yaml
46-
fi
47-
if ! test -f matrix_key.pem; then
48-
${pkgs.dendrite}/bin/generate-keys -private-key matrix_key.pem -tls-cert test.crt -tls-key test.key
49-
fi
50-
${pkgs.dendrite}/bin/dendrite-monolith-server
59+
mkdir -p ${conduitHome}
60+
exec env CONDUIT_CONFIG=${conduitConfig} ${pkgs.matrix-conduit}/bin/conduit
5161
'';
5262

5363
# A script to setup test environment
54-
dendriteSetup = pkgs.writeScriptBin "dendrite-setup" ''
64+
conduitSetup = pkgs.writeScriptBin "conduit-setup" ''
5565
#!/bin/sh -e
56-
cd ${dendriteHome}
57-
HOMESERVER_URL=http://localhost:8008
66+
HOMESERVER_URL=http://localhost:6167
67+
export PATH=$PATH:${pkgs.jq}/bin:${pkgs.curl}/bin
5868
create_token () {
59-
${pkgs.dendrite}/bin/create-account -username $1 -password $2 || true
60-
${pkgs.curl}/bin/curl -XPOST $HOMESERVER_URL/_matrix/client/r0/login -d '{"user": "'$1'", "password": "'$2'", "type": "m.login.password"}' | ${pkgs.jq}/bin/jq -r ".access_token"
69+
REGISTER_TOKEN=$(curl -XPOST $HOMESERVER_URL/_matrix/client/v3/register -d '{"auth":{"type": "m.login.dummy"}, "username": "'$1'", "password": "'$2'"}' | jq -r ".access_token")
70+
if [ "$REGISTER_TOKEN" != "null" ]; then
71+
echo $REGISTER_TOKEN
72+
else
73+
curl -XPOST $HOMESERVER_URL/_matrix/client/v3/login -d '{"type": "m.login.password", "identifier": {"type": "m.id.user", "user": "'$1'"}, "password": "'$2'"}' | jq -r ".access_token"
74+
fi
6175
}
6276
echo HOMESERVER_URL=$HOMESERVER_URL
6377
echo PRIMARY_TOKEN=$(create_token "test-user" "test-pass")
@@ -87,8 +101,8 @@
87101
pkgs.haskell-language-server
88102
pkgs.ghcid
89103
testScript
90-
dendriteStart
91-
dendriteSetup
104+
conduitStart
105+
conduitSetup
92106
];
93107

94108
withHoogle = false;

matrix-client/matrix-client.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ category: Network
2222
build-type: Simple
2323
extra-doc-files: CHANGELOG.md
2424
extra-source-files: test/data/*.json
25-
tested-with: GHC == 8.10.4
25+
tested-with: GHC == 8.10.7, GHC == 9.2.4
2626

2727
source-repository head
2828
type: git

matrix-client/src/Network/Matrix/Tutorial.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
-- > git clone https://github.com/matrix-org/dendrite
1111
-- > cd dendrite; ./build.sh; ./bin/generate-keys --private-key matrix_key.pem; cp dendrite-config.yaml dendrite.yaml
1212
-- > ./bin/dendrite-monolith-server --config dendrite.yaml
13-
-- > curl -XPOST http://localhost:8008/_matrix/client/r0/register -d'{"username": "tristanC", "password": "supersecret", "auth": {"type": "mlogin.dummy"}}
13+
-- > curl -XPOST http://localhost:8008/_matrix/client/r0/register -d'{"username": "tristanC", "password": "supersecret", "auth": {"type": "m.login.dummy"}}'
1414
--
1515
-- To avoid manipulating the token directly, put it in your environment:
1616
--

0 commit comments

Comments
 (0)