Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: util/github org supporting #405

Merged
merged 1 commit into from
Apr 11, 2022
Merged

Conversation

daniel-hutao
Copy link
Member

@daniel-hutao daniel-hutao commented Apr 10, 2022

Signed-off-by: Daniel Hu tao.hu@merico.dev

Summary

util/github org supporting

Key Points

  • All plugins github related have been updated
  • All default config print logic updated
  • All plugin docs updated
  • reposcaffolding/githubactions * user/org tested

Test

repo-scaffolding with "user"

  • config file: "config-reposcaffolding.yaml"
tools:
  # name of the instance with github-repo-scaffolding-golang
  - name: go-webapp-repo1
    # name of the plugin
    plugin: github-repo-scaffolding-golang
    # options for the plugin
    options:
      # the repo's owner. It should be case-sensitive here; strictly use your GitHub user name; please change the value below.
      owner: daniel-hutao
      # the repo's org. If you set this property, then the new repo will be created under the org you're given, and the "owner" setting above will be ignored.
      org: ""
      # the repo which you'd like to create; please change the value below.
      repo: go-webapp-repo1
      # the branch of the repo you'd like to hold the code
      branch: main
      # the image repo you'd like to push the container image; please change the value below.
      image_repo: a/b
  • apply ./dtm apply -f config-reposcaffolding.yaml
2022-04-10 12:54:55 ℹ [INFO]  Apply started.
2022-04-10 12:54:55 ℹ [INFO]  Using dir <.devstream> to store plugins.
2022-04-10 12:54:55 ℹ [INFO]  Tool go-webapp-repo1 (github-repo-scaffolding-golang) found in config but doesn't exist in the state, will be created.
Continue? [y/n]
Enter a value (Default is n): y

2022-04-10 12:55:01 ℹ [INFO]  Start executing the plan.
2022-04-10 12:55:01 ℹ [INFO]  Changes count: 1.
2022-04-10 12:55:01 ℹ [INFO]  -------------------- [  Processing progress: 1/1.  ] --------------------
2022-04-10 12:55:01 ℹ [INFO]  Processing: go-webapp-repo1 (github-repo-scaffolding-golang) -> Create ...
2022-04-10 12:55:09 ℹ [INFO]  The repo go-webapp-repo1 has been created.
2022-04-10 12:55:25 ✔ [SUCCESS]  Plugin go-webapp-repo1(github-repo-scaffolding-golang) Create done.
2022-04-10 12:55:25 ℹ [INFO]  -------------------- [  Processing done.  ] --------------------
2022-04-10 12:55:25 ✔ [SUCCESS]  All plugins applied successfully.
2022-04-10 12:55:25 ✔ [SUCCESS]  Apply finished.
  • result

image

  • delete ./dtm delete -f config-reposcaffolding.yaml
2022-04-10 13:00:55 ℹ [INFO]  Delete started.
2022-04-10 13:00:55 ℹ [INFO]  Using dir <.devstream> to store plugins.
2022-04-10 13:00:55 ℹ [INFO]  Tool go-webapp-repo1 (github-repo-scaffolding-golang) will be deleted.
Continue? [y/n]
Enter a value (Default is n): y

2022-04-10 13:00:56 ℹ [INFO]  Start executing the plan.
2022-04-10 13:00:56 ℹ [INFO]  Changes count: 1.
2022-04-10 13:00:56 ℹ [INFO]  -------------------- [  Processing progress: 1/1.  ] --------------------
2022-04-10 13:00:56 ℹ [INFO]  Processing: go-webapp-repo1 (github-repo-scaffolding-golang) -> Delete ...
2022-04-10 13:01:04 ✔ [SUCCESS]  GitHub repo go-webapp-repo1 removed.
2022-04-10 13:01:04 ℹ [INFO]  Prepare to delete 'go-webapp-repo1_github-repo-scaffolding-golang' from States.
2022-04-10 13:01:04 ✔ [SUCCESS]  Plugin go-webapp-repo1 (github-repo-scaffolding-golang) delete done.
2022-04-10 13:01:04 ℹ [INFO]  -------------------- [  Processing done.  ] --------------------
2022-04-10 13:01:04 ✔ [SUCCESS]  All plugins deleted successfully.
2022-04-10 13:01:04 ✔ [SUCCESS]  Delete finished.

repo-scaffolding with "org"

  • config file:
