Skip to content

Commit ab267ec

Browse files
Michael Vasseurvmcj
authored andcommitted
Put lib/vendor close to the webapp
This simplifies a couple of things. The Makefile targets are now moved to the webapp folder which also make the process easier to read IMO. The option to set the libvendor dir with configure has now also been removed as it lead to issues and we can't think of good usecases for them. Also moved the phpstan files to the webapp folder as we only test code from within that folder which simplifies the config. Also removed some unrelated unused MySQL debugging and refactored the code for the composer test after fixing the tests.
1 parent b404383 commit ab267ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+139
-181
lines changed

.github/jobs/baseinstall.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export PHPVERSION
1212

1313
section_start "Run composer"
1414
export APP_ENV="dev"
15+
cd webapp
1516
composer install --no-scripts |tee "$ARTIFACTS"/composer_out.txt
17+
cd ..
1618
section_end
1719

1820
section_start "Set simple admin password"
@@ -58,9 +60,6 @@ section_end
5860

5961
section_start "Install DOMjudge database"
6062
/opt/domjudge/domserver/bin/dj_setup_database -uroot -proot bare-install
61-
#>> "$ARTIFACTS"/mysql.txt
62-
# We don't have -o pipefail so the `tee` eats away the potential error.
63-
#cat "$ARTIFACTS"/mysql.txt
6463
section_end
6564

6665
section_start "Show PHP config"

.github/jobs/composer_setup.sh

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,7 @@
22

33
set -eux
44

5-
# Store artifacts/logs
6-
export ARTIFACTS="/tmp/artifacts"
7-
mkdir -p "$ARTIFACTS"
8-
9-
# Functions to annotate the Github actions logs
10-
trace_on () {
11-
set -x
12-
}
13-
14-
trace_off () {
15-
{
16-
set +x
17-
} 2>/dev/null
18-
}
19-
20-
section_start_internal () {
21-
echo "::group::$1"
22-
trace_on
23-
}
24-
25-
section_end_internal () {
26-
echo "::endgroup::"
27-
trace_on
28-
}
29-
30-
section_start () {
31-
if [ "$#" -ne 1 ]; then
32-
echo "Only 1 argument is needed for GHA, 2 was needed for GitLab."
33-
exit 1
34-
fi
35-
trace_off
36-
section_start_internal "$1"
37-
}
38-
39-
section_end () {
40-
trace_off
41-
section_end_internal
42-
}
5+
. .github/jobs/ci_settings.sh
436

447
section_start "Configure PHP"
458
PHPVERSION=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION."\n";')
@@ -48,5 +11,6 @@ echo "$PHPVERSION" | tee -a "$ARTIFACTS"/phpversion.txt
4811
section_end
4912

5013
section_start "Run composer"
14+
cd webapp
5115
composer install --no-scripts 2>&1 | tee -a "$ARTIFACTS/composer_log.txt"
5216
section_end

