Skip to content
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

Refactor parts of the ParseConfiguration #1446

Merged
merged 1 commit into from
Aug 25, 2024

Conversation

jonjohnsonjr
Copy link
Contributor

This thing is a bit of a beast, so I'm not going to do it all at once, but some of these string replacements are incredibly mutate-y, so I've rewritten them to be a bit more functional.

This still isn't great, but I think it's better than before.

imjasonh
imjasonh previously approved these changes Aug 21, 2024
@jonjohnsonjr
Copy link
Contributor Author

Drafted this because I'm not 100% happy with it. I've tried to model how things are working with these different phases of ParseConfiguration/Compile:

image

(link)

I'd love to refactor the code to look more like this so that it's easier to change/fix the code without accidentally breaking things.

@Dentrax
Copy link
Contributor

Dentrax commented Aug 25, 2024

Thanks @jonjohnsonjr! Could we also add 2 test cases to check:

  1. subpackages[].range[].pipeline[].working-directory[].pipeline is evaluating without any issues
  2. the following package build exists with 1?
package:
  name: foo
  version: 1.0.0
  epoch: 0
  description: Test
  copyright:
    - license: MIT

environment:
  contents:
    packages:
      - build-base
      - busybox

data:
  - name: packages
    items:
      foo: foo
      bar: bar

pipeline:
  - runs: mkdir foo bar

subpackages:
  - range: packages
    name: "${{package.name}}-${{range.key}}"
    description: Package ${{range.value}}
    pipeline:
      - working-directory: ${{range.key}}
        pipeline:
          - runs: exit 1

update:
  enabled: false

@jonjohnsonjr jonjohnsonjr marked this pull request as ready for review August 25, 2024 18:23
This thing is a bit of a beast, so I'm not going to do it all at once,
but some of these string replacements are incredibly mutate-y, so I've
rewritten them to be a bit more functional.

This still isn't great, but I think it's better than before.

Signed-off-by: Jon Johnson <jon.johnson@chainguard.dev>
@jonjohnsonjr
Copy link
Contributor Author

is evaluating without any issues

Added a sub-pipeline to one of the tests that includes subpackages, that works fine.

the following package build exists with 1?

I don't think we have any tests that are supposed to fail but I ran that locally with my change and got:

ERRO failed to build package: unable to run subpackage fail-bar pipeline: unable to run pipeline: unable to run pipeline: task exited with code 1

@jonjohnsonjr jonjohnsonjr merged commit 9f17579 into chainguard-dev:main Aug 25, 2024
37 checks passed
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.

3 participants