Skip to content

PoC: Create SingleInterpolation classes

Avielle Wolfe requested to merge aw-single-interpolation-poc into master

What does this MR do and why?

This MR creates a SingleInterpolation module that contains modified versions of the Interpolator, Template, and Config classes from the Interpolation module. The modifications implement a single interpolation process, where an entire YAML config is interpolated in one go.

  • SingleInterpolation uses the Interpolation::Access, Interpolation::Block, and Interpolation::Context classes without any changes
  • This MR adds a ci_single_interpolation feature flag that we can use for a percentage based rollout
  • Since this is a PoC, it only adds specs to Yaml::Loader so we can test at an integration level that the interpolation is working as expected
  • This MR includes a new ArrayInput so we can test that single interpolation works for arrays

Local Testing

  1. Create a file included.yml in the root directory of a project
spec:
  inputs:
    after_script:
    allow_failure:
      type: boolean
    cleanup:
    deploy_job_name:
    deploy_script:
      type: array
    parallel:
      type: number
    test_script_name:
---
.scripts:
  rspec:
    - echo "Runs rspec"
  cleanup:
    - echo "$[[ inputs.cleanup ]]"

test_job:
  after_script: $[[ inputs.after_script ]]
  parallel: $[[ inputs.parallel ]]
  script: !reference [.scripts, "$[[ inputs.test_script_name ]]"]

$[[ inputs.deploy_job_name ]]:
  allow_failure: $[[ inputs.allow_failure ]]
  script: $[[ inputs.deploy_script ]]
  1. In the CI Editor, add the following configuration
# .gitlab-ci.yml

include:
  - local: included.yml
    inputs:
      after_script: "!reference [.scripts, cleanup]"
      allow_failure: true
      cleanup: Cleanup things
      deploy_job_name: inputs_deploy
      deploy_script:
        - echo "Staging deploy from input"
        - echo "Prod deploy from input"
      parallel: 8
      test_script_name: rspec
  1. The parsed configuration should be:
---
".scripts":
  rspec:
  - echo "Runs rspec"
  cleanup:
  - echo "Cleanup things"
test_job:
  after_script:
  - echo "Cleanup things"
  parallel: 8
  script:
  - echo "Runs rspec"
inputs_deploy:
  allow_failure: true
  script:
  - echo "Staging deploy from input"
  - echo "Prod deploy from input"

References

Benchmarking:

Issue: #411438 (closed)

Previous spike: !132045 (closed)

Edited by Avielle Wolfe

Merge request reports

Loading