Skip to content

Fedora base

Fedora base #177

Workflow file for this run

name: CI
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
jobs:
formatting-check:
name: Check code format
runs-on: ubuntu-latest
steps:
-
name: Checkout hermes repo
uses: actions/checkout@v2
-
name: Run clang format
run: |
find . -regex '.*\.\(cpp\|hpp\|cc\|cxx\|h\|c\|hh\)' -exec clang-format -style=file -i {} \;
git diff --exit-code
compile-and-unit-tests:
name: Compile and run unit tests
runs-on: ubuntu-latest
container:
image: ghcr.io/jgomezselles/hermes_base:0.0.3
options: "--entrypoint sh"
steps:
-
name: Checkout hermes repo
uses: actions/checkout@v2
-
name: Run cmake with debug and coverage flags
run: cmake -B build -DCMAKE_BUILD_TYPE=Debug .
-
name: Compile code and unit tests
run: make -j -C build
-
name: Install and setup lcov base
run: |
dnf install -y lcov
lcov -i --capture --directory "./build/src/" --output-file base-coverage.info --no-external --directory "./" --exclude "*/ut/*" --exclude "*/main*"
-
name: Run unit tests
run: ./build/ut/unit-test
-
name: Capture and merge coverage info
run: |
lcov --capture --directory "./build/src/" --output-file test-coverage.info --no-external --directory "./" --exclude "*/ut/*" --exclude "*/main*"
lcov -a base-coverage.info -a test-coverage.info -o total-coverage.info
-
name: Upload coverage to Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: total-coverage.info
build-release-image:
name: Build hermes release image and push it to artifacts
runs-on: ubuntu-latest
env:
COMMIT_ID: ${{ github.sha }}
steps:
-
name: Set commit id
run: echo COMMIT_ID=${COMMIT_ID::7} >> $GITHUB_ENV
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./docker/Dockerfile
tags: ghcr.io/jgomezselles/hermes:${{ env.COMMIT_ID }}
outputs: type=docker,dest=/tmp/hermes-image-${{ env.COMMIT_ID }}.tar
-
name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: hermes-image-${{ env.COMMIT_ID }}
path: /tmp/hermes-image-${{ env.COMMIT_ID }}.tar
retention-days: 1
build-server-mock-image:
name: Build server-mock image and push it to artifacts
runs-on: ubuntu-latest
env:
COMMIT_ID: ${{ github.sha }}
steps:
-
name: Set commit id
run: echo COMMIT_ID=${COMMIT_ID::7} >> $GITHUB_ENV
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./docker/server-mock/Dockerfile
tags: ghcr.io/jgomezselles/server-mock:${{ env.COMMIT_ID }}
outputs: type=docker,dest=/tmp/server-mock-image-${{ env.COMMIT_ID }}.tar
-
name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: server-mock-image-${{ env.COMMIT_ID }}
path: /tmp/server-mock-image-${{ env.COMMIT_ID }}.tar
retention-days: 1
test-example-hermes:
needs: [ build-release-image, build-server-mock-image]
runs-on: ubuntu-latest
env:
COMMIT_ID: ${{ github.sha }}
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Trim commit id
run: echo COMMIT_ID=${COMMIT_ID::7} >> $GITHUB_ENV
-
name: Install KinD
uses: helm/kind-action@2a525709fd0874b75d7ae842d257981b0e0f557d
with:
cluster_name: "kind"
kubectl_version: "v1.22.1"
-
name: Download server-mock
uses: actions/download-artifact@v2
with:
name: server-mock-image-${{ env.COMMIT_ID }}
path: /tmp
-
name: Download hermes image
uses: actions/download-artifact@v2
with:
name: hermes-image-${{ env.COMMIT_ID }}
path: /tmp
-
name: Load images to KinD
run: |
kind load image-archive /tmp/server-mock-image-${{ env.COMMIT_ID }}.tar ghcr.io/jgomezselles/server-mock:${{ env.COMMIT_ID }} --name kind
kind load image-archive /tmp/hermes-image-${{ env.COMMIT_ID }}.tar ghcr.io/jgomezselles/hermes:${{ env.COMMIT_ID }} --name kind
-
name: Check previous steps
run: |
docker exec kind-control-plane crictl images
kubectl get pods -A
kubectl version
-
name: Lint hermes helmchart
run: |
helm lint helm/hermes
-
name: Update example-hermes dependencies
run: |
helm dep update helm/example-hermes
-
name: Lint example-hermes helmchart
run: |
helm lint helm/example-hermes
-
name: Template example-hermes
run: |
helm template helm/example-hermes/ --set serverMock.image.tag=${{ env.COMMIT_ID }} --set hermes.image.tag=${{ env.COMMIT_ID }} --set hermes.image.pullPolicy=Never
-
name: Install example-hermes
run: |
helm install hermes-example-${{ env.COMMIT_ID }} helm/example-hermes/ --set serverMock.image.tag=${{ env.COMMIT_ID }} --set hermes.image.tag=${{ env.COMMIT_ID }} --set hermes.image.pullPolicy=Never --wait --timeout=30s
-
name: Check pods
run: |
kubectl describe pods
-
name: Run helm tests
run: |
helm test hermes-example-${{ env.COMMIT_ID }}
-
name: Run hermes
run: |
HERMES_POD=$(kubectl get pod -l app.kubernetes.io/name=hermes -o jsonpath="{.items[0].metadata.name}")
kubectl exec $HERMES_POD -- hermes -p1 -t10 -r1000