diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7fb567361..efce1a939 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,13 +44,6 @@ jobs: uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - - - name: Build - run: | - rm package-lock.json - npm install -g npm@latest - npm install - npm run test - name: API Test run: | diff --git a/src/backend/src/modules/selfhosted/DefaultUserService.js b/src/backend/src/modules/selfhosted/DefaultUserService.js index aa33188d5..a71da1695 100644 --- a/src/backend/src/modules/selfhosted/DefaultUserService.js +++ b/src/backend/src/modules/selfhosted/DefaultUserService.js @@ -101,6 +101,9 @@ class DefaultUserService extends BaseService { // console.log("************************************************"); // console.log('\n'); + // NB: this is needed for the CI to extract the password + console.log(`password for admin is: ${tmp_password}`); + const realConsole = globalThis.original_console_object ?? console; realConsole.log('\n'); svc_devConsole.notice({ diff --git a/tools/api-tester/ci/run.py b/tools/api-tester/ci/run.py index 2de4ac274..16fa74415 100755 --- a/tools/api-tester/ci/run.py +++ b/tools/api-tester/ci/run.py @@ -65,30 +65,40 @@ def init_server_config(): # create the admin user and print its password def get_admin_password(): - output_bytes, exit_code = cxc_toolkit.exec.run_command( - "npm start", - stream_output=False, - kill_on_output="password for admin", + # output_bytes, exit_code = cxc_toolkit.exec.run_command( + # "npm start", + # stream_output=False, + # kill_on_output="password for admin", + # ) + + backend_process = cxc_toolkit.exec.run_background( + "npm start", log_path="/tmp/backend.log" ) - # wait for the server to terminate + # NB: run_command + kill_on_output may wait indefinitely, use run_background + hard limit instead time.sleep(10) - # print the line that contains "password" - lines = output_bytes.decode("utf-8", errors="ignore").splitlines() - admin_password = None + backend_process.terminate() + + # read the log file + with open("/tmp/backend.log", "r") as f: + lines = f.readlines() for line in lines: - if "password" in line: + if "password for admin" in line: print(f"found password line: ---{line}---") - # Parse password from "password for admin is: bbb236b2" - if "password for admin is:" in line: - admin_password = line.split("password for admin is:")[1].strip() - print(f"Extracted admin password: {admin_password}") - break + admin_password = line.split("password for admin is:")[1].strip() + print(f"Extracted admin password: {admin_password}") + CONTEXT.ADMIN_PASSWORD = admin_password + return - print(f"password for admin: {admin_password}") + if not CONTEXT.ADMIN_PASSWORD: + print("Error: No admin password found") - CONTEXT.ADMIN_PASSWORD = admin_password + # print the log file + with open("/tmp/backend.log", "r") as f: + print(f.read()) + + exit(1) def update_server_config():