.github/jobs/configure-checks/all.bats

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ compile_assertions_finished () {
231231
assert_line " - bin..............: /opt/domjudge/domserver/bin"
232232
assert_line " - etc..............: /opt/domjudge/domserver/etc"
233233
assert_line " - lib..............: /opt/domjudge/domserver/lib"
234-
assert_line " - libvendor........: /opt/domjudge/domserver/lib/vendor"
235234
assert_line " - log..............: /opt/domjudge/domserver/log"
236235
assert_line " - run..............: /opt/domjudge/domserver/run"
237236
assert_line " - sql..............: /opt/domjudge/domserver/sql"
@@ -257,7 +256,6 @@ compile_assertions_finished () {
257256
refute_line " * documentation.......: /opt/domjudge/doc"
258257
refute_line " * domserver...........: /opt/domjudge/domserver"
259258
refute_line " - bin..............: /opt/domjudge/domserver/bin"
260-
refute_line " - libvendor........: /opt/domjudge/domserver/lib/vendor"
261259
refute_line " - tmp..............: /opt/domjudge/domserver/tmp"
262260
refute_line " - example_problems.: /opt/domjudge/domserver/example_problems"
263261
refute_line " * judgehost...........: /opt/domjudge/judgehost"
@@ -269,7 +267,6 @@ compile_assertions_finished () {
269267
assert_line " * prefix..............: /tmp"
270268
assert_line " * documentation.......: /tmp/doc"
271269
assert_line " * domserver...........: /tmp/domserver"
272-
assert_line " - libvendor........: /tmp/domserver/lib/vendor"
273270
assert_line " * judgehost...........: /tmp/judgehost"
274271
assert_line " - judge............: /tmp/judgehost/judgings"
275272
}
@@ -291,7 +288,6 @@ compile_assertions_finished () {
291288
assert_line " - bin..............: /usr/local/bin"
292289
assert_line " - etc..............: /usr/local/etc/domjudge"
293290
assert_line " - lib..............: /usr/local/lib/domjudge"
294-
assert_line " - libvendor........: /usr/local/lib/domjudge/vendor"
295291
assert_line " - log..............: /usr/local/var/log/domjudge"
296292
assert_line " - run..............: /usr/local/var/run/domjudge"
297293
assert_line " - sql..............: /usr/local/share/domjudge/sql"
@@ -319,7 +315,6 @@ compile_assertions_finished () {
319315
assert_line " - bin..............: /usr/local/bin"
320316
assert_line " - etc..............: /usr/local/etc/domjudge"
321317
assert_line " - lib..............: /usr/local/lib/domjudge"
322-
assert_line " - libvendor........: /usr/local/lib/domjudge/vendor"
323318
assert_line " - log..............: /usr/local/var/log/domjudge"
324319
assert_line " - run..............: /usr/local/var/run/domjudge"
325320
assert_line " - sql..............: /usr/local/share/domjudge/sql"

.github/jobs/webstandard.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ if [ "$TEST" = "w3cval" ]; then
109109
unzip -q vnu.linux.zip
110110
section_end
111111
112-
FLTR='--filterpattern .*autocomplete.*|.*style.*|.*role=tab.*|.*descendant.*|.*Stray.*|.*attribute.*|.*Forbidden.*|.*stream.*'
112+
FLTR='--filterpattern .*autocomplete.*|.*style.*|.*role=tab.*|.*descendant.*|.*Stray.*|.*attribute.*|.*Forbidden.*|.*stream.*|.*obsolete.*'
113113
for typ in html css svg
114114
do
115115
section_start "Analyse with $typ"
@@ -133,7 +133,7 @@ else
133133
else
134134
STAN="-s $TEST"
135135
FLTR0="-E '#DataTables_Table_0 > tbody > tr > td > a','#menuDefault > a','#filter-card > div > div > div > span > span:nth-child(1) > span > ul > li > input',.problem-badge"
136-
FLTR1="'html > body > div > div > div > div > div > div > table > tbody > tr > td > a > span'"
136+
FLTR1="'html > body > div > div > div > div > div > div > table > tbody > tr > td > a > span','html > body > div > div > div > div > div > div > form > div > div > div > label'"
137137
FLTR="$FLTR0,$FLTR1"
138138
fi
139139
chown -R domjudge:domjudge "$DIR"

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ jobs:
4141

4242
- name: Install composer files
4343
if: ${{ contains(env.COMPILED, matrix.language) }}
44-
run: composer install --no-scripts
44+
run: |
45+
cd webapp
46+
composer install --no-scripts
4547
4648
- name: Configure Makefile
4749
if: ${{ contains(env.COMPILED, matrix.language) }}

.github/workflows/phpstan.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ jobs:
1818
run: .github/jobs/composer_setup.sh
1919
- uses: php-actions/phpstan@v3
2020
with:
21-
configuration: phpstan.dist.neon
21+
configuration: webapp/phpstan.dist.neon
2222
path: webapp/src webapp/tests
2323
php_extensions: gd intl mysqli pcntl zip
24+
autoload_file: webapp/vendor/autoload.php
2425
- uses: actions/upload-artifact@v4
2526
if: always()
2627
with:

Makefile

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
export TOPDIR = $(shell pwd)
66

77
REC_TARGETS=build domserver install-domserver judgehost install-judgehost \
8-
docs install-docs inplace-install inplace-uninstall
8+
docs install-docs inplace-install inplace-uninstall maintainer-conf \
9+
composer-dependencies composer-dependencies-dev
910

1011
# Global Makefile definitions
1112
include $(TOPDIR)/Makefile.global
@@ -64,21 +65,6 @@ ifneq "$(JUDGEHOST_BUILD_ENABLED)" "yes"
6465
@exit 1
6566
endif
6667

67-
# Install PHP dependencies
68-
composer-dependencies:
69-
ifeq (, $(shell command -v composer 2> /dev/null))
70-
$(error "'composer' command not found in $(PATH), install it via your package manager or https://getcomposer.org/download/")
71-
endif
72-
# We use --no-scripts here because at this point the autoload.php file is
73-
# not generated yet, which is needed to run the post-install scripts.
74-
composer $(subst 1,-q,$(QUIET)) install --prefer-dist -o -a --no-scripts --no-plugins
75-
76-
composer-dependencies-dev:
77-
composer $(subst 1,-q,$(QUIET)) install --prefer-dist --no-scripts --no-plugins
78-
79-
composer-dump-autoload-dev:
80-
composer $(subst 1,-q,$(QUIET)) dump-autoload
81-
8268
# Generate documentation for distribution. Remove this dependency from
8369
# dist above for quicker building from git sources.
8470
distdocs:
@@ -94,19 +80,23 @@ build-scripts:
9480
$(MAKE) -C sql build-scripts
9581

9682
# List of SUBDIRS for recursive targets:
97-
build: SUBDIRS= lib misc-tools
98-
domserver: SUBDIRS=etc lib sql misc-tools webapp
99-
install-domserver: SUBDIRS=etc lib sql misc-tools webapp example_problems
100-
judgehost: SUBDIRS=etc judge misc-tools
101-
install-judgehost: SUBDIRS=etc lib judge misc-tools
102-
docs: SUBDIRS= doc
103-
install-docs: SUBDIRS= doc
104-
inplace-install: SUBDIRS= doc misc-tools
105-
inplace-uninstall: SUBDIRS= doc misc-tools
106-
dist: SUBDIRS= lib sql misc-tools
107-
clean: SUBDIRS=etc doc lib sql judge misc-tools webapp
108-
distclean: SUBDIRS=etc doc lib sql judge misc-tools webapp
109-
maintainer-clean: SUBDIRS=etc doc lib sql judge misc-tools webapp
83+
build: SUBDIRS= lib misc-tools
84+
domserver: SUBDIRS=etc sql misc-tools webapp
85+
install-domserver: SUBDIRS=etc lib sql misc-tools webapp example_problems
86+
judgehost: SUBDIRS=etc judge misc-tools
87+
install-judgehost: SUBDIRS=etc lib judge misc-tools
88+
docs: SUBDIRS= doc
89+
install-docs: SUBDIRS= doc
90+
maintainer-conf: SUBDIRS= webapp
91+
maintainer-install: SUBDIRS= webapp
92+
inplace-install: SUBDIRS= doc misc-tools webapp
93+
inplace-uninstall: SUBDIRS= doc misc-tools
94+
dist: SUBDIRS= lib sql misc-tools
95+
clean: SUBDIRS=etc doc lib sql judge misc-tools webapp
96+
distclean: SUBDIRS=etc doc lib sql judge misc-tools webapp
97+
maintainer-clean: SUBDIRS=etc doc lib sql judge misc-tools webapp
98+
composer-dependencies: SUBDIRS= webapp
99+
composer-dependencies-dev: SUBDIRS= webapp
110100

111101
domserver-create-dirs:
112102
$(INSTALL_DIR) $(addprefix $(DESTDIR),$(domserver_dirs))
@@ -187,7 +177,7 @@ paths.mk:
187177
@exit 1
188178

189179
# Configure for running in source tree, not meant for normal use:
190-
maintainer-conf: inplace-conf-common composer-dependencies-dev webapp/.env.local
180+
maintainer-conf: inplace-conf-common composer-dependencies-dev
191181
inplace-conf: inplace-conf-common composer-dependencies
192182
inplace-conf-common: dist
193183
./configure $(subst 1,-q,$(QUIET)) --prefix=$(CURDIR) \
@@ -205,13 +195,6 @@ inplace-conf-common: dist
205195
--with-baseurl='http://localhost/domjudge/' \
206196
$(CONFIGURE_FLAGS)
207197

208-
# Run Symfony in dev mode (for maintainer-mode):
209-
webapp/.env.local:
210-
@echo "Creating file '$@'..."
211-
@echo "# This file was automatically created by 'make maintainer-conf' to run" > $@
212-
@echo "# the DOMjudge Symfony application in developer mode. Adjust as needed." >> $@
213-
@echo "APP_ENV=dev" >> $@
214-
215198
# Install the system in place: don't really copy stuff, but create
216199
# symlinks where necessary to let it work from the source tree.
217200
# This stuff is a hack!
@@ -233,8 +216,6 @@ inplace-install-l:
233216
# because judgehost-create-dirs sets wrong permissions:
234217
$(MKDIR_P) $(domserver_tmpdir)
235218
chmod a+rwx $(domserver_tmpdir)
236-
# Make sure we're running from a clean state:
237-
composer auto-scripts
238219
@echo ""
239220
@echo "========== Maintainer Install Completed =========="
240221
@echo ""

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The M4 autoconf macros are licensed under all-permissive and GPL3+
7272
licences; see the respective files under m4/ for details.
7373

7474
The DOMjudge tarball ships external library dependencies in the
75-
lib/vendor directory. These are covered by their individual licenses
75+
webapp/vendor directory. These are covered by their individual licenses
7676
as specified in the file composer.lock.
7777

7878
Contact

configure.ac

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ if test "x$FHS_ENABLED" = xyes ; then
170170
AC_SUBST(domserver_webappdir, $datadir/${PACKAGE_TARNAME}/webapp)
171171
AC_SUBST(domserver_sqldir, $datadir/${PACKAGE_TARNAME}/sql)
172172
AC_SUBST(domserver_libdir, $libdir/${PACKAGE_TARNAME})
173-
AC_SUBST(domserver_libvendordir, $libdir/${PACKAGE_TARNAME}/vendor)
174173
AC_SUBST(domserver_logdir, $localstatedir/log/${PACKAGE_TARNAME})
175174
AC_SUBST(domserver_rundir, $localstatedir/run/${PACKAGE_TARNAME})
176175
AC_SUBST(domserver_tmpdir, /tmp)
@@ -222,7 +221,6 @@ AX_PATH(domserver_etcdir, [$domserver_root/etc])
222221
AX_PATH(domserver_webappdir, [$domserver_root/webapp])
223222
AX_PATH(domserver_sqldir, [$domserver_root/sql])
224223
AX_PATH(domserver_libdir, [$domserver_root/lib])
225-
AX_PATH(domserver_libvendordir, [$domserver_root/lib/vendor])
226224
AX_PATH(domserver_logdir, [$domserver_root/log])
227225
AX_PATH(domserver_rundir, [$domserver_root/run])
228226
AX_PATH(domserver_tmpdir, [$domserver_root/tmp])
@@ -382,7 +380,6 @@ echo " * domserver...........: AX_VAR_EXPAND($domserver_root)"
382380
echo " - bin..............: AX_VAR_EXPAND($domserver_bindir)"
383381
echo " - etc..............: AX_VAR_EXPAND($domserver_etcdir)"
384382
echo " - lib..............: AX_VAR_EXPAND($domserver_libdir)"
385-
echo " - libvendor........: AX_VAR_EXPAND($domserver_libvendordir)"
386383
echo " - log..............: AX_VAR_EXPAND($domserver_logdir)"
387384
echo " - run..............: AX_VAR_EXPAND($domserver_rundir)"
388385
echo " - sql..............: AX_VAR_EXPAND($domserver_sqldir)"

etc/domserver-static.php.in

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77

88
define('DOMJUDGE_VERSION', '@DOMJUDGE_VERSION@');
99

10-
define('BINDIR', '@domserver_bindir@');
11-
define('ETCDIR', '@domserver_etcdir@');
12-
define('WEBAPPDIR', '@domserver_webappdir@');
13-
define('LIBDIR', '@domserver_libdir@');
14-
define('SQLDIR', '@domserver_sqldir@');
15-
define('LIBVENDORDIR','@domserver_libvendordir@');
16-
define('LOGDIR', '@domserver_logdir@');
17-
define('RUNDIR', '@domserver_rundir@');
18-
define('TMPDIR', '@domserver_tmpdir@');
10+
define('BINDIR', '@domserver_bindir@');
11+
define('ETCDIR', '@domserver_etcdir@');
12+
define('WEBAPPDIR', '@domserver_webappdir@');
13+
define('LIBDIR', '@domserver_libdir@');
14+
define('SQLDIR', '@domserver_sqldir@');
15+
define('VENDORDIR', '@domserver_webappdir@/vendor');
16+
define('LOGDIR', '@domserver_logdir@');
17+
define('RUNDIR', '@domserver_rundir@');
18+
define('TMPDIR', '@domserver_tmpdir@');
1919

20-
define('BASEURL', '@BASEURL@');
20+
define('BASEURL', '@BASEURL@');

gitlab/base.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,24 @@ parameters:
4848
domjudge.webappdir: /webapp
4949
domjudge.libdir: /lib
5050
domjudge.sqldir: /sql
51-
domjudge.libvendordir: /lib/vendor
51+
domjudge.vendordir: /webapp/vendor
5252
domjudge.logdir: /output/log
5353
domjudge.rundir: /output/run
5454
domjudge.tmpdir: /output/tmp
5555
domjudge.baseurl: http://localhost/domjudge
5656
EOF
5757

58+
# Composer steps
59+
cd webapp
5860
# install check if the cache might be dirty
5961
set +e
60-
composer install --no-scripts || rm -rf lib/vendor
62+
composer install --no-scripts || rm -rf vendor
6163
set -e
6264

6365
# install all php dependencies
6466
composer install --no-scripts
6567
echo -e "\033[0m"
68+
cd $DIR
6669

6770
# configure, make and install (but skip documentation)
6871
make configure

gitlab/ci/template.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
.cached_vendor:
2828
extends: [.clean_ordering]
2929
cache:
30-
key: libvendor-260522
30+
key: webappvendor-20240623
3131
paths:
32-
- lib/vendor/
32+
- webapp/vendor/
3333

3434
.mysql_job:
3535
script:

gitlab/unit-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ echo "UPDATE user SET teamid = 1 WHERE userid = 1;" | mysql domjudge_test
2020
cp webapp/.env.test /opt/domjudge/domserver/webapp/
2121

2222
# We also need the composer.json for PHPunit to detect the correct directory.
23-
cp composer.json /opt/domjudge/domserver/
23+
cp webapp/composer.json /opt/domjudge/domserver/webapp/
2424

2525
cd /opt/domjudge/domserver
2626

lib/Makefile

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,9 @@ $(OBJECTS): %$(OBJEXT): %.c %.h
1515
clean-l:
1616
rm -f $(OBJECTS)
1717

18-
# Change baseDir in composer autogenerated files
19-
define fix_composer_paths
20-
for file in autoload_psr4.php autoload_classmap.php autoload_files.php autoload_namespaces.php ; do \
21-
sed -i "s#^\$$baseDir = .*#\$$baseDir = dirname('$(domserver_webappdir)');#" $(1)/composer/$$file ; \
22-
done
23-
sed -i "s#__DIR__ \. '/\.\./\.\./\.\.' \. '/webapp#'$(domserver_webappdir)#" $(1)/composer/autoload_static.php
24-
endef
25-
2618
install-domserver:
2719
$(INSTALL_DATA) -t $(DESTDIR)$(domserver_libdir) *.php
2820
$(INSTALL_PROG) -t $(DESTDIR)$(domserver_libdir) alert
29-
for i in vendor/* ; do \
30-
$(call install_tree,$(DESTDIR)$(domserver_libvendordir),$$i) ; \
31-
done
32-
$(call fix_composer_paths,$(DESTDIR)$(domserver_libvendordir))
3321

3422
install-judgehost:
3523
$(INSTALL_DATA) -t $(DESTDIR)$(judgehost_libdir) *.php *.sh

0 commit comments

Comments
 (0)