Concourse: support for 'groups' attribute

This commit is contained in:
Kris De Volder
2016-12-21 19:00:26 -08:00
parent 9fd2026b7e
commit 078bad08e4
6 changed files with 76 additions and 1 deletions

View File

@@ -172,14 +172,21 @@ public class PipelineYmlSchema implements YamlSchema {
prop(job, "plan", f.yseq(step));
YType resource_type_def = f.ybean("ResourceTypeDef",
//TODO: This way of initializing the props doesn't attach descriptions!
f.yprop("name", t_ne_string),
f.yprop("type", t_image_type),
f.yprop("source", t_any)
);
YBeanType group = f.ybean("Group");
prop(group, "name", t_ne_string);
prop(group, "resources", f.yseq(resourceName));
prop(group, "jobs", f.yseq(jobName));
prop(TOPLEVEL_TYPE, "resources", f.yseq(resource));
prop(TOPLEVEL_TYPE, "jobs", f.yseq(job));
prop(TOPLEVEL_TYPE, "resource_types", f.yseq(resource_type_def));
prop(TOPLEVEL_TYPE, "groups", f.yseq(group));
}

View File

@@ -0,0 +1 @@
*Optional.* A list of jobs that should appear in this group. A job may appear in multiple groups. Neighbours of jobs in the current group will also appear on the same page in order to give context of the location of the group in the pipeline.

View File

@@ -0,0 +1 @@
*Required.* The name of the group. This should be short and simple as it will be used as the tab name for navigation.

View File

@@ -0,0 +1 @@
*Optional.* A list of resources that should appear in this group. Resources that are inputs or outputs of jobs in the group are automatically added; they do not have to be explicitly listed here.

View File

@@ -0,0 +1,21 @@
Splitting up your pipeline into sections.
A pipeline may optionally contain a section called `groups`. As more resources and jobs are added to a pipeline it can become difficult to navigate. Pipeline groups allow you to group jobs together under a header and have them show on different tabs in the user interface. Groups have no functional effect on your pipeline.
A simple grouping for the pipeline above may look like:
groups:
- name: tests
jobs:
- controller-mysql
- controller-postgres
- worker
- integration
- name: deploy
jobs:
- deploy
This would display two tabs at the top of the home page: "tests" and "deploy". Once you have added groups to your pipeline then all jobs must be in a group otherwise they will not be visible.
For a real world example of how groups can be used to simplify navigation and provide logical grouping, see the groups used at the top of the page in the [Concourse pipeline](https://ci.concourse.ci/).

View File

@@ -233,6 +233,19 @@ public class PipelineYamlEditorTest {
editor.assertHoverContains("ensure", "a second step to execute regardless of the result of the parent step");
}
@Test
public void groupHovers() throws Exception {
Editor editor = harness.newEditor(
"groups:\n" +
"- name: some-group\n" +
" resources: []\n" +
" jobs: []\n"
);
editor.assertHoverContains("name", "The name of the group");
editor.assertHoverContains("resources", "A list of resources that should appear in this group");
editor.assertHoverContains("jobs", " A list of jobs that should appear in this group");
}
@Test
public void taskStepHovers() throws Exception {
Editor editor = harness.newEditor(
@@ -342,6 +355,9 @@ public class PipelineYamlEditorTest {
Editor editor;
editor = harness.newEditor(CURSOR);
editor.assertCompletions(
"groups:\n" +
"- <*>"
, // --------------
"jobs:\n" +
"- <*>"
, // ---------------
@@ -421,12 +437,15 @@ public class PipelineYamlEditorTest {
" params:\n" +
" build: docker-git/concourse/docker\n" +
" get_params: \n" +
" skip_download: true\n"
" skip_download: true\n" +
"groups:\n" +
"- name: a-groups\n"
);
editor.assertHoverContains("resource_types", "each pipeline can configure its own custom types by specifying `resource_types` at the top level.");
editor.assertHoverContains("resources", "A resource is any entity that can be checked for new versions");
editor.assertHoverContains("jobs", "At a high level, a job describes some actions to perform");
editor.assertHoverContains("groups", "A pipeline may optionally contain a section called `groups`");
}
@Test
@@ -535,6 +554,31 @@ public class PipelineYamlEditorTest {
editor.assertProblems("not-a-job|does not exist");
}
@Test
public void reconcileGroups() throws Exception {
Editor editor = harness.newEditor(
"resources:\n" +
"- name: git-repo\n" +
"- name: build-artefact\n" +
"jobs:\n" +
"- name: build\n" +
" plan:\n" +
" - get: git-repo\n" +
" - task: run-build\n" +
" - put: build-artefact\n" +
"- name: test\n" +
" plan:\n" +
" - get: git-repo\n" +
"groups:\n" +
"- name: some-group\n" +
" jobs: [build, test, bogus-job]\n" +
" resources: [git-repo, build-artefact, not-a-resource]"
);
editor.assertProblems("bogus-job|does not exist");
editor.assertProblems("not-a-resource|does not exist");
}
@Test
public void contentAssistJobNames() throws Exception {
assertContextualCompletions(