Skip to content

Commit

Permalink
internal/ci: remove workflow files pre generate
Browse files Browse the repository at this point in the history
This ensures we can never have any stale .yml files lying around.

Signed-off-by: Paul Jolly <paul@myitcv.io>
Change-Id: Ia479aabc86a0643a368a447864a59f1f68047e2b
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/551625
Unity-Result: CUEcueckoo <cueckoo@cuelang.org>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
  • Loading branch information
myitcv committed Mar 26, 2023
1 parent 87db1a5 commit b418955
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions internal/ci/ci_tool.cue
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,29 @@ _goos: string @tag(os,var=os)
// See internal/ci/gen.go for details on how this step fits into the sequence
// of generating our CI workflow definitions, and updating various txtar tests
// with files from that process.
command: gen: workflows: {
for _workflowName, _workflow in github.workflows {
let _filename = _workflowName + ".yml"
(_filename): file.Create & {
_dir: path.FromSlash("../../.github/workflows", path.Unix)
filename: path.Join([_dir, _filename], _goos)
let donotedit = base.#doNotEditMessage & {#generatedBy: "internal/ci/ci_tool.cue", _}
contents: "# \(donotedit)\n\n\(yaml.Marshal(_workflow))"
command: gen: {
_dir: path.FromSlash("../../.github/workflows", path.Unix)

workflows: {
remove: {
glob: file.Glob & {
glob: path.Join([_dir, "*.yml"], _goos)
files: [...string]
}
for _, _filename in glob.files {
"delete \(_filename)": file.RemoveAll & {
path: _filename
}
}
}
for _workflowName, _workflow in github.workflows {
let _filename = _workflowName + ".yml"
"generate \(_filename)": file.Create & {
$after: [ for v in remove {v}]
filename: path.Join([_dir, _filename], _goos)
let donotedit = base.#doNotEditMessage & {#generatedBy: "internal/ci/ci_tool.cue", _}
contents: "# \(donotedit)\n\n\(yaml.Marshal(_workflow))"
}
}
}
}
Expand Down

0 comments on commit b418955

Please sign in to comment.