Skip to content

Put lib/vendor close to the webapp #2428

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

Merged
merged 1 commit into from
Jul 7, 2024
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: 2 additions & 3 deletions .github/jobs/baseinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export PHPVERSION

section_start "Run composer"
export APP_ENV="dev"
cd webapp
composer install --no-scripts |tee "$ARTIFACTS"/composer_out.txt
cd ..
section_end

section_start "Set simple admin password"
Expand Down Expand Up @@ -58,9 +60,6 @@ section_end

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

section_start "Show PHP config"
Expand Down
40 changes: 2 additions & 38 deletions .github/jobs/composer_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,7 @@

set -eux

# Store artifacts/logs
export ARTIFACTS="/tmp/artifacts"
mkdir -p "$ARTIFACTS"

# Functions to annotate the Github actions logs
trace_on () {
set -x
}

trace_off () {
{
set +x
} 2>/dev/null
}

section_start_internal () {
echo "::group::$1"
trace_on
}

section_end_internal () {
echo "::endgroup::"
trace_on
}

section_start () {
if [ "$#" -ne 1 ]; then
echo "Only 1 argument is needed for GHA, 2 was needed for GitLab."
exit 1
fi
trace_off
section_start_internal "$1"
}

section_end () {
trace_off
section_end_internal
}
. .github/jobs/ci_settings.sh

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

