devstream icon indicating copy to clipboard operation
devstream copied to clipboard

:four_leaf_clover: `Proposal`: New Config format for github/gitlab aciton

Open steinliber opened this issue 2 years ago • 1 comments

What Would You Like to Add? Why Is This Needed?

Current github action and gitlab ci are all different, we can use a unified config for them。

- name: githubactions-golang
  instanceID: default
  dependsOn: [ ]
  options:
    owner: YOUR_GITHUB_USERNAME
    org: YOUR_ORGANIZATION_NAME
    repo: YOUR_REPO_NAME
    language:
      name: go
      version: "1.18"
    branch: main
    build:
      enable: True
      command: "go build ./..."
    test:
      enable: True
      command: "go test ./..."
      coverage:
        enable: False
        profile: "-race -covermode=atomic"
        output: "coverage.out"
    docker:
      enable: True
      registry:
        type: dockerhub
        username: YOUR_DOCKERHUB_USERNAME
        repository: YOUR_DOCKERHUB_REPOSITORY
  - name: gitlabci-golang
    # id of the tool instance
    instanceID: default
    # format: name.instanceID; If specified, dtm will make sure the dependency is applied first before handling this tool.
    dependsOn: [ ]
    # options for the plugin
    options:
      # owner/repo; "path with namespace" is only GitLab API's way of saying the same thing; please change the values below.
      pathWithNamespace: YOUR_GITLAB_USERNAME/YOUR_GITLAB_REPO_NAME
      # main branch of the repo (to which branch the plugin will submit the workflows)
      branch: main

Design

we can use a unified config for them.

- name: githubactions-golang
  instanceID: default
  dependsOn: [ ]
  options:
    repo:
      owner: YOUR_GITHUB_USERNAME
      org: YOUR_ORGANIZATION_NAME
      repo: YOUR_REPO_NAME
      branch: main
    ci:
      build:
        enable: True
      test:
        enable: True
        coverage:
          enable: True
    registry:
      type: dockerhub
      username: YOUR_DOCKERHUB_USERNAME
      repository: YOUR_DOCKERHUB_REPOSITORY
- name: gitlabci-golang
  instanceID: default
  dependsOn: [ ]
  options:
    repo:
      owner: YOUR_GITLAB_USERNAME
      org: YOUR_ORGANIZATION_NAME
      repo: YOUR_REPO_NAME
      branch: main
    ci:
      build:
        enable: True
      test:
        enable: True
        coverage:
          enable: True
    registry:
      type: dockerhub
      username: YOUR_DOCKERHUB_USERNAME
      repository: YOUR_DOCKERHUB_REPOSITORY

Anything else

steinliber avatar Aug 05 '22 06:08 steinliber

Min Config

I would like to propose a minimum possible config for users to get started ASAP, with many defaults:

- name: githubactions-golang
  instanceID: default
  options:
    repoOwner: YOUR_GITHUB_USERNAME
    repoName: YOUR_REPO_NAME

Explanations:

  • Build, and test is enabled by default; we can set "make build", "make test" as the default build/test command, so that it's compatible with all languages
  • Test coverage (when possible) is also enabled by default
  • Docker build/push is not enabled because the user didn't input docker-related options.

There are fewer indentations, so it's more readable and less likely to get wrong.


Enable Docker Build/Push

If the user wants to enable docker build/push:

- name: githubactions-golang
  instanceID: default
  options:
    repoOwner: YOUR_GITHUB_USERNAME
    repoName: YOUR_REPO_NAME
    imageRegistryType: dockerhub
    imageRegistry: YOUR_DOCKERHUB_USERNAME/YOUR_DOCKERHUB_REPOSITORY

Basically, this is the min config plus two options. Notice that the docker hub user and repo are merged into one config to further simplify things.


Non Defaults Maximum Configuration

If user wants to override non-defaults:

- name: githubactions-golang
  instanceID: default
  dependsOn: []
  options:
    # repoOwner or org, must have one, and only one
    repoOwner: YOUR_GITHUB_USERNAME
    org: some_org
    repoName: YOUR_REPO_NAME
    # disable build
    buildEnabled: False
    # use non-default build command (default build command should be `make build`
    buildCommand: some non-default command
    # disable test
    testEnabled: False
    # defaults to `make test`
    testCommand: some non-default test command
    # defaults to true
    testCoverage: false
    imageRegistryType: dockerhub
    imageRegistry: YOUR_DOCKERHUB_USERNAME/YOUR_DOCKERHUB_REPOSITORY

IronCore864 avatar Aug 05 '22 07:08 IronCore864