From 078bad08e43f6a8b7aa1edfd7668c70c457cc736 Mon Sep 17 00:00:00 2001 From: Kris De Volder Date: Wed, 21 Dec 2016 19:00:26 -0800 Subject: [PATCH] Concourse: support for 'groups' attribute --- .../vscode/concourse/PipelineYmlSchema.java | 7 +++ .../src/main/resources/desc/Group/jobs.md | 1 + .../src/main/resources/desc/Group/name.md | 1 + .../main/resources/desc/Group/resources.md | 1 + .../main/resources/desc/Pipeline/groups.md | 21 +++++++++ .../concourse/PipelineYamlEditorTest.java | 46 ++++++++++++++++++- 6 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/Group/jobs.md create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/Group/name.md create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/Group/resources.md create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/Pipeline/groups.md diff --git a/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java b/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java index ba3501813..60a23219b 100644 --- a/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java +++ b/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java @@ -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)); } diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/Group/jobs.md b/vscode-extensions/vscode-concourse/src/main/resources/desc/Group/jobs.md new file mode 100644 index 000000000..4b6d86fa1 --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/Group/jobs.md @@ -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. \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/Group/name.md b/vscode-extensions/vscode-concourse/src/main/resources/desc/Group/name.md new file mode 100644 index 000000000..b30efbf64 --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/Group/name.md @@ -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. \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/Group/resources.md b/vscode-extensions/vscode-concourse/src/main/resources/desc/Group/resources.md new file mode 100644 index 000000000..654156983 --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/Group/resources.md @@ -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. \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/Pipeline/groups.md b/vscode-extensions/vscode-concourse/src/main/resources/desc/Pipeline/groups.md new file mode 100644 index 000000000..ca5c424f2 --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/Pipeline/groups.md @@ -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/). + diff --git a/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/concourse/PipelineYamlEditorTest.java b/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/concourse/PipelineYamlEditorTest.java index a802a761b..dcf47796d 100644 --- a/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/concourse/PipelineYamlEditorTest.java +++ b/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/concourse/PipelineYamlEditorTest.java @@ -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(