{"id":17005873,"url":"https://github.com/devatherock/vela-template-tester","last_synced_at":"2025-08-26T11:37:26.464Z","repository":{"id":47617979,"uuid":"268174276","full_name":"devatherock/vela-template-tester","owner":"devatherock","description":"API and plugin to test and validate vela-ci templates ","archived":false,"fork":false,"pushed_at":"2025-03-15T02:21:31.000Z","size":262,"stargazers_count":3,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-15T03:24:39.019Z","etag":null,"topics":["ci","golang","template","vela","vela-ci-templates","vela-template-tester"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devatherock.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-30T23:07:19.000Z","updated_at":"2025-03-02T23:31:13.000Z","dependencies_parsed_at":"2022-09-06T10:22:39.544Z","dependency_job_id":"449b7c2d-5374-486a-8a4a-4db01300e43a","html_url":"https://github.com/devatherock/vela-template-tester","commit_stats":{"total_commits":143,"total_committers":5,"mean_commits":28.6,"dds":0.5034965034965035,"last_synced_commit":"b45d7cd85d8b973c56ad3b28b79cda1948e8449c"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devatherock%2Fvela-template-tester","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devatherock%2Fvela-template-tester/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devatherock%2Fvela-template-tester/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devatherock%2Fvela-template-tester/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devatherock","download_url":"https://codeload.github.com/devatherock/vela-template-tester/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244986362,"owners_count":20543002,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ci","golang","template","vela","vela-ci-templates","vela-template-tester"],"created_at":"2024-10-14T05:04:22.793Z","updated_at":"2025-03-22T16:30:51.864Z","avatar_url":"https://github.com/devatherock.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CircleCI](https://circleci.com/gh/devatherock/vela-template-tester.svg?style=svg)](https://circleci.com/gh/devatherock/vela-template-tester)\n[![Version](https://img.shields.io/docker/v/devatherock/vela-template-tester?sort=semver)](https://hub.docker.com/r/devatherock/vela-template-tester/)\n[![Coverage Status](https://coveralls.io/repos/github/devatherock/vela-template-tester/badge.svg?branch=master)](https://coveralls.io/github/devatherock/vela-template-tester?branch=master)\n[![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=vela-template-tester\u0026metric=alert_status)](https://sonarcloud.io/component_measures?id=vela-template-tester\u0026metric=alert_status\u0026view=list)\n[![Docker Pulls](https://img.shields.io/docker/pulls/devatherock/vela-template-tester.svg)](https://hub.docker.com/r/devatherock/vela-template-tester/)\n[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=vela-template-tester\u0026metric=ncloc)](https://sonarcloud.io/component_measures?id=vela-template-tester\u0026metric=ncloc)\n[![Docker Image Size](https://img.shields.io/docker/image-size/devatherock/vela-template-tester.svg?sort=date)](https://hub.docker.com/r/devatherock/vela-template-tester/)\n# vela-template-tester\nAPI and vela plugin to test and validate [vela-ci templates](https://go-vela.github.io/docs/templates/overview/). The API can also be used to expand any golang/[sprig](https://github.com/Masterminds/sprig) template\n\n## API Reference\n### Key parameters:\n- **Endpoint**: `https://vela-template-tester.onrender.com/api/expandTemplate`\n- **Request Content-Type**: `application/x-yaml`\n- **Response Content-Type**: `application/x-yaml`\n\n### Usage samples\n**Sample valid template payload:**\n\n```yaml\ntemplate: |-\n  metadata:\n    template: true\n\n  slack_plugin_image: \u0026slack_plugin_image\n    image: devatherock/simple-slack:0.2.0\n\n  steps:\n    - name: notify_success\n      ruleset:\n        branch: {{ default \"[ master, v1 ]\" .notification_branch }}\n        event: {{ default \"[ push, tag ]\" .notification_event }}\n      \u003c\u003c: *slack_plugin_image\n      secrets: [ slack_webhook ]\n      parameters:\n        color: \"#33ad7f\"\n        text: |-\n          Success: {{\"{{.BuildLink}}\"}} ({{\"{{.BuildRef}}\"}}) by {{\"{{.BuildAuthor}}\"}}\n          {{\"{{.BuildMessage}}\"}}\nparameters:\n  notification_branch: develop\n```\n\n**Response:**\n\n```yaml\nmessage: template is a valid yaml\ntemplate: |-\n  metadata:\n    template: true\n\n  slack_plugin_image: \u0026slack_plugin_image\n    image: devatherock/simple-slack:0.2.0\n\n  steps:\n    - name: notify_success\n      ruleset:\n        branch: develop\n        event: [ push, tag ]\n      \u003c\u003c: *slack_plugin_image\n      secrets: [ slack_webhook ]\n      parameters:\n        color: \"#33ad7f\"\n        text: |-\n          Success: {{.BuildLink}} ({{.BuildRef}}) by {{.BuildAuthor}}\n          {{.BuildMessage}}\n```\n\n**Sample invalid template payload:**\n\n```yaml\ntemplate: |-\n  metadata:\n    template: true\n\n  steps:\n    - name: notify_success\n      ruleset:\n        branch: {{ default \"[ master, v1 ]\" .notification_branch }}\n        event: {{ default \"[ push, tag ]\" .notification_event }}\n      \u003c\u003c: *slack_plugin_image\n      secrets: [ slack_webhook ]\n      parameters:\n        color: \"#33ad7f\"\n        text: |-\n          Success: {{\"{{.BuildLink}}\"}} ({{\"{{.BuildRef}}\"}}) by {{\"{{.BuildAuthor}}\"}}\n          {{\"{{.BuildMessage}}\"}}\nparameters:\n  notification_branch: develop\n```\n\n**Response:**\n\n```yaml\nmessage: template is not a valid yaml\nerror: 'yaml: unknown anchor ''slack_plugin_image'' referenced'\ntemplate: |-\n  metadata:\n    template: true\n\n  steps:\n    - name: notify_success\n      ruleset:\n        branch: develop\n        event: [ push, tag ]\n      \u003c\u003c: *slack_plugin_image\n      secrets: [ slack_webhook ]\n      parameters:\n        color: \"#33ad7f\"\n        text: |-\n          Success: {{.BuildLink}} ({{.BuildRef}}) by {{.BuildAuthor}}\n          {{.BuildMessage}}\n```\n\n**Sample Starlark template payload:**\n\n```\ntemplate: |-\n  def main(ctx):\n    return {\n        'version': '1',\n        'steps': [\n            {\n                'name': 'build',\n                'image': ctx[\"vars\"][\"image\"],\n                'commands': [\n                    'go build',\n                    'go test',\n                ]\n            },\n        ],\n    }\ntype: starlark    \nparameters:\n  image: \"go:1.16\"\n```\n\n## Plugin Reference\n### Config\nThe following parameters can be set to configure the plugin.\n\n**Parameters**\n* **input_file** - Input template file to test. Optional if `templates` is specified\n* **template_type** - The template type. Needs to be `starlark` if `input_file` is a starlark template\n* **variables** - `vars` to test the template with. Doesn't need to be specified if the template can be tested without variables\n* **expected_output** - File containing the expected output of the template after applying the variables. Optional, if not specified, only the validity of the processed template will be checked\n* **templates** - A list of templates to test. Optional if `input_file` is specified\n* **log_level** - Sets the log level. Set to `debug` to enable debug logs. Optional, defaults to `info`\n\n### Examples\n**Test a single template**\n\n```yaml\nsteps:\n  - name: vela-template-tester\n    ruleset:\n      branch: master\n      event: [ pull_request, push ]\n    image: devatherock/vela-template-tester:latest\n    parameters:\n      input_file: path/to/template.yml\n      variables:\n        notification_branch: develop\n        notification_event: push\n```\n\n**Test a single template with output verification**\n\n```yaml\nsteps:\n  - name: vela-template-tester\n    ruleset:\n      branch: master\n      event: [ pull_request, push ]\n    image: devatherock/vela-template-tester:latest\n    parameters:\n      input_file: path/to/template.yml\n      variables:\n        notification_branch: develop\n        notification_event: push\n      expected_output: samples/output_template.yml\n```\n\n**Test multiple templates**\n\n```yaml\nsteps:\n  - name: vela-template-tester\n    ruleset:\n      branch: master\n      event: [ pull_request, push ]\n    image: devatherock/vela-template-tester:latest\n    parameters:\n      templates:\n        - input_file: path/to/first_template.yml\n          variables:\n            notification_branch: develop\n            notification_event: push\n          expected_output: samples/first_template.yml\n        - input_file: path/to/second_template.yml\n```\n\n## Starlark playground\n\nA vela Starlark template can also be tested using [Starlark playground](https://starpg.onrender.com). We need to specify the template along with the template variables specified within a `ctx` variable and a `print` method call to view the compiled template. Sample usage below:\n\n```\ndef main(ctx):\n  return {\n    'version': '1',\n    'steps': [\n      {\n        'name': 'build',\n        'image': ctx[\"vars\"][\"image\"],\n        'commands': [\n          'go build',\n          'go test',\n        ]\n      },\n    ],\n}\n\nctx = {\n\t\"vars\": {\n\t\t\"image\": \"alpine\"\n\t}\n}\nprint(main(ctx))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevatherock%2Fvela-template-tester","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevatherock%2Fvela-template-tester","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevatherock%2Fvela-template-tester/lists"}