tools:
  # name of the instance with github-repo-scaffolding-golang
  - name: go-webapp-repo1
    # name of the plugin
    plugin: github-repo-scaffolding-golang
    # options for the plugin
    options:
      # the repo's owner. It should be case-sensitive here; strictly use your GitHub user name; please change the value below.
      owner: ""
      # the repo's org. If you set this property, then the new repo will be created under the org you're given, and the "owner" setting above will be ignored.
      org: devstream-io
      # the repo which you'd like to create; please change the value below.
      repo: go-webapp-repo1
      # the branch of the repo you'd like to hold the code
      branch: main
      # the image repo you'd like to push the container image; please change the value below.
      image_repo: a/b
  • apply ./dtm apply -f config-reposcaffolding.yaml -y
2022-04-10 13:48:46 ℹ [INFO]  Apply started.
2022-04-10 13:48:46 ℹ [INFO]  Using dir <.devstream> to store plugins.
2022-04-10 13:48:46 ℹ [INFO]  Tool go-webapp-repo1 (github-repo-scaffolding-golang) found in config but doesn't exist in the state, will be created.
2022-04-10 13:48:46 ℹ [INFO]  Start executing the plan.
2022-04-10 13:48:46 ℹ [INFO]  Changes count: 1.
2022-04-10 13:48:46 ℹ [INFO]  -------------------- [  Processing progress: 1/1.  ] --------------------
2022-04-10 13:48:46 ℹ [INFO]  Processing: go-webapp-repo1 (github-repo-scaffolding-golang) -> Create ...
2022-04-10 13:48:47 ℹ [INFO]  Prepare to create an organization repository: devstream-io
2022-04-10 13:48:49 ℹ [INFO]  The repo go-webapp-repo1 has been created.
2022-04-10 13:49:03 ✔ [SUCCESS]  Plugin go-webapp-repo1(github-repo-scaffolding-golang) Create done.
2022-04-10 13:49:03 ℹ [INFO]  -------------------- [  Processing done.  ] --------------------
2022-04-10 13:49:03 ✔ [SUCCESS]  All plugins applied successfully.
2022-04-10 13:49:03 ✔ [SUCCESS]  Apply finished.
  • result

image

  • delete ./dtm delete -f config-reposcaffolding.yaml -y
2022-04-10 13:50:53 ℹ [INFO]  Delete started.
2022-04-10 13:50:53 ℹ [INFO]  Using dir <.devstream> to store plugins.
2022-04-10 13:50:53 ℹ [INFO]  Tool go-webapp-repo1 (github-repo-scaffolding-golang) will be deleted.
2022-04-10 13:50:53 ℹ [INFO]  Start executing the plan.
2022-04-10 13:50:53 ℹ [INFO]  Changes count: 1.
2022-04-10 13:50:53 ℹ [INFO]  -------------------- [  Processing progress: 1/1.  ] --------------------
2022-04-10 13:50:53 ℹ [INFO]  Processing: go-webapp-repo1 (github-repo-scaffolding-golang) -> Delete ...
2022-04-10 13:50:54 ✔ [SUCCESS]  GitHub repo go-webapp-repo1 removed.
2022-04-10 13:50:54 ℹ [INFO]  Prepare to delete 'go-webapp-repo1_github-repo-scaffolding-golang' from States.
2022-04-10 13:50:54 ✔ [SUCCESS]  Plugin go-webapp-repo1 (github-repo-scaffolding-golang) delete done.
2022-04-10 13:50:54 ℹ [INFO]  -------------------- [  Processing done.  ] --------------------
2022-04-10 13:50:54 ✔ [SUCCESS]  All plugins deleted successfully.
2022-04-10 13:50:54 ✔ [SUCCESS]  Delete finished.

actions with "org"

  • config file:
tools:
- name: golang-demo-app
  # name of the plugin
  plugin: githubactions-golang
  # optional; if specified, dtm will make sure the dependency is applied first before handling this tool.
  dependsOn: []
  # options for the plugin
  options:
    # the repo's owner. It should be case-sensitive here; strictly use your GitHub user name; please change the value below.
    owner: ""
    # the repo where you'd like to setup GitHub Actions; please change the value below to an existing repo.
    # the repo's org. If you set this property, then the new repo will be created under the org you're given, and the "owner" setting above will be ignored.
    org: devstream-io
    repo: go-webapp-repo1
    # programming language specific settings
    language:
      name: go
      # version of the language
      version: "1.17"
    # main branch of the repo (to which branch the plugin will submit the workflows)
    branch: main
    build:
      # default to false
      enable: True
      # build command, OPTIONAL, the given value below is default value
      command: "go build ./..."
    test:
      # default to false
      enable: True
      # test command, OPTIONAL, the given value below is default value
      command: "go test ./..."
      coverage:
        # default to false
        enable: False
        # go test profile subcommand, OPTIONAL, the given value below is default value
        profile: "-race -covermode=atomic"
        output: "coverage.out"
    docker:
      # docker build/push related, default to false
      enable: False
      # dockerhub image repo; please change the value below.
      repo: abc
  • apply ./dtm apply -f config-actions.yaml -y
