From 7398feade4149cf282e2d2e7c35b06f33de35d27 Mon Sep 17 00:00:00 2001 From: Kanak Singhal Date: Thu, 14 Dec 2023 09:53:52 +0530 Subject: [PATCH 1/2] TER-408 add git workflow doc --- .github/workflows/README.md | 57 +++++++++++++++++++++++++++++ .github/workflows/build-n-push.yaml | 2 +- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/.github/workflows/README.md b/.github/workflows/README.md index e69de29b..06072c58 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -0,0 +1,57 @@ +# Automaton flows on repository + +The Terrarium repo has various automation flows in place. Mainly there are three events that trigger the automation in this repo: + +1. New Pull request +1. Merge to the base branch (main) +1. Create new release tag (v*) + +## 1. New pull request + +The intent of automation pipelines here is to validate the changes coming from the pull requests. + +```mermaid +flowchart LR + Code --> PR --> CH["Checks\nGitHub Action"] + PR --> CLI["CLI test automation\nCode Pipes"] + PR --> API["API test automation\nAZP"] + CH --> UT["Unit Test"] + CH --> ST["Smoke test\nAPI health-check & harvest flow"] +``` + +## 2. Merge to the base branch (main) + +There are two automation intents that run on merge to master: + +### 1. Validation + +This is same as the PR checks, but is important here to ensure sanity of the code merge. + +### 2. Build container images and deploy to staging + +The terrarium repo produces two docker images: + +- **docker.io/cldcvr/terrarium-api** - Terrarium API image is used to deploy the API server. It is based on alpine and contains the go binary for server. +- **docker.io/cldcvr/terrarium-farm-harvester** - Terrarium Harvester image is based on terraform image and contains Terrarium CLI binary built in along with a Makefile that contains sequence of running the terraform harvest commands. + +```mermaid +flowchart LR + Code --> Main --> H["Push harvester image\nGitHub Action\ncldcvr/terrarium-farm-harvester:latest,\ncldcvr/terrarium-farm-harvester:commit_sha"] + H --> F["Used in farm repo"] + Main --> API["Push API Image\nCode Pipes App Integration\ncldcvr/terrarium-api:latest,\ncldcvr/terrarium-api:commit_sha"] + API --> D["Deploy to Staging"] + Main --> C["Unit tests and integration test pipelines"] +``` + +## 3. Create new release tag (v*) + +The release process currently deals with releasing the new version of Terrarium CLI binary. The Terrarium API doesn't have a Prod release (or deployment) setup currently. + +```mermaid +flowchart TD + Code --> PR["Create pre-release\neg tag v1.0.0"] + PR --> A["Build CLI binaries for multiple platforms\nGitHub Action pipeline"] + A --> U["Upload binaries to the GitHub Release"] + U --> GHL["Mark the GitHub release as latest"] + U --> HBL["Update the latest version on Homebrew-tap"] +``` diff --git a/.github/workflows/build-n-push.yaml b/.github/workflows/build-n-push.yaml index 965ed4e8..a00a9bce 100644 --- a/.github/workflows/build-n-push.yaml +++ b/.github/workflows/build-n-push.yaml @@ -1,4 +1,4 @@ -name: Build and Push to DockerHub +name: Push Harvester Image on: push: From 9e338c236888ddb722e381b140837e09cf41ee97 Mon Sep 17 00:00:00 2001 From: Kanak Singhal Date: Tue, 19 Dec 2023 14:57:34 +0530 Subject: [PATCH 2/2] review feedback --- .github/workflows/README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 06072c58..a617a4b7 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -45,7 +45,7 @@ flowchart LR ## 3. Create new release tag (v*) -The release process currently deals with releasing the new version of Terrarium CLI binary. The Terrarium API doesn't have a Prod release (or deployment) setup currently. +The release process currently deals with releasing a new version of Terrarium CLI binary. The Terrarium API doesn't have a Prod release (or deployment) setup currently. ```mermaid flowchart TD @@ -53,5 +53,11 @@ flowchart TD PR --> A["Build CLI binaries for multiple platforms\nGitHub Action pipeline"] A --> U["Upload binaries to the GitHub Release"] U --> GHL["Mark the GitHub release as latest"] - U --> HBL["Update the latest version on Homebrew-tap"] + U --> HBA["Auto generate PR in Homebrew-tap repo\nfrom GitHub action"] + HBA --> HBL["Merge the PR to publish the\n latest CLI version on Homebrew-tap"] ``` + +When creating a new version release in GitHub, mark it as "Pre-release", then wait for the pipelines to finish, and you should see the release assets uploaded. Then make a business decision to publish the release, and do two things to publish the release: + +1. Label the GitHub release as "latest" +2. Merge the auto generated PR in [homebrew-tap](https://github.com/cldcvr/homebrew-tap) repo. - This step is responsible for publishing the new version in Homebrew for all the users that use Homebrew for CLI installation