Split assets build to dedicated job (take 2)

What does this MR do?

NOTE: This MR is a redo of !57754 (merged), which was reverted because it had problems with the custom config monkey patch

Split build 7/9 ("assets") out of PartialBuild to separate dedicated jobs:

  • This first dedicated job will introduce extensions/destination_path_regexes_filter. This will use DESTINATION_PATH_REGEXES, which is a comma-delimited list of regexes which will be matched against paths under source (Middleman "resource.destination_path") to determine what will be built. The extension will be very similar to the manipulate_resource_list in extensions/monorepo.rb.
  • Update scripts/deploy to use DESTINATION_PATH_REGEXES. This is a comma-separated list of top-level paths to be partially deployed. Will need to introduce a loop with a separate rsync command for each path.

Tasks

  • Write the extension
  • Write ci jobs to use the extension (use handbook jobs as a template)
  • Remove reference to assets from PartialBuild
  • Rename existing assets jobs to packaged-assets
  • Use a custom minimal middleman config file /config_assets.rb, which can stay at top level when rest of main /config.rb moves down to marketing repo.
    • Need to monkeypatch middleman to support MIDDLEMAN_CONFIG_FILE_NAME for custom config file.
  • Replace the only ERB-processed stylesheet with the rendered CSS: source/stylesheets/highlight.css.erb
  • Move asset-specific config out of main config.rb into config_assets.rb:
    • activate :minify_css
    • activate :minify_javascript
    • activate :autoprefixer...
  • Verify that exactly the same files are built and published in the artifact on the branch (assets-build-and-review-deploy example) as current master code (build 7/9 - example) with PartialBuild.
  • Verify there are no (actually used) javascript or css source outside the built directories:
    find source -iname '*.js*' | grep -E -v '(source/stylesheets/|source/javascripts|source/frontend|json)'
    source/images/blogimages/gitlab-daily-tools/Handy GitLab actions.user.js
    source/images/blogimages/gitlab-daily-tools/GitLab filters.user.js
    
    find source -iname '*css*' | grep -E -v '(source/stylesheets/|source/javascripts|source/frontend|json)'
    source/images/organizations/logo_ericsson.svg
    source/images/organizations/logo_ericsson_ultra.svg
    source/images/ux/include_gitlab_css.png
  • Test with local dev env
  • [-] Test with local build rake build:all will be updated in a subsequent MR.
  • Test in review app
  • Test in production

Tips

Example of testing the build locally with a single file:

DESTINATION_PATH_REGEXES='^stylesheets/highlight.css' MIDDLEMAN_CONFIG_FILE_NAME='config_assets.rb' NO_CONTRACTS=true  bundle exec middleman build

Related issues

Relates #8302 (closed)

Edited by Chad Woolley

Merge request reports

Loading