diff --git a/.github/workflows/repo_tests.yaml b/.github/workflows/repo_tests.yaml index dbea8d38..d3874746 100644 --- a/.github/workflows/repo_tests.yaml +++ b/.github/workflows/repo_tests.yaml @@ -75,6 +75,15 @@ jobs: fi description: (test for setup-node) + - repo: prawn-test-staging-rw/node-packages-failure-test + ref: main + post-init: | + if [ "${FAILED_NODE_PACKAGE_INSTALL}" != "true" ]; then + echo "::error::Node package install didn't fail" + exit 1 + fi + description: (test for continuing on node package install failure) + - repo: replayio/devtools ref: 730a9f0ddaafefc2a1a293d6924ce3910cd156ac description: (has trunk.yaml) diff --git a/action.yaml b/action.yaml index e5fe0ddd..1e74710c 100644 --- a/action.yaml +++ b/action.yaml @@ -223,6 +223,7 @@ runs: run: | if [ ! -e .trunk/trunk.yaml ]; then ${TRUNK_PATH:-trunk} init + echo "INITIALIZED_TRUNK=true" >>$GITHUB_ENV fi - name: Detect setup strategy diff --git a/setup-env/action.yaml b/setup-env/action.yaml index 92da70f6..2168de82 100644 --- a/setup-env/action.yaml +++ b/setup-env/action.yaml @@ -115,6 +115,27 @@ runs: hashFiles(env.HASH_GLOB) }} - name: Install ${{ env.PACKAGE_MANAGER }} packages + id: install_packages if: env.PACKAGE_MANAGER && (env.NODE_VERSION_FILE || env.RUN_INSTALL_NODE_PACKAGES) shell: bash run: ${{ env.INSTALL_CMD }} + continue-on-error: true + + - name: Check for package install + if: env.PACKAGE_MANAGER && (env.NODE_VERSION_FILE || env.RUN_INSTALL_NODE_PACKAGES) + shell: bash + run: | + if [ ${{ steps.install_packages.outcome }} == "success" ]; then + exit 0 + fi + echo "FAILED_NODE_PACKAGE_INSTALL=true" >>$GITHUB_ENV + + if [[ -z "${INITIALIZED_TRUNK}" ]]; then + echo "::error::Failed to install node packages." + echo "::error::Aborting because this repo has an existing trunk.yaml file." + exit 1 + fi + echo "::warning::Failed to install node packages." + echo "::warning::Disabling linters that depend on node packages." + ${TRUNK_PATH} check disable eslint + ${TRUNK_PATH} check disable stylelint