Skip to content

Review of old commit 85f6352 (#29) #197

Review of old commit 85f6352 (#29)

Review of old commit 85f6352 (#29) #197

name: 1/3 Main Pipeline
on:
push:
workflow_dispatch:
env:
KOSLI_ORG: kosli
KOSLI_FLOW: loancalculator
KOSLI_CLI_VERSION: "2.6.1"
IMAGE_NAME: merkely/loancalculator
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Add Docker image names to GITHUB_ENV
run: |
echo "IMAGE_TAGGED=${{ env.IMAGE_NAME }}:$(git log -1 --pretty=%h)" >> ${GITHUB_ENV}
echo "IMAGE_LATEST=${{ env.IMAGE_NAME }}:latest" >> ${GITHUB_ENV}
- name: Setup cli client
uses: kosli-dev/setup-cli-action@v2
with:
version: ${{ env.KOSLI_CLI_VERSION }}
- name: Create Kosli flow
env:
KOSLI_API_TOKEN: ${{ secrets.KOSLI_API_TOKEN }}
run:
kosli create flow ${{ env.KOSLI_FLOW }}
--description "The loan calculator application"
--template "jira,artifact,unit_test,coverage"
--visibility public
- name: Report jira ticket to kosli
env:
KOSLI_API_TOKEN: ${{ secrets.KOSLI_API_TOKEN }}
KOSLI_JIRA_API_TOKEN: ${{ secrets.KOSLI_JIRA_API_TOKEN }}
run:
kosli report evidence commit jira
--jira-base-url https://kosli-test.atlassian.net
--jira-username [email protected]
--name jira
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_DEPLOY_USERNAME }}
password: ${{ secrets.DOCKERHUB_DEPLOY_TOKEN }}
- name: Build and push Docker image
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ env.IMAGE_TAGGED }}
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max
build-args: |
COMMIT_SHA=${{ github.sha }}
- name: Make the image digest available for following steps
id: digest-prep
run: |
ARTIFACT_SHA=$( echo ${{ steps.docker_build.outputs.digest }} | sed 's/.*://')
echo "KOSLI_FINGERPRINT=$ARTIFACT_SHA" >> ${GITHUB_ENV}
- name: Log Docker image in Kosli
env:
KOSLI_API_TOKEN: ${{ secrets.KOSLI_API_TOKEN }}
run:
kosli report artifact ${{ env.IMAGE_TAGGED }}
- name: Run unit tests
run: |
# Write results to ./build/test/
docker run \
--name container \
--entrypoint ./entrypoint-unit_test.sh \
${{ env.IMAGE_TAGGED }}
mkdir -p build/test
docker cp container:/code/build/test/ ${PWD}/build
docker rm container
- name: Log unit test results in Kosli
env:
KOSLI_API_TOKEN: ${{ secrets.KOSLI_API_TOKEN }}
run:
kosli report evidence artifact junit
--name unit_test
--results-dir "${{ github.workspace }}/build/test"
- name: Run coverage
run: |
# Write summary to build/coverage/coverage_summary.sh
mkdir -p build/coverage
docker run \
--rm \
--volume ${PWD}/build:/code/build \
--entrypoint ./entrypoint-coverage.sh \
${{ env.IMAGE_TAGGED }}
source build/coverage/coverage_summary.sh
echo "COVERAGE_SUMMARY=${COVERAGE_SUMMARY}" >> ${GITHUB_ENV}
- name: Log coverage results in Kosli
env:
KOSLI_API_TOKEN: ${{ secrets.KOSLI_API_TOKEN }}
run:
kosli report evidence artifact generic
--description "${{ env.COVERAGE_SUMMARY }}"
--name coverage
- name: Deploy to staging
run: |
echo YOUR DEPLOYMENT COMMAND HERE
- name: Log deployment to staging in Kosli
env:
KOSLI_API_TOKEN: ${{ secrets.KOSLI_API_TOKEN }}
run:
kosli expect deployment
--environment staging