Skip to content

Commit 367ae9f

Browse files
committed
fcm-add-trac-env: add owner permission
Both `admin` and `owner` are set up to have `TRAC_ADMIN` permissions, but this allows us to distinguish between the admin team who set up hosting of the Trac environments and the owners of the software projects. Install Trac on Travis CI build.
1 parent bfb3895 commit 367ae9f

File tree

4 files changed

+31
-11
lines changed

4 files changed

+31
-11
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@ before_install:
1111
install:
1212
- sudo apt-get install -y build-essential gfortran
1313
- sudo apt-get install -y libxml-parser-perl libconfig-inifiles-perl
14+
- sudo apt-get install -y libdbi-perl libdbd-sqlite3-perl
1415
# For some reason XML::Parser needs to be installed this way
1516
- cpanm 'Config::IniFiles' 'XML::Parser'
1617
# Latest Subversion
1718
- sudo sh -c 'echo "deb http://opensource.wandisco.com/ubuntu `lsb_release -cs` svn19" >> /etc/apt/sources.list.d/subversion19.list'
1819
- sudo wget -q http://opensource.wandisco.com/wandisco-debian.gpg -O- | sudo apt-key add -
1920
- sudo apt-get update
20-
- sudo apt-get install -y subversion libsvn-perl
21+
- sudo apt-get install -y subversion libsvn-perl python-subversion
2122
- sudo apt-get install -y heirloom-mailx
23+
- sudo apt-get install -y python-pip
24+
- sudo pip install trac
2225

2326
script:
2427
- fcm test-battery -j 5

lib/FCM/Admin/System.pm

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ sub add_trac_environment {
140140
my @command = (q{trac-admin}, $project->get_trac_live_path(), @args);
141141
$RUN->($log, sub {!system(@command)});
142142
};
143+
my $TRAC_ADMIN_CONT = sub {
144+
my ($log, @args) = @_;
145+
my @command = (q{trac-admin}, $project->get_trac_live_path(), @args);
146+
$RUNNER->run_continue($log, sub {!system(@command)});
147+
};
143148
$TRAC_ADMIN->(
144149
"initialising Trac environment",
145150
q{initenv},
@@ -152,18 +157,22 @@ sub add_trac_environment {
152157
if ($group) {
153158
_chgrp_and_chmod($project->get_trac_live_path(), $group);
154159
}
160+
# Note: For some reason, the commands to remove example components,
161+
# versions, milestones, priorities fail using the "pip install trac" version
162+
# on Travis CI. It is safe to allow the logic to continue after a failure
163+
# here as they are really unimportant and can easily be configured later.
155164
for my $item (qw{component1 component2}) {
156-
$TRAC_ADMIN->(
165+
$TRAC_ADMIN_CONT->(
157166
"removing example component $item", q{component remove}, $item,
158167
);
159168
}
160169
for my $item (qw{1.0 2.0}) {
161-
$TRAC_ADMIN->(
170+
$TRAC_ADMIN_CONT->(
162171
"removing example version $item", q{version remove}, $item,
163172
);
164173
}
165174
for my $item (qw{milestone1 milestone2 milestone3 milestone4}) {
166-
$TRAC_ADMIN->(
175+
$TRAC_ADMIN_CONT->(
167176
"removing example milestone $item", q{milestone remove}, $item,
168177
);
169178
}
@@ -173,13 +182,16 @@ sub add_trac_environment {
173182
['blocker' => 'critical'],
174183
) {
175184
my ($old, $new) = @{$item};
176-
$TRAC_ADMIN->(
185+
$TRAC_ADMIN_CONT->(
177186
"changing priority $old to $new", qw{priority change}, $old, $new,
178187
);
179188
}
180189
$TRAC_ADMIN->(
181190
"adding admin permission", qw{permission add admin TRAC_ADMIN},
182191
);
192+
$TRAC_ADMIN->(
193+
"adding admin permission", qw{permission add owner TRAC_ADMIN},
194+
);
183195
my @admin_users = shellwords($CONFIG->get_trac_admin_users());
184196
for my $item (@admin_users) {
185197
$TRAC_ADMIN->(

t/fcm-add-trac-env/00-basic.t

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
if ! which trac-admin 1>/dev/null 2>/dev/null; then
2525
skip_all 'trac-admin not available'
2626
fi
27-
tests 20
27+
tests 28
2828
#-------------------------------------------------------------------------------
2929
set -e
3030
mkdir -p etc srv/{svn,trac}
3131
# Configuration
3232
export FCM_CONF_PATH="$PWD/etc"
3333
ADMIN_USERS='holly ivy'
34-
cat >etc/admin.cfg <<__CONF__
34+
cat >'etc/admin.cfg' <<__CONF__
3535
svn_live_dir=$PWD/srv/svn
3636
trac_admin_users=$ADMIN_USERS
3737
trac_live_dir=$PWD/srv/trac
@@ -49,12 +49,16 @@ for NAME in bus car lorry taxi; do
4949
# Trac environment directory exists
5050
run_pass "$TEST_KEY-d" test -d "$PWD/srv/trac/$NAME"
5151
# Admin users are set
52+
trac-admin "$PWD/srv/trac/$NAME" 'permission' 'export' "$TEST_KEY-d-perms"
53+
# For some reason, the "echo" for the next test is lost in the ether unless
54+
# we have an "echo" here.
55+
echo
5256
for ADMIN_USER in $ADMIN_USERS; do
53-
trac-admin "$PWD/srv/trac/$NAME" permission list "$ADMIN_USER" \
54-
>"$TEST_KEY.perm.out"
55-
file_grep "$TEST_KEY.perm.out" \
56-
"$ADMIN_USER *TRAC_ADMIN" "$TEST_KEY.perm.out"
57+
file_grep "$TEST_KEY-d-perms-$ADMIN_USER" \
58+
"$ADMIN_USER,admin" "$TEST_KEY-d-perms"
5759
done
60+
file_grep "$TEST_KEY-d-perms-owner" "owner,TRAC_ADMIN" "$TEST_KEY-d-perms"
61+
file_grep "$TEST_KEY-d-perms-admin" "admin,TRAC_ADMIN" "$TEST_KEY-d-perms"
5862
# Subversion repository paths in place
5963
if [[ -d "srv/svn/$NAME" ]]; then
6064
file_grep "$TEST_KEY-repository_dir" \

t/svn-hooks/03-post-commit-bg.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ perl -e 'map {print(rand())} 1..2097152' >'file3' # compress should be >10MB
228228
svn import --no-auth-cache -q -m"${TEST_KEY}" 'file3' "${REPOS_URL}/file3"
229229
REV="$(<'rev')"
230230
poll 10 grep -q '^RET_CODE=' "${REPOS_PATH}/log/post-commit.log"
231+
poll 10 test -e 'mail.out'
231232
date2datefmt "${REPOS_PATH}/log/post-commit.log" \
232233
| sed '/^trac-admin/d; s/^\(REV_FILE_SIZE=\).*\( #\)/\1???\2/' \
233234
>"${TEST_KEY}.log"

0 commit comments

Comments
 (0)