Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ jobs:
run: python -m py_compile scripts/deploy-frontends.py scripts/you_deserve_to_interview_sql.py

- name: Shell syntax check
run: bash -n scripts/deploy-release.sh
run: bash -n scripts/ci-server-build-deploy.sh scripts/ci-server-build-deploy.test.sh scripts/deploy-release.sh

- name: Deployment dependency refresh contract
run: bash scripts/ci-server-build-deploy.test.sh

ci-summary:
name: CI Summary
Expand Down
25 changes: 18 additions & 7 deletions scripts/ci-server-build-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ copy_tree() {
cp -a "$source_dir"/. "$target_dir"/
}

install_frontend_dependencies() {
local frontend_dir="$1"

npm ci \
--prefer-offline \
--no-audit \
--fund=false \
--ignore-scripts \
--prefix "$frontend_dir"
}

main() {
require_cmd git
require_cmd mvn
Expand All @@ -64,16 +75,14 @@ main() {
log "build backend"
mvn -B -pl xiaou-application -am clean package -DskipTests

log "install admin frontend dependencies"
install_frontend_dependencies vue3-admin-front
log "build admin frontend"
if [[ ! -d vue3-admin-front/node_modules ]]; then
npm ci --prefer-offline --no-audit --fund=false --ignore-scripts --timeout=300000 --prefix vue3-admin-front
fi
npm run build --prefix vue3-admin-front

log "install user frontend dependencies"
install_frontend_dependencies vue3-user-front
log "build user frontend"
if [[ ! -d vue3-user-front/node_modules ]]; then
npm ci --prefer-offline --no-audit --fund=false --ignore-scripts --timeout=300000 --prefix vue3-user-front
fi
npm run build --prefix vue3-user-front

log "assemble release bundle"
Expand Down Expand Up @@ -105,4 +114,6 @@ EOF
"$bundle"
}

main "$@"
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
main "$@"
fi
42 changes: 42 additions & 0 deletions scripts/ci-server-build-deploy.test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
set -Eeuo pipefail

repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
source "$repo_root/scripts/ci-server-build-deploy.sh"

declare -a npm_calls=()

npm() {
npm_calls+=("$*")
}

workspace="$(mktemp -d)"
trap 'rm -rf "$workspace"' EXIT
mkdir -p \
"$workspace/vue3-admin-front/node_modules" \
"$workspace/vue3-user-front/node_modules"

cd "$workspace"
install_frontend_dependencies vue3-admin-front
install_frontend_dependencies vue3-user-front

if [[ "${#npm_calls[@]}" -ne 2 ]]; then
printf 'expected npm ci for both frontends, got %s calls\n' "${#npm_calls[@]}" >&2
exit 1
fi

for call in "${npm_calls[@]}"; do
if [[ "$call" != ci\ * ]]; then
printf 'expected npm ci, got: npm %s\n' "$call" >&2
exit 1
fi
done

for frontend_dir in vue3-admin-front vue3-user-front; do
if ! printf '%s\n' "${npm_calls[@]}" | grep -Fq -- "--prefix $frontend_dir"; then
printf 'missing npm ci call for %s\n' "$frontend_dir" >&2
exit 1
fi
done

printf 'deployment dependency refresh contract passed\n'
4 changes: 3 additions & 1 deletion scripts/code-nest-eval.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@ function Invoke-Release {

Invoke-Step "script syntax checks" {
Invoke-Native -Command $PythonCommand -Arguments @("-m", "py_compile", "scripts/deploy-frontends.py", "scripts/you_deserve_to_interview_sql.py")
Invoke-Native -Command (Resolve-BashCommand) -Arguments @("-n", "scripts/deploy-release.sh")
$bash = Resolve-BashCommand
Invoke-Native -Command $bash -Arguments @("-n", "scripts/ci-server-build-deploy.sh", "scripts/ci-server-build-deploy.test.sh", "scripts/deploy-release.sh")
Invoke-Native -Command $bash -Arguments @("scripts/ci-server-build-deploy.test.sh")
}
}

Expand Down
Loading