-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfresh_install
More file actions
executable file
·83 lines (77 loc) · 4.67 KB
/
Copy pathfresh_install
File metadata and controls
executable file
·83 lines (77 loc) · 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env bash
#
# Installs MediaWiki core (without running tests).
# Run ./shellto afterwards to open a shell with MediaWiki running.
# Runs ./prepare first if needed, then ./remove to ensure a fresh src/
# (the removal is skipped under DRY_RUN=1 — a dry run must not destroy state).
# WARNING: This will delete and recreate src/ (except under DRY_RUN=1).
#
# Usage: ./fresh_install
# ENVIRONMENT=0 ./fresh_install
# DRY_RUN=1 ./fresh_install # pass --dry-run to Quibble (no real install; src/ is left untouched)
# BRANCH=REL1_44 ./fresh_install # install and check out a branch (default: leave Quibble's detached HEAD)
# GERRIT_PATCHES="refs/changes/94/1146994/6" ./fresh_install # fetch and check out a Gerrit patch for core
#
# BRANCH: When set, passes --branch to Quibble (which branch to clone/install) and re-attaches
# HEAD to it afterwards, so src/ is on a named branch instead of Quibble's detached
# HEAD. Unset (default): leave the detached HEAD as Quibble produces it.
#
# GERRIT_PATCHES: When set, after the install, fetch the given Gerrit patch and check it out in
# core (src/). Takes a single change ref (e.g. "refs/changes/94/1146994/6"). Applied after
# install, so a patch that only changes code, tests, or in-tree config takes effect
# immediately; a patch that adds third-party composer/npm dependencies needs a re-install.
#
# See: https://www.mediawiki.org/wiki/Selenium/How-to/Run_tests_targeting_Quibble#Install_MediaWiki_Core
#
set -euo pipefail # exit on error, undefined vars, or pipe failures
. "$(dirname "$0")"/lib/setup # source shared setup (docker checks, shared vars, output capture, trace into the log)
. "$(dirname "$0")"/lib/docker_chmod # provides docker_chmod function
. "$(dirname "$0")"/lib/print_quibble_command # provides print_quibble_command function
. "$(dirname "$0")"/lib/checkout_branch # provides checkout_branch function (BRANCH support)
. "$(dirname "$0")"/lib/apply_gerrit_patch # provides apply_gerrit_patch function (GERRIT_PATCHES support)
# Run prepare if bare repos haven't been cloned yet
if [ ! -d ref/mediawiki/core.git ]; then
"$(dirname "$0")"/prepare
fi
# Remove src/ to ensure a fresh install. Skipped under DRY_RUN=1: Quibble gets --dry-run
# and installs nothing, so the removal would be the dry run's only real effect — it used to
# leave src/ empty, breaking whatever needed the existing install next (e.g. the ./save that
# follows the DRY_RUN entries in ./test_integration).
# ${DRY_RUN:-}: default to empty when DRY_RUN is unset, so the test is safe under set -u
if [ "${DRY_RUN:-}" != "1" ]; then
"$(dirname "$0")"/remove
fi
# Ensure working directories exist with proper permissions for the container user.
# Docker creates missing mount dirs as root; chmod may fail if they're already root-owned.
# Uses QUIBBLE_SRC from lib/setup (default "src", overridden for parallel workers).
mkdir -p cache log "$QUIBBLE_SRC"
docker_chmod cache log "$QUIBBLE_SRC" # make dirs world-writable for the container user
# Build the docker command in an array so we can both print and execute it.
# ${QUIBBLE_DOCKER_FLAGS[@]+"..."}: -i (default) or empty (background worker); ${arr[@]+"..."} guards the empty case for bash 3.2 (set by lib/setup)
# --rm: remove container on exit
# --entrypoint=quibble-with-supervisord: use Quibble's supervisord entrypoint
# "${QUIBBLE_VOLUMES[@]}": mount shared volumes (cache, log, ref, src)
# "${QUIBBLE_DRY_RUN[@]}": --dry-run when DRY_RUN=1 (set by lib/setup); empty otherwise
# "${QUIBBLE_BRANCH[@]}": --branch <branch> when BRANCH is set (set by lib/setup); empty otherwise
# --command true: install only, don't run tests ("true" exits immediately)
cmd=(
docker run ${QUIBBLE_DOCKER_FLAGS[@]+"${QUIBBLE_DOCKER_FLAGS[@]}"} --rm
--entrypoint=quibble-with-supervisord
"${QUIBBLE_VOLUMES[@]}"
"$QUIBBLE_IMAGE"
${QUIBBLE_DRY_RUN[@]+"${QUIBBLE_DRY_RUN[@]}"}
${QUIBBLE_BRANCH[@]+"${QUIBBLE_BRANCH[@]}"}
--command true
)
# Pretty-print the command (one option per line, framed by a '#' banner) so it stands
# out in busy logs. It lands wherever the output is captured (the script's log file,
# or a batch parent's per-step log).
print_quibble_command "${cmd[@]}"
"${cmd[@]}"
# When BRANCH is set, re-attach HEAD to that branch (Quibble leaves the cloned repos detached).
# No-op when BRANCH is unset or DRY_RUN=1.
checkout_branch
# When GERRIT_PATCHES is set, fetch and check out the patch in core (src/). The patch is a core
# change, so the target is /workspace/src (the core working copy) and project mediawiki/core.
# No-op when GERRIT_PATCHES is unset or DRY_RUN=1.
apply_gerrit_patch /workspace/src mediawiki/core