section_start "Run composer"
cd webapp
composer install --no-scripts 2>&1 | tee -a "$ARTIFACTS/composer_log.txt"
section_end
5 changes: 0 additions & 5 deletions .github/jobs/configure-checks/all.bats
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ compile_assertions_finished () {
assert_line " - bin..............: /opt/domjudge/domserver/bin"
assert_line " - etc..............: /opt/domjudge/domserver/etc"
assert_line " - lib..............: /opt/domjudge/domserver/lib"
assert_line " - libvendor........: /opt/domjudge/domserver/lib/vendor"
assert_line " - log..............: /opt/domjudge/domserver/log"
assert_line " - run..............: /opt/domjudge/domserver/run"
assert_line " - sql..............: /opt/domjudge/domserver/sql"
Expand All @@ -257,7 +256,6 @@ compile_assertions_finished () {
refute_line " * documentation.......: /opt/domjudge/doc"
refute_line " * domserver...........: /opt/domjudge/domserver"
refute_line " - bin..............: /opt/domjudge/domserver/bin"
refute_line " - libvendor........: /opt/domjudge/domserver/lib/vendor"
refute_line " - tmp..............: /opt/domjudge/domserver/tmp"
refute_line " - example_problems.: /opt/domjudge/domserver/example_problems"
refute_line " * judgehost...........: /opt/domjudge/judgehost"
Expand All @@ -269,7 +267,6 @@ compile_assertions_finished () {
assert_line " * prefix..............: /tmp"
assert_line " * documentation.......: /tmp/doc"
assert_line " * domserver...........: /tmp/domserver"
assert_line " - libvendor........: /tmp/domserver/lib/vendor"
assert_line " * judgehost...........: /tmp/judgehost"
assert_line " - judge............: /tmp/judgehost/judgings"
}
Expand All @@ -291,7 +288,6 @@ compile_assertions_finished () {
assert_line " - bin..............: /usr/local/bin"
assert_line " - etc..............: /usr/local/etc/domjudge"
assert_line " - lib..............: /usr/local/lib/domjudge"
assert_line " - libvendor........: /usr/local/lib/domjudge/vendor"
assert_line " - log..............: /usr/local/var/log/domjudge"
assert_line " - run..............: /usr/local/var/run/domjudge"
assert_line " - sql..............: /usr/local/share/domjudge/sql"
Expand Down Expand Up @@ -319,7 +315,6 @@ compile_assertions_finished () {
assert_line " - bin..............: /usr/local/bin"
assert_line " - etc..............: /usr/local/etc/domjudge"
assert_line " - lib..............: /usr/local/lib/domjudge"
assert_line " - libvendor........: /usr/local/lib/domjudge/vendor"
assert_line " - log..............: /usr/local/var/log/domjudge"
assert_line " - run..............: /usr/local/var/run/domjudge"
assert_line " - sql..............: /usr/local/share/domjudge/sql"
Expand Down
4 changes: 2 additions & 2 deletions .github/jobs/webstandard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ if [ "$TEST" = "w3cval" ]; then
unzip -q vnu.linux.zip
section_end

FLTR='--filterpattern .*autocomplete.*|.*style.*|.*role=tab.*|.*descendant.*|.*Stray.*|.*attribute.*|.*Forbidden.*|.*stream.*'
FLTR='--filterpattern .*autocomplete.*|.*style.*|.*role=tab.*|.*descendant.*|.*Stray.*|.*attribute.*|.*Forbidden.*|.*stream.*|.*obsolete.*'
for typ in html css svg
do
section_start "Analyse with $typ"
Expand All @@ -133,7 +133,7 @@ else
else
STAN="-s $TEST"
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"
FLTR1="'html > body > div > div > div > div > div > div > table > tbody > tr > td > a > span'"
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'"
FLTR="$FLTR0,$FLTR1"
fi
chown -R domjudge:domjudge "$DIR"
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ jobs:

- name: Install composer files
if: ${{ contains(env.COMPILED, matrix.language) }}
run: composer install --no-scripts
run: |
cd webapp
composer install --no-scripts

- name: Configure Makefile
if: ${{ contains(env.COMPILED, matrix.language) }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ jobs:
run: .github/jobs/composer_setup.sh
- uses: php-actions/phpstan@v3
with:
configuration: phpstan.dist.neon
configuration: webapp/phpstan.dist.neon
path: webapp/src webapp/tests
php_extensions: gd intl mysqli pcntl zip
autoload_file: webapp/vendor/autoload.php
- uses: actions/upload-artifact@v4
if: always()
with:
Expand Down
59 changes: 20 additions & 39 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
export TOPDIR = $(shell pwd)

REC_TARGETS=build domserver install-domserver judgehost install-judgehost \
docs install-docs inplace-install inplace-uninstall
docs install-docs inplace-install inplace-uninstall maintainer-conf \
composer-dependencies composer-dependencies-dev

# Global Makefile definitions
include $(TOPDIR)/Makefile.global
Expand Down Expand Up @@ -64,21 +65,6 @@ ifneq "$(JUDGEHOST_BUILD_ENABLED)" "yes"
@exit 1
endif

# Install PHP dependencies
composer-dependencies:
ifeq (, $(shell command -v composer 2> /dev/null))
$(error "'composer' command not found in $(PATH), install it via your package manager or https://getcomposer.org/download/")
endif
# We use --no-scripts here because at this point the autoload.php file is
# not generated yet, which is needed to run the post-install scripts.
composer $(subst 1,-q,$(QUIET)) install --prefer-dist -o -a --no-scripts --no-plugins

composer-dependencies-dev:
composer $(subst 1,-q,$(QUIET)) install --prefer-dist --no-scripts --no-plugins

composer-dump-autoload-dev:
composer $(subst 1,-q,$(QUIET)) dump-autoload

# Generate documentation for distribution. Remove this dependency from
# dist above for quicker building from git sources.
distdocs:
Expand All @@ -94,19 +80,23 @@ build-scripts:
$(MAKE) -C sql build-scripts

# List of SUBDIRS for recursive targets:
build: SUBDIRS= lib misc-tools
domserver: SUBDIRS=etc lib sql misc-tools webapp
install-domserver: SUBDIRS=etc lib sql misc-tools webapp example_problems
judgehost: SUBDIRS=etc judge misc-tools
install-judgehost: SUBDIRS=etc lib judge misc-tools
docs: SUBDIRS= doc
install-docs: SUBDIRS= doc
inplace-install: SUBDIRS= doc misc-tools
inplace-uninstall: SUBDIRS= doc misc-tools
dist: SUBDIRS= lib sql misc-tools
clean: SUBDIRS=etc doc lib sql judge misc-tools webapp
distclean: SUBDIRS=etc doc lib sql judge misc-tools webapp
maintainer-clean: SUBDIRS=etc doc lib sql judge misc-tools webapp
build: SUBDIRS= lib misc-tools
domserver: SUBDIRS=etc sql misc-tools webapp
install-domserver: SUBDIRS=etc lib sql misc-tools webapp example_problems
judgehost: SUBDIRS=etc judge misc-tools
install-judgehost: SUBDIRS=etc lib judge misc-tools
docs: SUBDIRS= doc
install-docs: SUBDIRS= doc
maintainer-conf: SUBDIRS= webapp
maintainer-install: SUBDIRS= webapp
inplace-install: SUBDIRS= doc misc-tools webapp
inplace-uninstall: SUBDIRS= doc misc-tools
dist: SUBDIRS= lib sql misc-tools
clean: SUBDIRS=etc doc lib sql judge misc-tools webapp
distclean: SUBDIRS=etc doc lib sql judge misc-tools webapp
maintainer-clean: SUBDIRS=etc doc lib sql judge misc-tools webapp
composer-dependencies: SUBDIRS= webapp
composer-dependencies-dev: SUBDIRS= webapp

domserver-create-dirs:
$(INSTALL_DIR) $(addprefix $(DESTDIR),$(domserver_dirs))
Expand Down Expand Up @@ -187,7 +177,7 @@ paths.mk:
@exit 1

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

# Run Symfony in dev mode (for maintainer-mode):
webapp/.env.local:
@echo "Creating file '$@'..."
@echo "# This file was automatically created by 'make maintainer-conf' to run" > $@
@echo "# the DOMjudge Symfony application in developer mode. Adjust as needed." >> $@
@echo "APP_ENV=dev" >> $@

# Install the system in place: don't really copy stuff, but create
# symlinks where necessary to let it work from the source tree.
# This stuff is a hack!
Expand All @@ -233,8 +216,6 @@ inplace-install-l:
# because judgehost-create-dirs sets wrong permissions:
$(MKDIR_P) $(domserver_tmpdir)
chmod a+rwx $(domserver_tmpdir)
# Make sure we're running from a clean state:
composer auto-scripts
@echo ""
@echo "========== Maintainer Install Completed =========="
@echo ""
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ The M4 autoconf macros are licensed under all-permissive and GPL3+
licences; see the respective files under m4/ for details.

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

Contact
Expand Down
3 changes: 0 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ if test "x$FHS_ENABLED" = xyes ; then
AC_SUBST(domserver_webappdir, $datadir/${PACKAGE_TARNAME}/webapp)
AC_SUBST(domserver_sqldir, $datadir/${PACKAGE_TARNAME}/sql)
AC_SUBST(domserver_libdir, $libdir/${PACKAGE_TARNAME})
AC_SUBST(domserver_libvendordir, $libdir/${PACKAGE_TARNAME}/vendor)
AC_SUBST(domserver_logdir, $localstatedir/log/${PACKAGE_TARNAME})
AC_SUBST(domserver_rundir, $localstatedir/run/${PACKAGE_TARNAME})
AC_SUBST(domserver_tmpdir, /tmp)
Expand Down Expand Up @@ -222,7 +221,6 @@ AX_PATH(domserver_etcdir, [$domserver_root/etc])
AX_PATH(domserver_webappdir, [$domserver_root/webapp])
AX_PATH(domserver_sqldir, [$domserver_root/sql])
AX_PATH(domserver_libdir, [$domserver_root/lib])
AX_PATH(domserver_libvendordir, [$domserver_root/lib/vendor])
AX_PATH(domserver_logdir, [$domserver_root/log])
AX_PATH(domserver_rundir, [$domserver_root/run])
AX_PATH(domserver_tmpdir, [$domserver_root/tmp])
Expand Down Expand Up @@ -382,7 +380,6 @@ echo " * domserver...........: AX_VAR_EXPAND($domserver_root)"
echo " - bin..............: AX_VAR_EXPAND($domserver_bindir)"
echo " - etc..............: AX_VAR_EXPAND($domserver_etcdir)"
echo " - lib..............: AX_VAR_EXPAND($domserver_libdir)"
echo " - libvendor........: AX_VAR_EXPAND($domserver_libvendordir)"
echo " - log..............: AX_VAR_EXPAND($domserver_logdir)"
echo " - run..............: AX_VAR_EXPAND($domserver_rundir)"
echo " - sql..............: AX_VAR_EXPAND($domserver_sqldir)"
Expand Down
20 changes: 10 additions & 10 deletions etc/domserver-static.php.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

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

define('BINDIR', '@domserver_bindir@');
define('ETCDIR', '@domserver_etcdir@');
define('WEBAPPDIR', '@domserver_webappdir@');
define('LIBDIR', '@domserver_libdir@');
define('SQLDIR', '@domserver_sqldir@');
define('LIBVENDORDIR','@domserver_libvendordir@');
define('LOGDIR', '@domserver_logdir@');
define('RUNDIR', '@domserver_rundir@');
define('TMPDIR', '@domserver_tmpdir@');
define('BINDIR', '@domserver_bindir@');
define('ETCDIR', '@domserver_etcdir@');
define('WEBAPPDIR', '@domserver_webappdir@');
define('LIBDIR', '@domserver_libdir@');
define('SQLDIR', '@domserver_sqldir@');
define('VENDORDIR', '@domserver_webappdir@/vendor');
define('LOGDIR', '@domserver_logdir@');
define('RUNDIR', '@domserver_rundir@');
define('TMPDIR', '@domserver_tmpdir@');

define('BASEURL', '@BASEURL@');
define('BASEURL', '@BASEURL@');
7 changes: 5 additions & 2 deletions gitlab/base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,24 @@ parameters:
domjudge.webappdir: /webapp
domjudge.libdir: /lib
domjudge.sqldir: /sql
domjudge.libvendordir: /lib/vendor
domjudge.vendordir: /webapp/vendor
domjudge.logdir: /output/log
domjudge.rundir: /output/run
domjudge.tmpdir: /output/tmp
domjudge.baseurl: http://localhost/domjudge
EOF

# Composer steps
cd webapp
# install check if the cache might be dirty
set +e
composer install --no-scripts || rm -rf lib/vendor
composer install --no-scripts || rm -rf vendor
set -e

# install all php dependencies
composer install --no-scripts
echo -e "\033[0m"
cd $DIR

# configure, make and install (but skip documentation)
make configure
Expand Down
4 changes: 2 additions & 2 deletions gitlab/ci/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
.cached_vendor:
extends: [.clean_ordering]
cache:
key: libvendor-260522
key: webappvendor-20240623
paths:
- lib/vendor/
- webapp/vendor/

.mysql_job:
script:
Expand Down
2 changes: 1 addition & 1 deletion gitlab/unit-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ echo "UPDATE user SET teamid = 1 WHERE userid = 1;" | mysql domjudge_test
cp webapp/.env.test /opt/domjudge/domserver/webapp/

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

cd /opt/domjudge/domserver

Expand Down
12 changes: 0 additions & 12 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,9 @@ $(OBJECTS): %$(OBJEXT): %.c %.h
clean-l:
rm -f $(OBJECTS)

# Change baseDir in composer autogenerated files
define fix_composer_paths
for file in autoload_psr4.php autoload_classmap.php autoload_files.php autoload_namespaces.php ; do \
sed -i "s#^\$$baseDir = .*#\$$baseDir = dirname('$(domserver_webappdir)');#" $(1)/composer/$$file ; \
done
sed -i "s#__DIR__ \. '/\.\./\.\./\.\.' \. '/webapp#'$(domserver_webappdir)#" $(1)/composer/autoload_static.php
endef

install-domserver:
$(INSTALL_DATA) -t $(DESTDIR)$(domserver_libdir) *.php
$(INSTALL_PROG) -t $(DESTDIR)$(domserver_libdir) alert
for i in vendor/* ; do \
$(call install_tree,$(DESTDIR)$(domserver_libvendordir),$$i) ; \
done
$(call fix_composer_paths,$(DESTDIR)$(domserver_libvendordir))

install-judgehost:
$(INSTALL_DATA) -t $(DESTDIR)$(judgehost_libdir) *.php *.sh
Expand Down
Loading
Loading