@@ -10,33 +10,63 @@ async function run() {
10
10
try {
11
11
12
12
core . info ( `Installing synapse...` ) ;
13
+ let installer = core . getInput ( "installer" ) ;
14
+ if ( installer == "" )
15
+ installer = "pip"
16
+
13
17
14
- // Lots of stuff here, from the setting up synapse page.
15
- await exec . exec ( "mkdir" , [ "-p" , "synapse" ] ) ;
16
- process . chdir ( "synapse" ) ;
17
- await exec . exec ( "python" , [ "-m" , "venv" , "env" ] ) ;
18
- await exec . exec ( "env/bin/pip" , [ "install" , "-q" , "--upgrade" , "pip" ] ) ;
19
- await exec . exec ( "env/bin/pip" , [ "install" , "-q" , "--upgrade" , "setuptools" ] ) ;
20
- await exec . exec ( "env/bin/pip" , [ "install" , "-q" , "matrix-synapse" ] ) ;
18
+ if ( installer == "poetry" ) {
19
+ // poetry requires a git checkout first
20
+ await exec . exec ( "git" , [ "clone" , "https://github.com/matrix-org/synapse" ] ) ;
21
+ process . chdir ( "synapse" ) ;
22
+ await exec . exec ( "python" , [ "-m" , "pip" , "install" , "pipx" ] ) ;
23
+ await exec . exec ( "python" , [ "-m" , "pipx" , "ensurepath" ] ) ;
24
+ await exec . exec ( "pipx" , [ "install" , "poetry" ] ) ;
25
+ await exec . exec ( "poetry" , [ "install" , "--extras" , "all" ] ) ;
26
+ }
27
+ else {
28
+ // installing from pypi does not need the checkout.
29
+ // Lots of stuff here, from the setting up synapse page.
30
+ await exec . exec ( "mkdir" , [ "-p" , "synapse" ] ) ;
31
+ process . chdir ( "synapse" ) ;
32
+ await exec . exec ( "python" , [ "-m" , "venv" , "env" ] ) ;
33
+ await exec . exec ( "env/bin/pip" , [ "install" , "-q" , "--upgrade" , "pip" ] ) ;
34
+ await exec . exec ( "env/bin/pip" , [ "install" , "-q" , "--upgrade" , "setuptools" ] ) ;
35
+ await exec . exec ( "env/bin/pip" , [ "install" , "-q" , "matrix-synapse" ] ) ;
36
+ }
21
37
const customModules = core . getInput ( "customModules" )
22
38
if ( customModules . length > 0 ) {
23
39
const toLoad = customModules . split ( ',' ) ;
24
40
for ( let module of toLoad ) {
25
- await exec . exec ( "env/bin/pip" , [ "install" , "-q" , module ] ) ;
41
+ if ( installer == "poetry" ) {
42
+ await exec . exec ( "poetry" , [ "install" , module ] ) ;
43
+ } else {
44
+ await exec . exec ( "env/bin/pip" , [ "install" , "-q" , module ] ) ;
45
+ }
26
46
}
27
- }
47
+ }
28
48
// homeserver.yaml is the default server config from synapse
29
49
30
50
core . info ( "Generating config..." ) ;
51
+ if ( installer == "poetry" ) {
52
+ await exec . exec ( "poetry" , [
53
+ "run" , "python" ,
54
+ "-m" , "synapse.app.homeserver" ,
55
+ "--server-name" , "localhost" ,
56
+ "--config-path" , "homeserver.yaml" ,
57
+ "--generate-config" ,
58
+ "--report-stats=no"
59
+ ] ) ;
31
60
32
- await exec . exec ( "env/bin/python3" , [
33
- "-m" , "synapse.app.homeserver" ,
34
- "--server-name" , "localhost" ,
35
- "--config-path" , "homeserver.yaml" ,
36
- "--generate-config" ,
37
- "--report-stats=no"
38
- ] ) ;
39
-
61
+ } else {
62
+ await exec . exec ( "env/bin/python3" , [
63
+ "-m" , "synapse.app.homeserver" ,
64
+ "--server-name" , "localhost" ,
65
+ "--config-path" , "homeserver.yaml" ,
66
+ "--generate-config" ,
67
+ "--report-stats=no"
68
+ ] ) ;
69
+ }
40
70
41
71
const port = core . getInput ( "httpPort" ) ;
42
72
var public_baseurl = core . getInput ( "public_baseurl" ) ;
@@ -150,20 +180,29 @@ async function run() {
150
180
detached : true ,
151
181
stdio : [ 'ignore' , out , err ]
152
182
}
153
- var child = spawn ( "env/bin/python3" , [
154
- "-m" , "synapse.app.homeserver" ,
155
- "--config-path" , "homeserver.yaml" ,
156
- "--config-path" , "additional.yaml" ,
157
- "--config-path" , "custom.yaml"
158
- ] , options ) ;
159
-
183
+ if ( installer == "poetry" ) {
184
+ var child = spawn ( "poetry" , [
185
+ "run" , "python" ,
186
+ "-m" , "synapse.app.homeserver" ,
187
+ "--config-path" , "homeserver.yaml" ,
188
+ "--config-path" , "additional.yaml" ,
189
+ "--config-path" , "custom.yaml"
190
+ ] , options ) ;
191
+ } else {
192
+ var child = spawn ( "env/bin/python3" , [
193
+ "-m" , "synapse.app.homeserver" ,
194
+ "--config-path" , "homeserver.yaml" ,
195
+ "--config-path" , "additional.yaml" ,
196
+ "--config-path" , "custom.yaml"
197
+ ] , options ) ;
198
+ }
160
199
core . saveState ( "synapse-pid" , child . pid ) ;
161
200
core . info ( `Waiting until C-S api is available` ) ;
162
201
163
202
164
203
const url = `http://localhost:${ port } /_matrix/client/versions` ;
165
204
var retry = 0 ;
166
- while ( true ) {
205
+ while ( retry < 20 ) {
167
206
core . info ( "Checking endpoint..." ) ;
168
207
const response = await checkFor200 ( url ) ;
169
208
core . info ( `.. got ${ response } ` ) ;
@@ -194,16 +233,16 @@ async function run() {
194
233
// Short timeout because we have a larger retry loop around it
195
234
// And the server should respond within ~500ms or is generally unhappy anyway
196
235
async function checkFor200 ( target ) {
197
- return new Promise ( ( resolve , reject ) => {
236
+ return new Promise ( ( resolve ) => {
198
237
199
238
const req = http . get ( target , { timeout : 500 } , ( res ) => {
200
239
resolve ( res . statusCode ) ;
201
- } ) . on ( 'timeout' , ( e ) => {
240
+ } ) . on ( 'timeout' , ( ) => {
202
241
req . abort ( ) ;
203
242
resolve ( 0 ) ;
204
- } ) . on ( 'error' , ( e ) => {
243
+ } ) . on ( 'error' , ( ) => {
205
244
resolve ( 0 ) ;
206
- } ) ; ;
245
+ } ) ;
207
246
req . end ( ) ;
208
247
} ) ;
209
248
}
0 commit comments