OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Speedup assets precompilation for CI (#12900)
Cyril Rohr4fe2a73087ae
diff --git a/docker/ci/Dockerfile b/docker/ci/Dockerfileindex c29c0500c88..a0a5f66be62 100644--- a/docker/ci/Dockerfile+++ b/docker/ci/Dockerfile@@ -64,11 +64,17 @@ COPY --from=nodejs /app/node_modules ./node_modulesCOPY --from=nodejs /app/frontend/node_modules ./frontend/node_modulesCOPY --chown=$APP_USER:$APP_USER . .+USER $APP_USERENV DATABASE_URL="postgres://appuser:[email protected]/appdb"ENV BUNDLE_WITHOUT="development:production:docker"+RUN --mount=type=cache,target=/app/frontend/.angular/cache,uid=1000,gid=1000 DATABASE_URL=nulldb://db bin/rails openproject:plugins:register_frontend assets:precompile && \+ # only keep most current angular cache since webpack is unable to cleanup after itself+ find frontend/.angular/cache -type d -exec sh -c 'ls -dt "$1"/*/ | tail -n +2 | xargs rm -r' sh {} \;+RUN cp -rp config/frontend_assets.manifest.json public/assets/frontend_assets.manifest.json+RUN cp docker/ci/database.yml config/+COPY ./docker/ci/entrypoint.sh /usr/sbin/entrypoint.sh-USER $APP_USERENTRYPOINT [ "/usr/sbin/entrypoint.sh" ]CMD ["setup-tests", "bash"]diff --git a/docker/ci/entrypoint.sh b/docker/ci/entrypoint.shindex 528eb0fd27c..268bb7a698a 100755--- a/docker/ci/entrypoint.sh+++ b/docker/ci/entrypoint.sh@@ -8,7 +8,7 @@ export PARALLEL_TEST_PROCESSORS=$JOBSexport PARALLEL_TEST_FIRST_IS_1=trueexport DISABLE_DATABASE_ENVIRONMENT_CHECK=1export NODE_OPTIONS="--max-old-space-size=8192"-LOG_FILE=/tmp/op-output.log+export LOG_FILE=/tmp/op-output.logrun_psql() {$PGBIN/psql -v ON_ERROR_STOP=1 -U dev -h 127.0.0.1 "$@"@@ -19,9 +19,10 @@ cleanup() {echo "CLEANUP"rm -rf tmp/cache/parallel*if [ -d tmp/features ]; then mv tmp/features spec/ ; fi+if [ ! $exit_code -eq "0" ]; thenecho "ERROR: exit code $exit_code"- cat $LOG_FILE+ tail -n 1000 $LOG_FILEfirm -f $LOG_FILE}@@ -35,7 +36,7 @@ execute() {}execute_quiet() {- if ! BANNER="[execute_quiet]" execute "$@" >$LOG_FILE ; then+ if ! BANNER="[execute_quiet]" execute "$@" >"$LOG_FILE" ; thenreturn 1elsereturn 0@@ -52,14 +53,9 @@ reset_dbs() {done}-if [ "$1" == "setup-tests" ]; then- shift+setup_tests() {echo "Preparing environment for running tests..."-- execute_quiet "mkdir -p tmp"- execute_quiet "cp docker/ci/database.yml config/"-- for i in $(seq 0 $JOBS); do+ for i in $(seq 1 $JOBS); dofolder="$CAPYBARA_DOWNLOADED_FILE_DIR/$i"execute_quiet "rm -rf '$folder' ; mkdir -p '$folder' ; chmod 1777 '$folder'"done@@ -72,11 +68,10 @@ if [ "$1" == "setup-tests" ]; thenfi# create test database "app" and dump schema because db/structure.sql is not checked in- execute_quiet "time bundle exec rails db:migrate db:schema:dump zeitwerk:check openproject:plugins:register_frontend"-fi+ execute_quiet "time bundle exec rails db:migrate db:schema:dump zeitwerk:check webdrivers:chromedriver:update webdrivers:geckodriver:update"+}-if [ "$1" == "run-units" ]; then- shift+run_units() {reset_dbsexecute_quiet "cp -f /cache/turbo_runtime_units.log spec/support/ || true"# turbo_tests cannot yet exclude specific directories, so copying spec/features elsewhere (temporarily)@@ -84,28 +79,44 @@ if [ "$1" == "run-units" ]; thenexecute "time bundle exec turbo_tests --verbose -n $JOBS --runtime-log spec/support/turbo_runtime_units.log spec"execute_quiet "cp -f spec/support/turbo_runtime_units.log /cache/ || true"cleanup-fi+}-if [ "$1" == "run-features" ]; then- shift+run_features() {reset_dbs- execute_quiet "time bundle exec rails assets:precompile webdrivers:chromedriver:update webdrivers:geckodriver:update"execute_quiet "cp -f /cache/turbo_runtime_features.log spec/support/ || true"- execute_quiet "cp -rp config/frontend_assets.manifest.json public/assets/frontend_assets.manifest.json"execute "time bundle exec turbo_tests --verbose -n $JOBS --runtime-log spec/support/turbo_runtime_features.log spec/features"execute_quiet "cp -f spec/support/turbo_runtime_features.log /cache/ || true"cleanup-fi+}-if [ "$1" == "run-all" ]; then- shift+run_all() {reset_dbs- execute_quiet "time bundle exec rails assets:precompile webdrivers:chromedriver:update webdrivers:geckodriver:update"execute_quiet "cp -f /cache/turbo_runtime_all.log spec/support/ || true"- execute_quiet "cp -rp config/frontend_assets.manifest.json public/assets/frontend_assets.manifest.json"execute "time bundle exec turbo_tests --verbose -n $JOBS --runtime-log spec/support/turbo_runtime_all.log spec"execute_quiet "cp -f spec/support/turbo_runtime_all.log /cache/ || true"cleanup+}++export -f cleanup execute execute_quiet run_psql reset_dbs setup_tests run_units run_features++if [ "$1" == "setup-tests" ]; then+ shift+ setup_tests+fi++if [ "$1" == "run-units" ]; then+ shift+ run_units+fi++if [ "$1" == "run-features" ]; then+ shift+ run_features+fi++if [ "$1" == "run-all" ]; then+ shift+ run_allfiif [ ! -z "$1" ] ; then