2022-04-10 13:55:05 ℹ [INFO]  Apply started.
2022-04-10 13:55:05 ℹ [INFO]  Using dir <.devstream> to store plugins.
2022-04-10 13:55:05 ℹ [INFO]  Tool golang-demo-app (githubactions-golang) found in config but doesn't exist in the state, will be created.
2022-04-10 13:55:05 ℹ [INFO]  Start executing the plan.
2022-04-10 13:55:05 ℹ [INFO]  Changes count: 1.
2022-04-10 13:55:05 ℹ [INFO]  -------------------- [  Processing progress: 1/1.  ] --------------------
2022-04-10 13:55:05 ℹ [INFO]  Processing: golang-demo-app (githubactions-golang) -> Create ...
2022-04-10 13:55:06 ℹ [INFO]  Creating GitHub Actions workflow pr-builder.yml ...
2022-04-10 13:55:06 ✔ [SUCCESS]  Github Actions workflow pr-builder.yml created.
2022-04-10 13:55:07 ℹ [INFO]  Creating GitHub Actions workflow main-builder.yml ...
2022-04-10 13:55:07 ✔ [SUCCESS]  Github Actions workflow main-builder.yml created.
2022-04-10 13:55:07 ✔ [SUCCESS]  Plugin golang-demo-app(githubactions-golang) Create done.
2022-04-10 13:55:07 ℹ [INFO]  -------------------- [  Processing done.  ] --------------------
2022-04-10 13:55:07 ✔ [SUCCESS]  All plugins applied successfully.
2022-04-10 13:55:07 ✔ [SUCCESS]  Apply finished.
  • result

image

  • delete ./dtm delete -f config-actions.yaml -y
2022-04-10 13:57:11 ℹ [INFO]  Delete started.
2022-04-10 13:57:11 ℹ [INFO]  Using dir <.devstream> to store plugins.
2022-04-10 13:57:11 ℹ [INFO]  Tool golang-demo-app (githubactions-golang) will be deleted.
2022-04-10 13:57:11 ℹ [INFO]  Start executing the plan.
2022-04-10 13:57:11 ℹ [INFO]  Changes count: 1.
2022-04-10 13:57:11 ℹ [INFO]  -------------------- [  Processing progress: 1/1.  ] --------------------
2022-04-10 13:57:11 ℹ [INFO]  Processing: golang-demo-app (githubactions-golang) -> Delete ...
2022-04-10 13:57:11 ℹ [INFO]  Deleting GitHub Actions workflow pr-builder.yml ...
2022-04-10 13:57:12 ✔ [SUCCESS]  GitHub Actions workflow pr-builder.yml removed.
2022-04-10 13:57:12 ℹ [INFO]  Deleting GitHub Actions workflow main-builder.yml ...
2022-04-10 13:57:13 ✔ [SUCCESS]  GitHub Actions workflow main-builder.yml removed.
2022-04-10 13:57:13 ℹ [INFO]  Prepare to delete 'golang-demo-app_githubactions-golang' from States.
2022-04-10 13:57:13 ✔ [SUCCESS]  Plugin golang-demo-app (githubactions-golang) delete done.
2022-04-10 13:57:13 ℹ [INFO]  -------------------- [  Processing done.  ] --------------------
2022-04-10 13:57:13 ✔ [SUCCESS]  All plugins deleted successfully.
2022-04-10 13:57:13 ✔ [SUCCESS]  Delete finished.

actions with "user"

  • config file
tools:
- name: golang-demo-app
  # name of the plugin
  plugin: githubactions-golang
  # optional; if specified, dtm will make sure the dependency is applied first before handling this tool.
  dependsOn: []
  # options for the plugin
  options:
    # the repo's owner. It should be case-sensitive here; strictly use your GitHub user name; please change the value below.
    owner: daniel-hutao
    # the repo where you'd like to setup GitHub Actions; please change the value below to an existing repo.
    # the repo's org. If you set this property, then the new repo will be created under the org you're given, and the "owner" setting above will be ignored.
    org: ""
    repo: go-webapp-repo1
    # programming language specific settings
    language:
      name: go
      # version of the language
      version: "1.17"
    # main branch of the repo (to which branch the plugin will submit the workflows)
    branch: main
    build:
      # default to false
      enable: True
      # build command, OPTIONAL, the given value below is default value
      command: "go build ./..."
    test:
      # default to false
      enable: True
      # test command, OPTIONAL, the given value below is default value
      command: "go test ./..."
      coverage:
        # default to false
        enable: False
        # go test profile subcommand, OPTIONAL, the given value below is default value
        profile: "-race -covermode=atomic"
        output: "coverage.out"
    docker:
      # docker build/push related, default to false
      enable: False
      # dockerhub image repo; please change the value below.
      repo: abc
  • apply ./dtm apply -f config-actions.yaml -y
