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

updated support for CI/CD #134

Merged
merged 8 commits into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/env-release-nucleus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Release to Environment Nucleus
on:
workflow_dispatch:
inputs:
environment:
description: 'Environment to Deploy'
required: true
type: choice
options:
- beta
- prod
version:
description: 'Version to be Published'
required: true
type: string

jobs:
env-release:

runs-on: ubuntu-latest

steps:

- name: Docker Login
uses: docker/login-action@v1.13.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
logout: true

- name: Setup Environment
run: |
echo "BOTNAME=Test-at-Scale Nucleus Promoted: Version ${ENVIRONMENT} to ${VERSION}" >> $GITHUB_ENV
if [ ${ENVIRONMENT} == "prod" ] ; then
echo "IMAGE_TAG=latest-base" >> $GITHUB_ENV
else
echo "IMAGE_TAG=${ENVIRONMENT}-base" >> $GITHUB_ENV
fi
env:
ENVIRONMENT: ${{ github.event.inputs.environment }}
VERSION: ${{ github.event.inputs.version }}

- name: Promote Docker Image
run: |
docker pull lambdatest/nucleus:${VERSION}-base
docker tag lambdatest/nucleus:${VERSION}-base lambdatest/nucleus:${{ env.IMAGE_TAG }}
docker push lambdatest/nucleus:${{ env.IMAGE_TAG }}
env:
VERSION: ${{ github.event.inputs.version }}

- if: startsWith(matrix.label, 'release:')
name: Build Cloud Runners
run: |
gh workflow run -R ${{ secrets.WF_REPO }} ${{ secrets.WF_NAME }} -r main -f environment=${ENVIRONMENT} -f version=${{ steps.tag_version.outputs.new_tag }}
env:
GITHUB_TOKEN: ${{secrets.GH_API_TOKEN}}
ENVIRONMENT: ${{ github.event.inputs.environment }}
50 changes: 50 additions & 0 deletions .github/workflows/env-release-synapse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Release to Environment Synapse
on:
workflow_dispatch:
inputs:
environment:
description: 'Environment to Deploy'
required: true
type: choice
options:
- beta
- prod
version:
description: 'Version to be Published'
required: true
type: string

jobs:
env-release:

runs-on: ubuntu-latest

steps:

- name: Docker Login
uses: docker/login-action@v1.13.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
logout: true

- name: Setup Environment
run: |
echo "BOTNAME=Test-at-Scale Synapse Promoted: Version ${ENVIRONMENT} to ${VERSION}" >> $GITHUB_ENV
if [ ${ENVIRONMENT} == "prod" ] ; then
echo "IMAGE_TAG=latest" >> $GITHUB_ENV
else
echo "IMAGE_TAG=${ENVIRONMENT}" >> $GITHUB_ENV
fi
env:
ENVIRONMENT: ${{ github.event.inputs.environment }}
VERSION: ${{ github.event.inputs.version }}

- name: Promote Docker Image
run: |
docker pull lambdatest/synapse:${VERSION}
docker tag lambdatest/synapse:${VERSION} lambdatest/synapse:${{ env.IMAGE_TAG }}
docker push lambdatest/synapse:${{ env.IMAGE_TAG }}
env:
ENVIRONMENT: ${{ github.event.inputs.environment }}
VERSION: ${{ github.event.inputs.version }}
24 changes: 0 additions & 24 deletions .github/workflows/golangci-lint.yml

This file was deleted.

117 changes: 51 additions & 66 deletions .github/workflows/main.yml → .github/workflows/premerge.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,95 @@
name: Go report card & Test coverage
name: CI

on:
push:
branches:
- main
- beta
- dev
tags: [ 'v*.*.*' ]

pull_request:
branches:
- main
- beta
- dev

workflow_dispatch:
jobs:

env:
REGISTRY_NAME: lambdatest
Linting:

name: Golang CI - Linting
runs-on: ubuntu-latest

steps:

- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16

- name: Checkout code
uses: actions/checkout@v2

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v2.5.2
with:
version: latest
# skip cache because of flaky behaviors
skip-build-cache: true
skip-pkg-cache: true
skip-go-installation: true
only-new-issues: true
args: --skip-dirs=pkg/docs --timeout=3m

jobs:
Unit_Test_Cases:

name: Unit Test Cases
runs-on: ubuntu-latest
needs: [ Linting ]

steps:

- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Checkout code
uses: actions/checkout@v2

- name: Unit Test Cases
env:
ENV: "dev"
run: go test ./... -parallel 4

Performance_Test_Cases:

name: Performance Test Cases
runs-on: ubuntu-latest
needs: [ Linting ]

steps:

- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Checkout code
uses: actions/checkout@v2

- name: Performance Test Cases
env:
ENV: "dev"
run: go test ./... -parallel 4 -bench=. -benchmem

Test_Coverage:

name: Test Coverage
runs-on: ubuntu-latest
needs: [ Unit_Test_Cases, Performance_Test_Cases ]

steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Checkout code
uses: actions/checkout@v2

- name: Test Code Coverage
env:
ENV: "dev"
Expand All @@ -66,15 +98,20 @@ jobs:
go tool cover -func profile.cov

Go_Report_Card:

name: Go Report Card
runs-on: ubuntu-latest
needs: [ Unit_Test_Cases, Performance_Test_Cases ]

steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Checkout code
uses: actions/checkout@v2

- name: Run Go Report Card
run: |
issues_threshold=13
Expand Down Expand Up @@ -119,55 +156,3 @@ jobs:
else
exit 0
fi

Build_To_Deploy:
if: ${{ github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
needs: [ Test_Coverage, Go_Report_Card ]
steps:
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v3.x

- name: Checkout
uses: actions/checkout@v2.4.0

- name: Build Cloud Runners
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/dev' }}
run: |
curl -X POST "https://api.github.com/repos/LambdaTest/test-at-scale-deployment/actions/workflows/main.yml/dispatches" -H "Authorization:Bearer ${{ secrets.GH_API_TOKEN }}" -d '{"ref":"${{env.GITHUB_REF_SLUG}}"}'

- name: Setup Docker Image Tags
run: |
if [ ${GITHUB_REF_SLUG} == "main" ] ; then
echo "NUCLEUS_TAGS=${REGISTRY_NAME}/nucleus:base" >> $GITHUB_ENV
echo "SYNAPSE_TAGS=${REGISTRY_NAME}/synapse:latest","${REGISTRY_NAME}/synapse:prod" >> $GITHUB_ENV
else
echo "NUCLEUS_TAGS=${REGISTRY_NAME}/nucleus:base-${GITHUB_REF_SLUG}" >> $GITHUB_ENV
echo "SYNAPSE_TAGS=${REGISTRY_NAME}/synapse:${GITHUB_REF_SLUG}" >> $GITHUB_ENV
fi

- name: Docker Login
uses: docker/login-action@v1.13.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
logout: true

- name: Build and push Nucleus images
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/dev' || startsWith(github.ref, 'refs/tags/v') }}
uses: docker/build-push-action@v2.9.0
with:
context: .
tags: ${{ env.NUCLEUS_TAGS }}
file: build/nucleus/Dockerfile
push: true

- name: Build and push Synapse images
if: ${{ github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
uses: docker/build-push-action@v2.9.0
with:
context: .
tags: ${{ env.SYNAPSE_TAGS }}
file: build/synapse/Dockerfile
push: true

70 changes: 70 additions & 0 deletions .github/workflows/release-patch-wf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# This workflow will release a new patch version of nucleus and synapse
name: Release Patch Version

on:
workflow_dispatch:

jobs:

Release:

runs-on: ubuntu-latest

steps:

- name: Retrieving Release Type
run: |
echo "RELEASE_TYPE=patch" >> $GITHUB_ENV
echo "Releasing: ${release_type}"

- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v3.x

- name: Checkout
uses: actions/checkout@v2.4.0

- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
default_bump: ${{ env.RELEASE_TYPE }}

- if: startsWith(matrix.label, 'release:')
name: Build Cloud Runners
run: |
gh workflow run -R ${{ secrets.WF_REPO }} ${{ secrets.WF_NAME }} -r main -f environment=dev -f version=${{ steps.tag_version.outputs.new_tag }}
env:
GITHUB_TOKEN: ${{secrets.GH_API_TOKEN}}

- name: Setup Environment
run: |
echo "BOTNAME=Test-at-Scale Deployment Status: Version ${{ steps.tag_version.outputs.new_tag }} to dev" >> $GITHUB_ENV

- name: Setup Docker Image Tags
run: |
echo "NUCLEUS_TAGS=lambdatest/nucleus:dev-base","lambdatest/nucleus:${{ steps.tag_version.outputs.new_tag }}-base" >> $GITHUB_ENV
echo "SYNAPSE_TAGS=lambdatest/synapse:dev","lambdatest/synapse:${{ steps.tag_version.outputs.new_tag }}" >> $GITHUB_ENV

- name: Docker Login
uses: docker/login-action@v1.13.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
logout: true

- name: Build and push Nucleus images
uses: docker/build-push-action@v2.9.0
with:
context: .
tags: ${{ env.NUCLEUS_TAGS }}
file: build/nucleus/Dockerfile
push: true

- name: Build and push Synapse images
uses: docker/build-push-action@v2.9.0
with:
context: .
tags: ${{ env.SYNAPSE_TAGS }}
file: build/synapse/Dockerfile
push: true
Loading