From 0a0b4b0853f342c2f860c53616e654d4cc18db9e Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Wed, 16 Aug 2023 23:30:05 -0400 Subject: [PATCH 01/14] Create pyflask-build-and-dist-tests.yml --- .../pyflask-build-and-dist-tests.yml | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 .github/workflows/pyflask-build-and-dist-tests.yml diff --git a/.github/workflows/pyflask-build-and-dist-tests.yml b/.github/workflows/pyflask-build-and-dist-tests.yml new file mode 100644 index 000000000..a6c205dc9 --- /dev/null +++ b/.github/workflows/pyflask-build-and-dist-tests.yml @@ -0,0 +1,95 @@ +name: PyFlask build and distributable tests +on: + schedule: + - cron: "0 16 * * *" # Daily at noon EST + pull_request: + +# Cancel previous workflows on the same pull request +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + CACHE_NUMBER: 1 # increase to reset cache manually + +jobs: + testing: + name: PyFlask build and distributable tests on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash -l {0} + + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + include: + - python-version: "3.9" + os: ubuntu-latest + label: environments/environment-Linux.yml + prefix: /usr/share/miniconda3/envs/nwb-guide + shorthand: unix + + - python-version: "3.10" + os: macos-latest + label: environments/environment-Mac.yml + prefix: /Users/runner/miniconda3/envs/nwb-guide + shorthand: unix + + - python-version: "3.9" + os: windows-latest + label: environments/environment-Windows.yml + prefix: C:\Miniconda3\envs\nwb-guide + shorthand: win + + steps: + - uses: actions/checkout@v3 + - run: git fetch --prune --unshallow --tags + + # see https://github.com/conda-incubator/setup-miniconda#caching-environments + - name: Setup Mambaforge + uses: conda-incubator/setup-miniconda@v2 + with: + miniforge-variant: Mambaforge + miniforge-version: latest + activate-environment: nwb-guide + use-mamba: true + + - name: Set cache date + id: get-date + run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT + shell: bash + + - name: Cache Mamba env + uses: actions/cache@v2 + with: + path: ${{ env.CONDA }}/envs + key: + conda-${{ runner.os }}-${{ runner.arch }}-${{steps.get-date.outputs.today }}-${{ hashFiles(matrix.label) }}-${{ env.CACHE_NUMBER }} + env: + CACHE_NUMBER: ${{ CACHE_NUMBER }} + id: cache + + - if: steps.cache.outputs.cache-hit != 'true' + name: Update environment + run: mamba env update -n env-electron-python -f ${{ matrix.label }} + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: "16" + + - name: Build PyFlask distribution + run: npm run build:flask:${{ matrix.shorthand }} + + - if: matrix.os == "windows-latest" + name: Run test on build executable + run: node tests/testPyinstallerExecutable.js ./build/nwb-guide/nwb-guide.exe + + - if: matrix.os != "windows-latest" + name: Run test on build executable + run: node tests/testPyinstallerExecutable.js ./build/nwb-guide/nwb-guide + + - name: Run test on distributed executable + run: node tests/testPyinstallerExecutable.js From fb98ceb4824a0f5a6bb4f8e1bedd43529b1faf4a Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Wed, 16 Aug 2023 23:31:34 -0400 Subject: [PATCH 02/14] try to trigger for testing --- .github/workflows/pyflask-build-and-dist-tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pyflask-build-and-dist-tests.yml b/.github/workflows/pyflask-build-and-dist-tests.yml index a6c205dc9..6a91131a5 100644 --- a/.github/workflows/pyflask-build-and-dist-tests.yml +++ b/.github/workflows/pyflask-build-and-dist-tests.yml @@ -3,6 +3,8 @@ on: schedule: - cron: "0 16 * * *" # Daily at noon EST pull_request: + push: + workflow_dispatch: # Cancel previous workflows on the same pull request concurrency: From fdcd06e70068bbe5981373681b31880e6fcb6207 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Wed, 16 Aug 2023 23:33:01 -0400 Subject: [PATCH 03/14] no dice --- .github/workflows/pyflask-build-and-dist-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pyflask-build-and-dist-tests.yml b/.github/workflows/pyflask-build-and-dist-tests.yml index 6a91131a5..1cfebac15 100644 --- a/.github/workflows/pyflask-build-and-dist-tests.yml +++ b/.github/workflows/pyflask-build-and-dist-tests.yml @@ -3,7 +3,6 @@ on: schedule: - cron: "0 16 * * *" # Daily at noon EST pull_request: - push: workflow_dispatch: # Cancel previous workflows on the same pull request From 310761fa074fc97c37f07a3d71075ea0cf30f1a8 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Thu, 17 Aug 2023 22:51:10 -0400 Subject: [PATCH 04/14] fix typo --- .github/workflows/pyflask-build-and-dist-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pyflask-build-and-dist-tests.yml b/.github/workflows/pyflask-build-and-dist-tests.yml index 1cfebac15..6c388307d 100644 --- a/.github/workflows/pyflask-build-and-dist-tests.yml +++ b/.github/workflows/pyflask-build-and-dist-tests.yml @@ -69,7 +69,7 @@ jobs: key: conda-${{ runner.os }}-${{ runner.arch }}-${{steps.get-date.outputs.today }}-${{ hashFiles(matrix.label) }}-${{ env.CACHE_NUMBER }} env: - CACHE_NUMBER: ${{ CACHE_NUMBER }} + CACHE_NUMBER: ${{ env.CACHE_NUMBER }} id: cache - if: steps.cache.outputs.cache-hit != 'true' From 5595bc0518ae86a6a24879b75c8b59a1d5948440 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Thu, 17 Aug 2023 22:53:01 -0400 Subject: [PATCH 05/14] single quotes --- .github/workflows/pyflask-build-and-dist-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pyflask-build-and-dist-tests.yml b/.github/workflows/pyflask-build-and-dist-tests.yml index 6c388307d..d1bee9a50 100644 --- a/.github/workflows/pyflask-build-and-dist-tests.yml +++ b/.github/workflows/pyflask-build-and-dist-tests.yml @@ -84,11 +84,11 @@ jobs: - name: Build PyFlask distribution run: npm run build:flask:${{ matrix.shorthand }} - - if: matrix.os == "windows-latest" + - if: matrix.os == 'windows-latest' name: Run test on build executable run: node tests/testPyinstallerExecutable.js ./build/nwb-guide/nwb-guide.exe - - if: matrix.os != "windows-latest" + - if: matrix.os != 'windows-latest' name: Run test on build executable run: node tests/testPyinstallerExecutable.js ./build/nwb-guide/nwb-guide From 0e69c2540ae8510f7587ec48433402a14f1edd61 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Thu, 17 Aug 2023 22:55:03 -0400 Subject: [PATCH 06/14] fix mamba env reference --- .github/workflows/pyflask-build-and-dist-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pyflask-build-and-dist-tests.yml b/.github/workflows/pyflask-build-and-dist-tests.yml index d1bee9a50..0c867a9b5 100644 --- a/.github/workflows/pyflask-build-and-dist-tests.yml +++ b/.github/workflows/pyflask-build-and-dist-tests.yml @@ -74,7 +74,7 @@ jobs: - if: steps.cache.outputs.cache-hit != 'true' name: Update environment - run: mamba env update -n env-electron-python -f ${{ matrix.label }} + run: mamba env update -n nwb-guide -f ${{ matrix.label }} - name: Setup Node uses: actions/setup-node@v3 From 2d3bd1fbd96cb8cf6eb4ba89eb7fc912cb19107d Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Thu, 17 Aug 2023 22:59:33 -0400 Subject: [PATCH 07/14] restore env path base --- .github/workflows/pyflask-build-and-dist-tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pyflask-build-and-dist-tests.yml b/.github/workflows/pyflask-build-and-dist-tests.yml index 0c867a9b5..4f7ece026 100644 --- a/.github/workflows/pyflask-build-and-dist-tests.yml +++ b/.github/workflows/pyflask-build-and-dist-tests.yml @@ -28,19 +28,19 @@ jobs: include: - python-version: "3.9" os: ubuntu-latest - label: environments/environment-Linux.yml + label: tools/anaconda-env/environment-Linux.yml prefix: /usr/share/miniconda3/envs/nwb-guide shorthand: unix - python-version: "3.10" os: macos-latest - label: environments/environment-Mac.yml + label: tools/anaconda-env/environment-Mac.yml prefix: /Users/runner/miniconda3/envs/nwb-guide shorthand: unix - python-version: "3.9" os: windows-latest - label: environments/environment-Windows.yml + label: tools/anaconda-env/environment-Windows.yml prefix: C:\Miniconda3\envs\nwb-guide shorthand: win @@ -74,7 +74,7 @@ jobs: - if: steps.cache.outputs.cache-hit != 'true' name: Update environment - run: mamba env update -n nwb-guide -f ${{ matrix.label }} + run: mamba env create -f ${{ matrix.label }} - name: Setup Node uses: actions/setup-node@v3 From 2b5afc6a39d223ed4b2e9ad6a0a82c21dcf60cd3 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Thu, 17 Aug 2023 23:09:15 -0400 Subject: [PATCH 08/14] try update on the file --- .github/workflows/pyflask-build-and-dist-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pyflask-build-and-dist-tests.yml b/.github/workflows/pyflask-build-and-dist-tests.yml index 4f7ece026..30762a676 100644 --- a/.github/workflows/pyflask-build-and-dist-tests.yml +++ b/.github/workflows/pyflask-build-and-dist-tests.yml @@ -74,7 +74,7 @@ jobs: - if: steps.cache.outputs.cache-hit != 'true' name: Update environment - run: mamba env create -f ${{ matrix.label }} + run: mamba env update -f ${{ matrix.label }} - name: Setup Node uses: actions/setup-node@v3 From 9522bc1a53edf00a9884d9c193efc4eec8e75b17 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Thu, 17 Aug 2023 23:22:44 -0400 Subject: [PATCH 09/14] add error throws --- tests/testPyinstallerExecutable.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/testPyinstallerExecutable.js b/tests/testPyinstallerExecutable.js index fd571429e..588ed871d 100644 --- a/tests/testPyinstallerExecutable.js +++ b/tests/testPyinstallerExecutable.js @@ -32,10 +32,12 @@ function handleProcess(proc, id = "process") { proc.on("error", (error) => { console.error(`[${id}] error: ${error.message}`); + throw new Error("The distributable pyflask failed to run!"); }); proc.on("close", (code) => { console.error(`[${id}] exit: ${code}`); + throw new Error("The distributable pyflask failed to run!"); }); } else console.error("child process failed to start on port" + port); } From 3377271dbfc5368831b585eb5de8ac0e2916f68b Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Thu, 17 Aug 2023 23:58:54 -0400 Subject: [PATCH 10/14] suppress build test parsing error --- .../workflows/pyflask-build-and-dist-tests.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pyflask-build-and-dist-tests.yml b/.github/workflows/pyflask-build-and-dist-tests.yml index 30762a676..dbc149371 100644 --- a/.github/workflows/pyflask-build-and-dist-tests.yml +++ b/.github/workflows/pyflask-build-and-dist-tests.yml @@ -84,13 +84,14 @@ jobs: - name: Build PyFlask distribution run: npm run build:flask:${{ matrix.shorthand }} - - if: matrix.os == 'windows-latest' - name: Run test on build executable - run: node tests/testPyinstallerExecutable.js ./build/nwb-guide/nwb-guide.exe - - - if: matrix.os != 'windows-latest' - name: Run test on build executable - run: node tests/testPyinstallerExecutable.js ./build/nwb-guide/nwb-guide + # encountering parsing issue for second arg + #- if: matrix.os == 'windows-latest' + # name: Run test on build executable + # run: node tests/testPyinstallerExecutable.js ./build/nwb-guide/nwb-guide.exe + + #- if: matrix.os != 'windows-latest' + # name: Run test on build executable + # run: node tests/testPyinstallerExecutable.js ./build/nwb-guide/nwb-guide - name: Run test on distributed executable run: node tests/testPyinstallerExecutable.js From 01d94cb6c89639d8cf9c89bffcee501cbbade436 Mon Sep 17 00:00:00 2001 From: Garrett Date: Fri, 18 Aug 2023 08:47:09 -0700 Subject: [PATCH 11/14] Close main process gracefully on success --- tests/testPyinstallerExecutable.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tests/testPyinstallerExecutable.js b/tests/testPyinstallerExecutable.js index 588ed871d..03a948858 100644 --- a/tests/testPyinstallerExecutable.js +++ b/tests/testPyinstallerExecutable.js @@ -12,8 +12,7 @@ console.log("Found file", fs.existsSync(script)); const proc2 = child_process.spawn(`${script}`, [port + 1]); handleProcess(proc2, "spawn"); -let now = Date.now(), - started; +let now = Date.now() function handleProcess(proc, id = "process") { if (proc != null) { @@ -23,11 +22,8 @@ function handleProcess(proc, id = "process") { }); proc.stdout.on("data", function (data) { - if (!started) { - started = Date.now(); - console.log(`Time to Start: ${(started - now).toFixed(2)}ms`); - } - console.error(`[${id}]: ${data}`); + console.log(`Time to Start: ${(Date.now() - now).toFixed(2)}ms`); + process.exit( ); }); proc.on("error", (error) => { From c3cbf453c1f9805bead60b380706e26596c59d78 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Aug 2023 15:47:25 +0000 Subject: [PATCH 12/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/testPyinstallerExecutable.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testPyinstallerExecutable.js b/tests/testPyinstallerExecutable.js index 03a948858..f391d9d87 100644 --- a/tests/testPyinstallerExecutable.js +++ b/tests/testPyinstallerExecutable.js @@ -12,7 +12,7 @@ console.log("Found file", fs.existsSync(script)); const proc2 = child_process.spawn(`${script}`, [port + 1]); handleProcess(proc2, "spawn"); -let now = Date.now() +let now = Date.now(); function handleProcess(proc, id = "process") { if (proc != null) { @@ -22,8 +22,8 @@ function handleProcess(proc, id = "process") { }); proc.stdout.on("data", function (data) { - console.log(`Time to Start: ${(Date.now() - now).toFixed(2)}ms`); - process.exit( ); + console.log(`Time to Start: ${(Date.now() - now).toFixed(2)}ms`); + process.exit(); }); proc.on("error", (error) => { From 6fe9a06bc396770785fa16f4743cab8abe8a4e4c Mon Sep 17 00:00:00 2001 From: Garrett Date: Fri, 18 Aug 2023 09:25:29 -0700 Subject: [PATCH 13/14] Try catching cumulative errors --- tests/testPyinstallerExecutable.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/tests/testPyinstallerExecutable.js b/tests/testPyinstallerExecutable.js index f391d9d87..602a5b785 100644 --- a/tests/testPyinstallerExecutable.js +++ b/tests/testPyinstallerExecutable.js @@ -14,26 +14,38 @@ handleProcess(proc2, "spawn"); let now = Date.now(); +let outputCollection = ''; + +const regex = /.+Error: .+/ + function handleProcess(proc, id = "process") { if (proc != null) { + // Listen for errors from Python process proc.stderr.on("data", function (data) { - console.error(`[${id}]: ${data}`); + const message = data.toString() + console.error(`[${id}] Error: ${data}`); + outputCollection+=message + if (regex.test(message)) throw new Error(outputCollection); }); proc.stdout.on("data", function (data) { - console.log(`Time to Start: ${(Date.now() - now).toFixed(2)}ms`); - process.exit(); + console.log(`Time to Start: ${(Date.now() - now).toFixed(2)}ms`); + process.exit( ); }); - proc.on("error", (error) => { - console.error(`[${id}] error: ${error.message}`); + const error = () => () => { throw new Error("The distributable pyflask failed to run!"); + } + + proc.on("error", (error) => { + console.error(`[${id}] Error: ${error.message}`); + error(); }); proc.on("close", (code) => { - console.error(`[${id}] exit: ${code}`); - throw new Error("The distributable pyflask failed to run!"); + console.error(`[${id}] Exit: ${code}`); + error(); }); } else console.error("child process failed to start on port" + port); } From bbe4517a1e244e9bc8714f2a14903408d0e229a1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Aug 2023 16:25:44 +0000 Subject: [PATCH 14/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/testPyinstallerExecutable.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/testPyinstallerExecutable.js b/tests/testPyinstallerExecutable.js index 602a5b785..3ee379952 100644 --- a/tests/testPyinstallerExecutable.js +++ b/tests/testPyinstallerExecutable.js @@ -14,29 +14,28 @@ handleProcess(proc2, "spawn"); let now = Date.now(); -let outputCollection = ''; +let outputCollection = ""; -const regex = /.+Error: .+/ +const regex = /.+Error: .+/; function handleProcess(proc, id = "process") { if (proc != null) { - // Listen for errors from Python process proc.stderr.on("data", function (data) { - const message = data.toString() + const message = data.toString(); console.error(`[${id}] Error: ${data}`); - outputCollection+=message + outputCollection += message; if (regex.test(message)) throw new Error(outputCollection); }); proc.stdout.on("data", function (data) { - console.log(`Time to Start: ${(Date.now() - now).toFixed(2)}ms`); - process.exit( ); + console.log(`Time to Start: ${(Date.now() - now).toFixed(2)}ms`); + process.exit(); }); - const error = () => () => { + const error = () => () => { throw new Error("The distributable pyflask failed to run!"); - } + }; proc.on("error", (error) => { console.error(`[${id}] Error: ${error.message}`);