2022-04-10 13:59:39 ℹ [INFO]  Apply started.
2022-04-10 13:59:39 ℹ [INFO]  Using dir <.devstream> to store plugins.
2022-04-10 13:59:39 ℹ [INFO]  Tool golang-demo-app (githubactions-golang) found in config but doesn't exist in the state, will be created.
2022-04-10 13:59:39 ℹ [INFO]  Start executing the plan.
2022-04-10 13:59:39 ℹ [INFO]  Changes count: 1.
2022-04-10 13:59:39 ℹ [INFO]  -------------------- [  Processing progress: 1/1.  ] --------------------
2022-04-10 13:59:39 ℹ [INFO]  Processing: golang-demo-app (githubactions-golang) -> Create ...
2022-04-10 13:59:40 ℹ [INFO]  Creating GitHub Actions workflow pr-builder.yml ...
2022-04-10 13:59:41 ✔ [SUCCESS]  Github Actions workflow pr-builder.yml created.
2022-04-10 13:59:41 ℹ [INFO]  Creating GitHub Actions workflow main-builder.yml ...
2022-04-10 13:59:42 ✔ [SUCCESS]  Github Actions workflow main-builder.yml created.
2022-04-10 13:59:42 ✔ [SUCCESS]  Plugin golang-demo-app(githubactions-golang) Create done.
2022-04-10 13:59:42 ℹ [INFO]  -------------------- [  Processing done.  ] --------------------
2022-04-10 13:59:42 ✔ [SUCCESS]  All plugins applied successfully.
2022-04-10 13:59:42 ✔ [SUCCESS]  Apply finished.
  • result

image

  • delete ./dtm delete -f config-actions.yaml -y
2022-04-10 14:01:21 ℹ [INFO]  Delete started.
2022-04-10 14:01:21 ℹ [INFO]  Using dir <.devstream> to store plugins.
2022-04-10 14:01:21 ℹ [INFO]  Tool golang-demo-app (githubactions-golang) will be deleted.
2022-04-10 14:01:21 ℹ [INFO]  Start executing the plan.
2022-04-10 14:01:21 ℹ [INFO]  Changes count: 1.
2022-04-10 14:01:21 ℹ [INFO]  -------------------- [  Processing progress: 1/1.  ] --------------------
2022-04-10 14:01:21 ℹ [INFO]  Processing: golang-demo-app (githubactions-golang) -> Delete ...
2022-04-10 14:01:23 ℹ [INFO]  Deleting GitHub Actions workflow pr-builder.yml ...
2022-04-10 14:01:23 ✔ [SUCCESS]  GitHub Actions workflow pr-builder.yml removed.
2022-04-10 14:01:24 ℹ [INFO]  Deleting GitHub Actions workflow main-builder.yml ...
2022-04-10 14:01:24 ✔ [SUCCESS]  GitHub Actions workflow main-builder.yml removed.
2022-04-10 14:01:24 ℹ [INFO]  Prepare to delete 'golang-demo-app_githubactions-golang' from States.
2022-04-10 14:01:24 ✔ [SUCCESS]  Plugin golang-demo-app (githubactions-golang) delete done.
2022-04-10 14:01:24 ℹ [INFO]  -------------------- [  Processing done.  ] --------------------
2022-04-10 14:01:24 ✔ [SUCCESS]  All plugins deleted successfully.
2022-04-10 14:01:24 ✔ [SUCCESS]  Delete finished.

Signed-off-by: Daniel Hu <tao.hu@merico.dev>
@daniel-hutao daniel-hutao marked this pull request as ready for review April 10, 2022 06:07
@daniel-hutao daniel-hutao self-assigned this Apr 11, 2022
@IronCore864 IronCore864 merged commit 4c927b1 into devstream-io:main Apr 11, 2022
@IronCore864 IronCore864 deleted the feat-gh branch April 11, 2022 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants