Skip to content

Commit 9e73f8b

Browse files
authored
Allow specification of a public_baseurl. (#25)
* Allow specification of a public_baseurl. * Prepare * Ensure timeout set for testing synapse up-ness * Remove use of custom baseurl other than by synapse itself.
1 parent 23154d1 commit 9e73f8b

File tree

5 files changed

+48
-11
lines changed

5 files changed

+48
-11
lines changed

.github/workflows/test.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@ jobs:
2222
uploadLogs: true
2323
httpPort: 8008
2424

25+
test-baseurl:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v3
29+
- uses: actions/setup-python@v3
30+
with:
31+
python-version: "3.x"
32+
- name: Run synapse
33+
uses: ./
34+
with:
35+
uploadLogs: true
36+
httpPort: 8008
37+
public_baseurl: http://10.0.2.2:8008/
38+
2539
test-modules:
2640
runs-on: ubuntu-latest
2741
steps:

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ inputs:
1717
description: 'Comma-separated list of modules to pip install.'
1818
required: false
1919
default: ''
20+
public_baseurl:
21+
description: 'Public base URL (defaults to http://localhost:${httpPort} if not defined)'
22+
required: false
2023
httpPort:
2124
description: 'HTTP port for C-S and S-S APIs'
2225
required: false

create.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,15 @@ async function run() {
3939

4040

4141
const port = core.getInput("httpPort");
42-
// Additional is our customizations to the base homeserver config
42+
var public_baseurl = core.getInput("public_baseurl");
43+
if (public_baseurl == "") {
44+
public_baseurl = `http://localhost:${port}`
45+
}
46+
4347

48+
// Additional is our customizations to the base homeserver config
4449
var additional = {
45-
public_baseurl: `http://localhost:${port}/`,
50+
public_baseurl: public_baseurl,
4651
enable_registration: true,
4752
enable_registration_without_verification: true,
4853
listeners: [
@@ -156,7 +161,7 @@ async function run() {
156161
core.info(`Waiting until C-S api is available`);
157162

158163

159-
const url = `http://localhost:${port}/_matrix/client/versions`;
164+
const url = `http://localhost:${ port }/_matrix/client/versions`;
160165
var retry = 0;
161166
while (true) {
162167
core.info("Checking endpoint...");
@@ -180,17 +185,22 @@ async function run() {
180185

181186
// Action directory is not in the root; provide an output with the synapse folder we're using
182187
core.saveState("synapse-dir", process.cwd());
183-
core.setOutput("synapse-url", `http://localhost:${port}/`);
188+
core.setOutput("synapse-url", `http://localhost:${ port }/`);
184189
} catch (error) {
185190
core.setFailed(error.message);
186191
}
187192
}
188193

194+
// Short timeout because we have a larger retry loop around it
195+
// And the server should respond within ~500ms or is generally unhappy anyway
189196
async function checkFor200(target) {
190197
return new Promise((resolve, reject) => {
191198

192-
const req = http.get(target, (res) => {
199+
const req = http.get(target, {timeout: 500}, (res) => {
193200
resolve(res.statusCode);
201+
}).on('timeout', (e) => {
202+
req.abort();
203+
resolve(0);
194204
}).on('error', (e) => {
195205
resolve(0);
196206
});;

dist/create/index.js

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

dist/create/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)