From 8d53fa124da141e3669671b7c66904b7294b7c01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Test=C3=A9?= Date: Thu, 31 Oct 2024 12:45:54 +0100 Subject: [PATCH] chore(ci): cache node build in workflows Building Node is failing often due to network error. Caching a successful build will allow more reliable workflows. --- .github/workflows/aws_tfhe_fast_tests.yml | 28 ++++++++++++++++++++- .github/workflows/aws_tfhe_wasm_tests.yml | 28 ++++++++++++++++++++- .github/workflows/benchmark_wasm_client.yml | 28 ++++++++++++++++++++- Makefile | 4 +++ 4 files changed, 85 insertions(+), 3 deletions(-) diff --git a/.github/workflows/aws_tfhe_fast_tests.yml b/.github/workflows/aws_tfhe_fast_tests.yml index 8fc00705a9..1a05675206 100644 --- a/.github/workflows/aws_tfhe_fast_tests.yml +++ b/.github/workflows/aws_tfhe_fast_tests.yml @@ -191,10 +191,36 @@ jobs: run: | make test_user_doc + - name: Get Node version + run: | + echo "NODE_VERSION=$(make node_version)" >> "${GITHUB_ENV}" + + - name: Node cache restoration + id: node-cache + uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a #v4.1.2 + with: + path: | + ~/.nvm + ~/.npm + key: node-${{ env.NODE_VERSION }} + + - name: Install Node + if: steps.node-cache.outputs.cache-hit != 'true' + run: | + make install_node + + - name: Node cache save + uses: actions/cache/save@6849a6489940f00c2f30c0fb92c6274307ccb58a #v4.1.2 + if: steps.node-cache.outputs.cache-hit != 'true' + with: + path: | + ~/.nvm + ~/.npm + key: node-${{ env.NODE_VERSION }} + - name: Run js on wasm API tests if: needs.should-run.outputs.wasm_test == 'true' run: | - make install_node make test_nodejs_wasm_api_ci - name: Gen Keys if required diff --git a/.github/workflows/aws_tfhe_wasm_tests.yml b/.github/workflows/aws_tfhe_wasm_tests.yml index a146e1cabe..b94696448e 100644 --- a/.github/workflows/aws_tfhe_wasm_tests.yml +++ b/.github/workflows/aws_tfhe_wasm_tests.yml @@ -55,9 +55,35 @@ jobs: with: toolchain: stable - - name: Install web resources + - name: Get Node version + run: | + echo "NODE_VERSION=$(make node_version)" >> "${GITHUB_ENV}" + + - name: Node cache restoration + id: node-cache + uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a #v4.1.2 + with: + path: | + ~/.nvm + ~/.npm + key: node-${{ env.NODE_VERSION }} + + - name: Install Node + if: steps.node-cache.outputs.cache-hit != 'true' run: | make install_node + + - name: Node cache save + uses: actions/cache/save@6849a6489940f00c2f30c0fb92c6274307ccb58a #v4.1.2 + if: steps.node-cache.outputs.cache-hit != 'true' + with: + path: | + ~/.nvm + ~/.npm + key: node-${{ env.NODE_VERSION }} + + - name: Install web resources + run: | make install_chrome_browser make install_chrome_web_driver diff --git a/.github/workflows/benchmark_wasm_client.yml b/.github/workflows/benchmark_wasm_client.yml index 1bd763ee3a..7aea88c890 100644 --- a/.github/workflows/benchmark_wasm_client.yml +++ b/.github/workflows/benchmark_wasm_client.yml @@ -102,9 +102,35 @@ jobs: with: toolchain: nightly - - name: Install web resources + - name: Get Node version + run: | + echo "NODE_VERSION=$(make node_version)" >> "${GITHUB_ENV}" + + - name: Node cache restoration + id: node-cache + uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a #v4.1.2 + with: + path: | + ~/.nvm + ~/.npm + key: node-${{ env.NODE_VERSION }} + + - name: Install Node + if: steps.node-cache.outputs.cache-hit != 'true' run: | make install_node + + - name: Node cache save + uses: actions/cache/save@6849a6489940f00c2f30c0fb92c6274307ccb58a #v4.1.2 + if: steps.node-cache.outputs.cache-hit != 'true' + with: + path: | + ~/.nvm + ~/.npm + key: node-${{ env.NODE_VERSION }} + + - name: Install web resources + run: | make install_${{ matrix.browser }}_browser make install_${{ matrix.browser }}_web_driver diff --git a/Makefile b/Makefile index 7bb4ab0869..c4fc33d751 100644 --- a/Makefile +++ b/Makefile @@ -122,6 +122,10 @@ install_node: $(SHELL) -i -c 'nvm install $(NODE_VERSION)' || \ ( echo "Unable to install node, unknown error." && exit 1 ) +.PHONY: node_version # Return Node version that will be installed +node_version: + @echo "$(NODE_VERSION)" + .PHONY: install_dieharder # Install dieharder for apt distributions or macOS install_dieharder: @dieharder -h > /dev/null 2>&1 || \