Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEST-0009 Fix dependency installation was silent when failing #353

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions .github/actions/frontend-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,40 @@ runs:
cache-dependency-path: "${{ inputs.working_directory }}/yarn.lock"

- name: Install dependencies
id: dependency-install
shell: bash
working-directory: ${{ inputs.working_directory }}
run: |
echo "::group::Install dependencies"
[[ "${{ inputs.package_manager }}" == "npm" ]] && npm ci || true
[[ "${{ inputs.package_manager }}" == "yarn" ]] && yarn install --immutable --immutable-cache --check-cache || true
set +e
if [[ "${{ inputs.package_manager }}" == "npm" ]]; then
npm ci 1>dependency.out 2>&1
exit_code=$?
elif [[ "${{ inputs.package_manager }}" == "yarn" ]]; then
yarn install --immutable --immutable-cache --check-cache 1>dependency.out 2>&1
exit_code=$?
else
echo "::error::Invalid package manager: ${{ inputs.package_manager }}"
exit_code=1
fi
echo "Dependency installation exit code: $exit_code"
set -e

echo -e "\nDependency installation:\n"
cat dependency.out

if [[ $exit_code -ne 0 ]]
then
echo "::error::Dependency installation failed with errors."
echo "## ❌ Dependency installation failed with errors:" > dependency.md
cat dependency.out >> dependency.md
exit 1
fi
echo "::endgroup::"

- name: Build
id: node-build
if: steps.dependency-install.outcome == 'success'
shell: bash
working-directory: ${{ inputs.working_directory }}
run: |
Expand Down Expand Up @@ -86,7 +110,7 @@ runs:
echo "::endgroup::"

- name: Lint
if: always()
if: steps.dependency-install.outcome == 'success'
id: node-lint
shell: bash
working-directory: ${{ inputs.working_directory }}
Expand Down Expand Up @@ -151,8 +175,9 @@ runs:
working-directory: ${{ inputs.working_directory }}
run: |
echo "# ${{ env.WORKFLOW_SHORT_NAME }}" > combined.md
cat build.md >> combined.md
cat lint.md >> combined.md
cat dependency.md >> combined.md
[ -f build.md ] && cat build.md >> combined.md
[ -f lint.md ] && cat lint.md >> combined.md
echo "result<<EOF"$'\n'"$(cat combined.md)"$'\n'EOF >> $GITHUB_OUTPUT

- name: "Create or Update PR Comment"
Expand Down