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

Commit

Permalink
build: use updated pipelines from service-template (#32)
Browse files Browse the repository at this point in the history
* build: use updated pipelines from service-template

Signed-off-by: Christian Kreuzberger <[email protected]>

* review

Signed-off-by: Christian Kreuzberger <[email protected]>
  • Loading branch information
christian-kreuzberger-dtx authored Dec 20, 2021
1 parent 42faed9 commit 36ffa91
Show file tree
Hide file tree
Showing 15 changed files with 314 additions and 166 deletions.
2 changes: 2 additions & 0 deletions .ci_env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DOCKER_ORGANIZATION="keptncontrib"
IMAGE="argo-service"
18 changes: 18 additions & 0 deletions .github/actions/unit-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 'Unit Tests'
description: 'Run unit tests using go'
inputs:
GO_VERSION:
default: "1.16"
env:
GO111MODULE: "on"
GOPROXY: "https://proxy.golang.org"
runs:
using: "composite"
steps:
- name: Install Go
uses: actions/[email protected]
with:
go-version: ${{ inputs.GO_VERSION }}
- name: Test
shell: bash
run: go test -race -v ./...
144 changes: 144 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
name: CI
on:
# always execute docker build when something is pushed to master or release-* branches
push:
branches:
- 'master'
- 'release-*'
# in addition, execute for pull requests to those branches
pull_request:
branches:
- 'master'
- 'release-*'
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 determines which artifacts should be
# built afterwards (in other jobs that depend on this one).
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 }}
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]"
- 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" ]]; 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 datetime
id: get_datetime
run: |
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/checkout@v2
- 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: Docker Build
id: docker_build
uses: keptn/gh-automation/.github/actions/[email protected]
with:
TAGS: |
${{ env.DOCKER_ORGANIZATION }}/${{ env.IMAGE }}:${{ env.VERSION }}
${{ env.DOCKER_ORGANIZATION }}/${{ env.IMAGE }}:${{ env.VERSION }}.${{ env.DATETIME }}
BUILD_ARGS: |
version=${{ env.VERSION }}
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
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'] }}
24 changes: 24 additions & 0 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: reviewdog
on: [pull_request]
jobs:
reviewdog:
name: reviewdog
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
id: go
- name: Check out code.
uses: actions/[email protected]
- name: Install linters
run: '( mkdir linters && cd linters && go get golang.org/x/lint/golint )'
- uses: reviewdog/[email protected]
with:
reviewdog_version: latest
- name: Run reviewdog
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
reviewdog -reporter=github-pr-review
22 changes: 22 additions & 0 deletions .github/workflows/validate-semantic-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Semantic PR Validation
on:
pull_request_target:
types:
- opened
- edited
- synchronize
jobs:
validate:
uses: keptn/gh-automation/.github/workflows/[email protected]
with:
# Configure which scopes are allowed.
scopes: |
api
core
install
cloudevents
deps
deps-dev
distributor
docs
release
118 changes: 0 additions & 118 deletions .travis.yml

This file was deleted.

51 changes: 51 additions & 0 deletions .versionrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"tagPrefix": "",
"preMajor": true,
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "chore",
"section": "Other"
},
{
"type": "docs",
"section": "Docs"
},
{
"type": "perf",
"section": "Performance"
},
{
"type": "build",
"hidden": true
},
{
"type": "ci",
"hidden": true
},
{
"type": "refactor",
"section": "Refactoring"
},
{
"type": "revert",
"hidden": true
},
{
"type": "style",
"hidden": true
},
{
"type": "test",
"hidden": true
}
]
}

Loading

0 comments on commit 36ffa91

Please sign in to comment.