Skip to content

Commit

Permalink
Add CI pipeline for C++
Browse files Browse the repository at this point in the history
Includes a separate builder docker image that includes all tools &
dependencies.
  • Loading branch information
GermanCoding committed Jul 25, 2024
1 parent 1418ec0 commit 7d44237
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 2 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/ci-cpp-toolchain.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: vaas-cpp-toolchain-ci
on:
push:
tags:
- "cpp-toolchain*"
paths:
- "cpp/Dockerfile.build"
- ".github/workflows/ci-cpp-toolchain.yaml"

jobs:
cpp-toolchain:
name: Build & Push C++ toolchain
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
cpp/Dockerfile.build
sparse-checkout-cone-mode: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: set version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/cpp-toolchain}" >> $GITHUB_ENV

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/gdatasoftwareag/vaas/cpp-toolchain
tags: |
type=semver,pattern={{version}},value=${{ env.RELEASE_VERSION }}
type=semver,pattern={{major}}.{{minor}},value=${{ env.RELEASE_VERSION }}
type=semver,pattern={{major}},value=${{ env.RELEASE_VERSION }}
flavor: |
latest=auto
- name: login to ghcr.io/gdatasoftwareag
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GHCR_IO_GDATASOFTWAREAG_USERNAME }}
password: ${{ secrets.GHCR_IO_GDATASOFTWAREAG_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: "cpp/"
file: "cpp/Dockerfile.build"
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
74 changes: 74 additions & 0 deletions .github/workflows/ci-cpp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: vaas-cpp-ci
on:
push:
paths:
- "cpp/**"
- ".github/workflows/ci-cpp.yaml"
pull_request:
paths:
- "cpp/**"
- ".github/workflows/ci-cpp.yaml"
workflow_dispatch:
inputs:
environment:
type: choice
description: "Test environment"
options:
- production
- staging
- develop
default: "production"

env:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{secrets.CLIENT_SECRET}}
VAAS_URL: "https://upload.production.vaas.gdatasecurity.de"
TOKEN_URL: "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token"
VAAS_CLIENT_ID: ${{ secrets.VAAS_CLIENT_ID }}
VAAS_USER_NAME: ${{ secrets.VAAS_USER_NAME }}
VAAS_PASSWORD: ${{secrets.VAAS_PASSWORD}}
jobs:
cpp-build:
name: Build & Test C++ SDK
runs-on: ubuntu-latest
container: ghcr.io/gdatasoftwareag/vaas/cpp-toolchain
steps:
- uses: actions/checkout@v4

- name: Scan for Viruses
uses: ./.github/actions/vaas-scan-action
with:
VAAS_CLIENT_ID: ${{ secrets.VAAS_SCAN_CLIENT_ID }}
VAAS_CLIENT_SECRET: ${{ secrets.VAAS_SCAN_CLIENT_SECRET }}

- name: set staging environment
if: (inputs.environment == 'staging' || (startsWith(github.ref, 'refs/tags/cs') && endsWith(github.ref, '-beta')))
run: |
echo "CLIENT_ID=${{ secrets.STAGING_CLIENT_ID }}" >> $GITHUB_ENV
echo "CLIENT_SECRET=${{ secrets.STAGING_CLIENT_SECRET }}" >> $GITHUB_ENV
echo "VAAS_URL=https://upload.staging.vaas.gdatasecurity.de" >> $GITHUB_ENV
echo "TOKEN_URL=https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token" >> $GITHUB_ENV
echo "VAAS_CLIENT_ID=${{ secrets.STAGING_VAAS_CLIENT_ID }}" >> $GITHUB_ENV
echo "VAAS_USER_NAME=${{ secrets.STAGING_VAAS_USER_NAME }}" >> $GITHUB_ENV
echo "VAAS_PASSWORD=${{ secrets.STAGING_VAAS_PASSWORD }}" >> $GITHUB_ENV
- name: set develop environment
if: (inputs.environment == 'develop' || (startsWith(github.ref, 'refs/tags/cs') && endsWith(github.ref, '-alpha')))
run: |
echo "CLIENT_ID=${{ secrets.DEVELOP_CLIENT_ID }}" >> $GITHUB_ENV
echo "CLIENT_SECRET=${{ secrets.DEVELOP_CLIENT_SECRET }}" >> $GITHUB_ENV
echo "VAAS_URL=https://upload.develop.vaas.gdatasecurity.de" >> $GITHUB_ENV
echo "TOKEN_URL=https://account-staging.gdata.de/realms/vaas-develop/protocol/openid-connect/token" >> $GITHUB_ENV
echo "VAAS_CLIENT_ID=${{ secrets.DEVELOP_VAAS_CLIENT_ID }}" >> $GITHUB_ENV
echo "VAAS_USER_NAME=${{ secrets.DEVELOP_VAAS_USER_NAME }}" >> $GITHUB_ENV
echo "VAAS_PASSWORD=${{ secrets.DEVELOP_VAAS_PASSWORD }}" >> $GITHUB_ENV
- name: Build C++ SDK
run: |
./build.sh
working-directory: cpp

- name: Test C++ SDK
run: |
./test.sh
working-directory: cpp
16 changes: 16 additions & 0 deletions cpp/Dockerfile.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#### Base Image
FROM ubuntu:22.04

RUN apt-get update -qq && \
# install dependencies
apt-get install -y --no-install-recommends git ca-certificates curl zip unzip tar build-essential cmake make pkg-config libssl3 libssl-dev linux-libc-dev && \
# install vcpkg
cd /usr/local && \
git clone https://github.com/microsoft/vcpkg.git && \
cd vcpkg && ./bootstrap-vcpkg.sh

ENV VCPKG_ROOT="/usr/local/vcpkg/"
ENV PATH="$VCPKG_ROOT:$PATH"


ENTRYPOINT ["/bin/bash"]
3 changes: 1 addition & 2 deletions cpp/build_and_test.sh → cpp/build.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash
set -ex
cmake --preset release
cmake --build build
./build/vaas_test
cmake --build build
3 changes: 3 additions & 0 deletions cpp/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
set -ex
./build/vaas_test

0 comments on commit 7d44237

Please sign in to comment.