server icon indicating copy to clipboard operation
server copied to clipboard

feat(templates): support same-repo templates using build commit

Open ecrupper opened this issue 2 years ago • 6 comments

When working with templates that are found in the same repo as the Vela file, any live edits to the templates requires the users to reference their specific branch in the templates block. Example:

templates:
  - name: sample
    source: https://github.com/<org>/<repo>/path/template.yml@feature-branch
    type: github

With this change, users can specify the type commit in their templates block, which will automatically fetch the template from the commit associated with the build. Example:

templates:
  - name: sample
    source: path/template.yml
    type: commit

ecrupper avatar Oct 06 '22 21:10 ecrupper

Codecov Report

Merging #713 (68d7183) into main (cd67f9a) will increase coverage by 0.00%. The diff coverage is 54.83%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #713   +/-   ##
=======================================
  Coverage   54.79%   54.79%           
=======================================
  Files         216      216           
  Lines       16015    16046   +31     
=======================================
+ Hits         8776     8793   +17     
- Misses       6857     6869   +12     
- Partials      382      384    +2     
Impacted Files Coverage Δ
compiler/native/expand.go 70.68% <54.83%> (-3.07%) :arrow_down:

codecov[bot] avatar Oct 06 '22 21:10 codecov[bot]

@ecrupper I feel like we should have the type be either github-commit or commit-github incase we want to add additional source code systems in the future.

JordanSussman avatar Oct 07 '22 15:10 JordanSussman

@ecrupper I feel like we should have the type be either github-commit or commit-github incase we want to add additional source code systems in the provider.

Naming is definitely a pain point with this PR 😅 . I agree github should be somewhere in the name. github-commit, github-repo, github-relative, github-local all come to mind...

ecrupper avatar Oct 07 '22 16:10 ecrupper

this would be really nice for local pipeline execution via vela exec pipeline - even without checking code in. but i think the current implementation doesn't suit itself for that. part of the reason i thought this can be scm agnostic and the type be relative or file. thoughts around that?

wass3r avatar Oct 11 '22 15:10 wass3r

this would be really nice for local pipeline execution via vela exec pipeline - even without checking code in. but i think the current implementation doesn't suit itself for that. part of the reason i thought this can be scm agnostic and the type be relative or file. thoughts around that?

Is that what c.local bit does?

https://github.com/go-vela/server/blob/56932446fdc545d44162da499f7318ad34994c77/compiler/native/expand.go#L170-L179

I kind of like relative - but that might suggest that it is relative to the current file vs relative to the repo root. I think I could grow to like file even better. The more I think about this one, I think I like it a lot.

cognifloyd avatar Oct 11 '22 15:10 cognifloyd

Is that what c.local bit does?

busted! forgot about that. 🫣

wass3r avatar Oct 11 '22 15:10 wass3r

@cognifloyd i think your feedback is addressed

@ecrupper we will need to add to docs too

wass3r avatar Dec 13 '22 17:12 wass3r