Skip to content

Clean up docker/build.sh #197

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
Aug 2, 2024

Conversation

tom93
Copy link
Contributor

@tom93 tom93 commented Jul 9, 2024

  • Move usage check to the top, to serve as documentation for people who read the script.

  • Remove -x from shebang line (#!), to only enable tracing in CI.

  • Fix set -x call (previously it was inside the if condition, which is wrong).

  • Include line numbers etc. in traces (using PS4) on GitHub Actions (previously they were only included on other CI platforms).
    Update: sh doesn't support $LINENO, so remove PS4 entirely instead.

  • Inline trace_off into section_start and section_end to produce less noise in the trace.

  • Make the no-op placeholders for section_start and section_end produce less noise in the trace.

  • Redirect stderr to stdout as a workaround for a GitHub Actions issue that causes them to appear out-of-order.

  • Simplify initialisation of NAMESPACE variable to make the trace look nicer.

  • Put the variable assignments in a log group to make it look nicer.

  • Fix the invocation of build.sh in the build-domjudge-container-* workflows to use ./build.sh rather than sh ./build.sh so that the options in the shebang line will be respected. Also remove unnecessary calls to set -x in the workflows.

Comment on lines -38 to -39
else
export PS4='(${0}:${LINENO}): - [$?] $ '
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out that LINENO doesn't work in sh. How about switching to bash?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We try by default ship sh scripts instead of bash, I don't think the LINENO is imporant enough to switch as this is only for CI and only in a legacy part of CI as this was used for gitlab-ci.

So in this case moving to bash is not worth it IMO, if you find another section where this makes sense I'm fine with (reconsider) moving. But to me the line numbers are not relevant when checking the CI log as this logging was only copied from the main repository but is not relevant for such a short script.

Copy link
Contributor Author

@tom93 tom93 Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching to bash would also allow hiding the section_start (and section_end) lines from the trace, but it's not a big deal. Currently it looks like this without PS4 (the "▸" lines are collapsed groups):

▶ Run cd docker
+ VERSION=8.2.3
+ NAMESPACE=domjudge
+ URL=https://www.domjudge.org/releases/domjudge-8.2.3.tar.gz
+ FILE=domjudge.tar.gz
+ section_start Download DOMjudge tarball
▶ Download DOMjudge tarball
+ section_start Build domserver container
▶ Build domserver container
+ section_start Build judgehost container (with intermediate image)
▸ Build judgehost container (with intermediate image)
+ section_start Build judgehost container (judging chroot)
▶ Build judgehost container (judging chroot)
+ section_start Push instructions
▶ Push instructions

(Another option is to only enable tracing between section_start and section_end, which would hide the section_start lines even in sh.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed PS4 (and put the variable assignments in a log group to make things look nicer).

@tom93 tom93 marked this pull request as draft July 9, 2024 19:53
 - Move usage check to the top, to serve as documentation for people
   who read the script.

 - Remove `-x` from shebang line (#!), to only enable tracing in CI.

 - Fix `set -x` call (previously it was inside the `if` condition,
   which is wrong).

 - Remove PS4 variable (which adds info to the trace) because sh does
   not support LINENO, and the rest of the info is not that useful.

 - Inline `trace_off` into section_start and section_end to produce
   less noise in the trace. (The "section_start" lines will still be
   displayed though. Hiding them is tricky; see
   DOMjudge/domjudge/gitlab/integration.sh for an example, but note
   that it requires bash for `shopt -s expand_aliases`.)

 - Make the no-op placeholders for section_start and section_end
   produce less noise in the trace.

 - Redirect stderr to stdout as a workaround for a GitHub Actions
   issue that causes them to appear out-of-order.

 - Simplify initialisation of NAMESPACE variable to make the trace
   look nicer.

 - Put the variable assignments in a log group to make it look nicer.

 - Fix the invocation of build.sh in the build-domjudge-container-*
   workflows to use `./build.sh` rather than `sh ./build.sh` so that
   the options in the shebang line will be respected. Also remove
   unnecessary calls to `set -x` in the workflows.
@tom93 tom93 force-pushed the pr/clean-up-docker-build-script branch from 6cd73e4 to 0a45274 Compare July 10, 2024 10:44
@tom93 tom93 marked this pull request as ready for review July 10, 2024 10:51
tom93 added a commit to tom93/domjudge that referenced this pull request Jul 21, 2024
tom93 added a commit to tom93/domjudge that referenced this pull request Jul 25, 2024
@tom93 tom93 mentioned this pull request Aug 2, 2024
@vmcj vmcj added this pull request to the merge queue Aug 2, 2024
Merged via the queue into DOMjudge:main with commit a2b0824 Aug 2, 2024
3 checks passed
@tom93 tom93 deleted the pr/clean-up-docker-build-script branch August 5, 2024 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants