Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
feat: Repository migration (#2)
Browse files Browse the repository at this point in the history
* feat: Add LICENSE

Signed-off-by: Raphael Ludwig <[email protected]>

* refactor: Downgrade Go version to 1.17

Signed-off-by: Raphael Ludwig <[email protected]>

* feat: Add github automation workflow and renovate, reviewdog

Signed-off-by: Raphael Ludwig <[email protected]>

* refactor: Move helm-service to keptn-contrib/helm-service

Signed-off-by: Raphael Ludwig <[email protected]>

* refactor: Fix chart and appVersion

Signed-off-by: Raphael Ludwig <[email protected]>

* feat: Add compability matrix to Readme.md

Signed-off-by: Raphael Ludwig <[email protected]>

* refactor: Remove keptn common chart

Signed-off-by: Raphael Ludwig <[email protected]>

* chore: Ignore .vscode for docker build

Signed-off-by: Raphael Ludwig <[email protected]>

* chore: Update comments in the CI pipeline

Signed-off-by: Raphael Ludwig <[email protected]>

* chore: reformat .gitignore

Signed-off-by: Raphael Ludwig <[email protected]>

Signed-off-by: Raphael Ludwig <[email protected]>
  • Loading branch information
Raffy23 authored Aug 23, 2022
1 parent 981cdc0 commit 5c7abf9
Show file tree
Hide file tree
Showing 70 changed files with 1,768 additions and 526 deletions.
1 change: 1 addition & 0 deletions .ci_env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
IMAGE=helm-service
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,12 @@ deploy/
Dockerfile
chart/
skaffold.yaml
.github
installer
.reviewdog.yaml
.versionrc.json
renovate.json
.ci_env
sequence_diagrams/
example-events/
.vscode
25 changes: 25 additions & 0 deletions .github/actions/unit-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "Unit Tests"
description: "Run unit tests using go"
env:
GO111MODULE: "on"
GOPROXY: "https://proxy.golang.org"
runs:
using: "composite"
steps:
- name: Check out code.
uses: actions/[email protected]
- name: Install Go
uses: actions/[email protected]
with:
go-version-file: "go.mod"
- name: Install gotestsum
shell: bash
run: go install gotest.tools/gotestsum@latest
- name: Test
shell: bash
run: gotestsum --format testname --junitfile unittests_report.xml -- -race ./...
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
if: always() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
with:
files: "unittests_report.xml"
192 changes: 192 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
name: CI
on:
# always execute docker build when something is pushed to main/master or release-* branches
push:
branches:
- "master"
- "main"
- "release-*"
# in addition, execute for pull requests to those branches
pull_request:
branches:
- "master"
- "main"
- "release-*"
# run integration tests when triggered manually
workflow_dispatch:

defaults:
run:
shell: bash
jobs:
prepare_ci_run:
name: Prepare CI Run
# Prepare CI Run looks at what has been changed in this commit/PR/... and builds the artifacts
runs-on: ubuntu-20.04
outputs: # declare what this job outputs (so it can be re-used for other jobs)
# build config
# metadata
GIT_SHA: ${{ steps.extract_branch.outputs.GIT_SHA }}
BRANCH: ${{ steps.extract_branch.outputs.BRANCH }}
BRANCH_SLUG: ${{ steps.extract_branch.outputs.BRANCH_SLUG }}
VERSION: ${{ steps.get_version.outputs.VERSION }}
DATE: ${{ steps.get_datetime.outputs.DATE }}
TIME: ${{ steps.get_datetime.outputs.TIME }}
DATETIME: ${{ steps.get_datetime.outputs.DATETIME }}

steps:
- name: Check out code
uses: actions/[email protected]
with:
fetch-depth: 0 # need to checkout "all commits" for certain features to work (e.g., get all changed files)

- name: Load CI Environment from .ci_env
id: load_ci_env
uses: c-py/action-dotenv-to-setenv@v3
with:
env-file: .ci_env

- name: Extract branch name
id: extract_branch
# see https://github.com/keptn/gh-action-extract-branch-name for details
uses: keptn/gh-action-extract-branch-name@main

- name: "Get Previous tag"
id: get_previous_tag
uses: "WyriHaximus/[email protected]"
with:
fallback: "0.0.1"
- name: "Get next patch version"
id: get_next_semver_tag
uses: "WyriHaximus/[email protected]"
with:
version: ${{ steps.get_previous_tag.outputs.tag }}
- name: Get the version
id: get_version
env:
BRANCH: ${{ steps.extract_branch.outputs.BRANCH }}
BRANCH_SLUG: ${{ steps.extract_branch.outputs.BRANCH_SLUG }}
shell: bash
run: |
# determine version
GIT_LAST_TAG=${{ steps.get_previous_tag.outputs.tag }}
GIT_NEXT_TAG=${{ steps.get_next_semver_tag.outputs.patch }}
echo "GIT_LAST_TAG=${GIT_LAST_TAG}, GIT_NEXT_TAG=${GIT_NEXT_TAG}"
if [[ "$BRANCH" == "release-"* ]]; then
# Release Branch: extract version from branch name
VERSION=${BRANCH#"release-"}
else
if [[ "$BRANCH" == "master" || "$BRANCH" == "main" ]]; then
# master branch = latest
VERSION="${GIT_NEXT_TAG}-dev"
else
# Feature/Development Branch - use last tag with branch slug
VERSION="${GIT_NEXT_TAG}-dev-${BRANCH_SLUG}"
fi
fi
echo "VERSION=${VERSION}"
echo "::set-output name=VERSION::$(echo ${VERSION})"
- name: Get current date and time
id: get_datetime
run: |
echo "::set-output name=DATE::$(date +'%Y%m%d')"
echo "::set-output name=TIME::$(date +'%H%M')"
echo "::set-output name=DATETIME::$(date +'%Y%m%d')$(date +'%H%M')"
############################################################################
# Unit tests #
############################################################################
unit-tests:
name: Unit Tests
runs-on: ubuntu-20.04
steps:
- name: Check out repository
uses: actions/[email protected]
- name: Unit tests
uses: ./.github/actions/unit-tests

############################################################################
# Build Docker Image #
############################################################################
docker_build:
needs: [prepare_ci_run]
name: Docker Build
runs-on: ubuntu-20.04
env:
VERSION: ${{ needs.prepare_ci_run.outputs.VERSION }}
DATETIME: ${{ needs.prepare_ci_run.outputs.DATETIME }}
steps:
- name: Checkout Code
uses: actions/[email protected]

- name: Load CI Environment from .ci_env
id: load_ci_env
uses: c-py/action-dotenv-to-setenv@v3
with:
env-file: .ci_env

- name: Sanitize repo owner
uses: actions/github-script@v4
id: repo_slug
with:
result-encoding: string
script: return '${{ github.repository_owner }}'.toLowerCase()

- name: Docker Build
id: docker_build
uses: keptn/gh-automation/.github/actions/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAGS: |
ghcr.io/${{ steps.repo_slug.outputs.result }}/${{ env.IMAGE }}:${{ env.VERSION }}
ghcr.io/${{ steps.repo_slug.outputs.result }}/${{ env.IMAGE }}:${{ env.VERSION }}.${{ env.DATETIME }}
BUILD_ARGS: |
version=${{ env.VERSION }}
PUSH: ${{(github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository)}}

- id: report_docker_build_to_pr
name: Report Docker Build to PR
if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
recreate: true
header: test
message: |
The following Docker Images have been built:
${{ fromJSON(steps.docker_build.outputs.BUILD_METADATA)['image.name'] }}
helm_chart_build:
needs: [prepare_ci_run, docker_build]
name: Build Helm Charts
runs-on: ubuntu-20.04
env:
VERSION: ${{ needs.prepare_ci_run.outputs.VERSION }}
DATETIME: ${{ needs.prepare_ci_run.outputs.DATETIME }}
steps:
- name: Checkout Code
uses: actions/[email protected]

- name: Load CI Environment from .ci_env
id: load_ci_env
uses: c-py/action-dotenv-to-setenv@v3
with:
env-file: .ci_env

- name: Build Helm Charts
id: build_helm_charts
uses: keptn/gh-automation/.github/actions/[email protected]
with:
VERSION: ${{ env.VERSION }}
APP_VERSION: ${VERSION}.${DATETIME}
CHART_NAME: ${{ env.IMAGE }}

- name: Upload Helm Chart as an artifact
id: upload_helm_chart
uses: actions/upload-artifact@v3
with:
name: helm-charts
path: installer/*.tgz
79 changes: 79 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Create Pre-Release
on:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-20.04
steps:
- name: Check out repository
uses: actions/[email protected]
- name: Unit tests
uses: ./.github/actions/unit-tests

pre-release:
needs: test
name: Pre-Release
uses: keptn/gh-automation/.github/workflows/[email protected]

docker_build:
needs: [pre-release]
name: Docker Build
runs-on: ubuntu-20.04
env:
VERSION: ${{ needs.pre-release.outputs.RELEASE_TAG }}
steps:
- name: Checkout Code
uses: actions/[email protected]

- name: Load CI Environment from .ci_env
id: load_ci_env
uses: c-py/action-dotenv-to-setenv@v3
with:
env-file: .ci_env

- name: Sanitize repo owner
uses: actions/github-script@v4
id: repo_slug
with:
result-encoding: string
script: return '${{ github.repository_owner }}'.toLowerCase()

- name: Docker Build
uses: keptn/gh-automation/.github/actions/[email protected]
with:
TAGS: |
ghcr.io/${{ steps.repo_slug.outputs.result }}/${{ env.IMAGE }}:${{ env.VERSION }}
BUILD_ARGS: |
version=${{ env.VERSION }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

helm_chart_build:
needs: [pre-release, docker_build]
name: Build Helm Charts
runs-on: ubuntu-20.04
env:
VERSION: ${{ needs.pre-release.outputs.RELEASE_TAG }}
steps:
- name: Checkout Code
uses: actions/[email protected]

- name: Load CI Environment from .ci_env
id: load_ci_env
uses: c-py/action-dotenv-to-setenv@v3
with:
env-file: .ci_env

- name: Build Helm Charts
id: build_helm_charts
uses: keptn/gh-automation/.github/actions/[email protected]
with:
VERSION: ${{ env.VERSION }}
APP_VERSION: ${{ env.VERSION }}
CHART_NAME: ${{ env.IMAGE }}

- name: Upload Helm Chart as release asset
env:
RELEASE_TAG: ${{ needs.pre-release.outputs.RELEASE_TAG }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload "$RELEASE_TAG" installer/*.tgz
80 changes: 80 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Create Release
on:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-20.04
steps:
- name: Check out repository
uses: actions/[email protected]
- name: Unit tests
uses: ./.github/actions/unit-tests

release:
needs: test
name: Release
uses: keptn/gh-automation/.github/workflows/[email protected]

docker_build:
needs: [release]
name: Docker Build
runs-on: ubuntu-20.04
env:
VERSION: ${{ needs.release.outputs.RELEASE_TAG }}
steps:
- name: Checkout Code
uses: actions/[email protected]

- name: Load CI Environment from .ci_env
id: load_ci_env
uses: c-py/action-dotenv-to-setenv@v3
with:
env-file: .ci_env

- name: Sanitize repo owner
uses: actions/github-script@v4
id: repo_slug
with:
result-encoding: string
script: return '${{ github.repository_owner }}'.toLowerCase()

- name: Docker Build
uses: keptn/gh-automation/.github/actions/[email protected]
with:
TAGS: |
ghcr.io/${{ steps.repo_slug.outputs.result }}/${{ env.IMAGE }}:${{ env.VERSION }}
BUILD_ARGS: |
version=${{ env.VERSION }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

helm_chart_build:
needs: [release, docker_build]

name: Build Helm Charts
runs-on: ubuntu-20.04
env:
VERSION: ${{ needs.release.outputs.RELEASE_TAG }}
steps:
- name: Checkout Code
uses: actions/[email protected]

- name: Load CI Environment from .ci_env
id: load_ci_env
uses: c-py/action-dotenv-to-setenv@v3
with:
env-file: .ci_env

- name: Build Helm Charts
id: build_helm_charts
uses: keptn/gh-automation/.github/actions/[email protected]
with:
VERSION: ${{ env.VERSION }}
APP_VERSION: ${{ env.VERSION }}
CHART_NAME: ${{ env.IMAGE }}

- name: Upload Helm Chart as release asset
env:
RELEASE_TAG: ${{ needs.release.outputs.RELEASE_TAG }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload "$RELEASE_TAG" installer/*.tgz
Loading

0 comments on commit 5c7abf9

Please sign in to comment.