Skip to content

Initial workflow

Initial workflow #1

# This workflow requires the following:
# - A build-kit-<repository-name> docker image
# - which is built from the `inputs.build_kit_docker_directory` directory
# - A build-kit/scripts directory
# - which is defined by `inputs.build_kit_scripts_directory`
# - with the following scripts:
# - compile.sh
# - run_unit_tests.sh (optional, but required if `inputs.run_unit_tests` is true)
# - This script should run the unit tests
# and output the results to `inputs.ctest_report_path`
# - run_coverage.sh (optional, but required if `inputs.run_coverage` is true)
# - This script should run the coverage tests
# and output the results to `inputs.coverage_report_path`
# - install.sh (optional, but required if `inputs.run_install` is true)
# - This script should create the dist directory
# and output it to `inputs.dist_path`
# - install_wheels.sh (optional, but required if `inputs.run_install_wheels` is true)
# - This script should create the wheels directory
# and output it to `inputs.wheels_path`
# - create_integration_image.sh (optional, but required if `inputs.run_integration_tests` is true)
# - This script should create the integration image
# by installing additional dependencies, for example wheel files
# - run_integration_tests.sh (optional, but required if `inputs.run_integration_tests` is true)
# - This script should run the integration tests
# and output the results to `inputs.result_xml_path` and `inputs.report_html_path`
# - During the build, the `github.workspace` directory is mounted to `/ext`,
# which is stored in the environment variable `$EXT_MOUNT`
# - A docker-compose file with the services required for integration tests
# - which is defined by `inputs.docker_compose_file_path`
# - A service in the docker-compose file with the name `inputs.test_service_name`,
# which uses the `inputs.integration_image_name` image
name: Continuous Integration
on:
workflow_call:
inputs:
# General inputs
runner:
description: 'Which runner to use'
required: true
default: 'ubuntu-22.04'
options:
- 'ubuntu-22.04'
- 'large-ubuntu-22.04-xxl'
# Enviroment inputs
docker_registry:
description: 'The docker registry to use'
required: true
default: 'ghcr.io'
# Lint inputs
lint_source_dir:
description: 'The directory to run clang-format on, relative to the repository root'
required: true
default: '.'
lint_extensions:
description: 'The file extensions to run clang-format on'
required: true
default: 'hpp,cpp'
lint_exclude:
description: 'The directories to exclude from clang-format'
required: false
default: 'cache'
# Build kit inputs
build_kit_docker_directory:
description: 'The directory to build the build kit from, relative to the repository root'
required: true
default: '.ci/build-kit/docker'
build_kit_scripts_directory:
description: 'The directory to find the build kit scripts in, relative to the repository root'
required: true
default: '.ci/build-kit/scripts'
# Build inputs
ctest_report_path:
description: 'The path to the ctest report, relative to the github workspace'
required: false
default: 'build/Testing/Temporary/LastTest.log'
coverage_report_path:
description: 'The path to the coverage report, relative to the github workspace'
required: false
default: 'build/gcovr-coverage'
dist_path:
description: 'The path to the dist directory, relative to the github workspace'
required: true
default: 'dist'
wheels_path:
description: 'The path to the wheels directory, relative to the github workspace'
required: true
default: 'wheels'
use_build_cache:
description: 'Use build cache'
required: true
default: 'true'
options:
- 'true'
- 'false'
# Integration test inputs
docker_compose_file_path:
description: 'The path to the docker-compose file, relative to the repository root'
required: true
default: '.ci/e2e/docker-compose.yml'
integration_image_name:
description: 'The name of the integration image'
required: true
default: 'integration-image'
test_service_name:
description: 'The name of the service to run integration tests on'
required: true
default: 'e2e-test-server'
result_xml_path:
description: 'The path to the result xml file, relative to the github workspace'
required: false
default: 'result.xml'
report_html_path:
description: 'The path to the report html file, relative to the github workspace'
required: false
default: 'report.html'
# Workflow control inputs
run_lint:
description: 'Run linting'
required: true
default: 'true'
options:
- 'true'
- 'false'
run_unit_tests:
description: 'Run unit tests'
required: true
default: 'true'
options:
- 'true'
- 'false'
run_coverage:
description: 'Run coverage'
required: true
default: 'true'
options:
- 'true'
- 'false'
run_install:
description: 'Run install'
required: true
default: 'true'
options:
- 'true'
- 'false'
run_install_wheels:
description: 'Run install wheels'
required: true
default: 'true'
options:
- 'true'
- 'false'
run_integration_tests:
description: 'Run integration tests'
required: true
default: 'false'
options:
- 'true'
- 'false'
env:
EVEREST_CI_VERSION: v1.3.1
jobs:
lint:
name: Lint Repository
runs-on: ${{ inputs.runner }}
if: ${{ inputs.run_lint == 'true' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
path: source
- name: Run clang-format
uses: everest/everest-ci/github-actions/[email protected]
with:
source-dir: source/${{ github.event.inputs.lint_source_dir }}
extensions: ${{ github.event.inputs.lint_extensions }}
exclude: ${{ github.event.inputs.lint_exclude }}
# Since env variables can't be passed to reusable workflows, we need to pass them as outputs
setup-env:
name: Setup Environment
runs-on: ${{ inputs.runner }}
outputs:
everest_ci_version: ${{ env.EVEREST_CI_VERSION }}
workflow_path: ${{ steps.set_workflow_path.outputs.workflow_path }}
steps:
- name: Determine workflow_path
id: set_workflow_path
shell: python3 {0}
run: |
import os
workflow_path = "${{ github.workflow_ref }}".split('@')[0]
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
f.write(f"workflow_path={workflow_path}\n")
print(f"Set output workflow_path to {workflow_path}")
build-and-push-build-kit:
name: Build and Push Build Kit
uses: everest/everest-ci/.github/workflows/[email protected]
needs: setup-env
permissions:
contents: read
packages: write
with:
image_name: ${{ github.event.repository.name }}/build-kit-${{ github.event.repository.name }}
directory: ${{ inputs.build_kit_docker_directory}}
docker_registry: ${{ inputs.docker_registry }}
github_ref_before: ${{ github.event.before }}
github_ref_after: ${{ github.event.after }}
platforms: linux/amd64
depends_on_paths: |
${{ inputs.build_kit_scripts_directory }}
${{ steps.setup-env.outputs.workflow_path }}
build_args: |
BASE_IMAGE_TAG=${{ needs.setup-env.outputs.everest_ci_version }}
build:
name: Build, Unit Tests and Install
needs: build-and-push-build-kit
runs-on: ${{ inputs.runner }}
env:
BUILD_KIT_IMAGE: ${{ needs.build-and-push-build-kit.outputs.one_image_tag_long }}
steps:
- name: Format branch name for cache key
if: ${{ inputs.use_build_cache == 'true' }}
run: |
BRANCH_NAME_FOR_CACHE="${GITHUB_REF_NAME//-/_}"

Check failure on line 231 in .github/workflows/continuous_integration.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/continuous_integration.yml

Invalid workflow file

You have an error in your yaml syntax on line 231
echo "branch_name_for_cache=${BRANCH_NAME_FOR_CACHE}" >> "$GITHUB_ENV"
- name: Setup cache
if: ${{ inputs.use_build_cache == 'true' }}
uses: actions/cache@v3
with:
path: cache
key: compile-${{ env.branch_name_for_cache }}-${{ github.sha }}
restore-keys: |
compile-${{ env.branch_name_for_cache }}-
compile-
- name: Checkout repository
uses: actions/checkout@v3
with:
path: source
- name: Setup run scripts
run: |
mkdir scripts
rsync -a source/${{ inputs.build_kit_scripts_directory }}/ scripts
- name: Pull build-kit image
run: |
docker pull --quiet ${{ env.BUILD_KIT_IMAGE }}
docker image tag ${{ env.BUILD_KIT_IMAGE }} build-kit
- name: Compile
run: |
docker run \
--volume "${{ github.workspace }}:/ext" \
--name compile-container \
build-kit run-script compile
- name: Run unit tests
id: run_unit_tests
if: ${{ inputs.run_unit_tests == 'true' }}
run: |
docker run \
--volume "${{ github.workspace }}:/ext" \
--name unit-test-container \
build-kit run-script run_unit_tests
- name: Archive test results
if: ${{ steps.run_unit_tests.outcome == 'success' or steps.run_unit_tests.outcome == 'failure' }}
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: ctest-report
path: ${{ inputs.ctest_report_path }}
- name: Run coverage
id: run_coverage
if: ${{ inputs.run_coverage == 'true' }}
run: |
docker run \
--volume "${{ github.workspace }}:/ext" \
--name coverage-container \
build-kit run-script run_coverage
- name: Archive coverage report
if: ${{ steps.run_coverage.outcome == 'success' or steps.run_coverage.outcome == 'failure' }}
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: coverage-report
path: ${{ inputs.coverage_report_path }}
- name: Create dist
id: create_dist
if: ${{ inputs.run_install == 'true' }}
run: |
docker run \
--volume "${{ github.workspace }}:/ext" \
--name dist-container \
build-kit run-script install
- name: Tar dist dir and keep permissions
if: ${{ steps.create_dist.outcome == 'success' or steps.create_dist.outcome == 'failure' }}
run: |
tar -czf dist.tar.gz dist
- name: Upload dist artifact
if: ${{ steps.create_dist.outcome == 'success' or steps.create_dist.outcome == 'failure' }}
uses: actions/[email protected]
with:
if-no-files-found: error
path: dist.tar.gz
name: dist
- name: Create wheels
id: create_wheels
if: ${{ inputs.run_install_wheels == 'true' }}
run: |
docker run \
--volume "${{ github.workspace }}:/ext" \
--name wheels-container \
build-kit run-script install_wheels
- name: Upload wheels artifact
if: ${{ steps.create_wheels.outcome == 'success' or steps.create_wheels.outcome == 'failure' }}
uses: actions/[email protected]
with:
if-no-files-found: error
path: ${{ inputs.wheels_path }}
name: wheels
integration-tests:
name: Integration Tests
needs:
- build
- build-and-push-build-kit
env:
BUILD_KIT_IMAGE: ${{ needs.build-and-push-build-kit.outputs.one_image_tag_long }}
runs-on: ${{ inputs.runner }}
if: ${{ inputs.run_integration_tests == 'true' }}
steps:
- name: Download dist dir
uses: actions/[email protected]
with:
name: dist
- name: Extract dist.tar.gz
run: |
tar -xzf ${{ github.workspace }}/dist.tar.gz -C ${{ github.workspace }}
- name: Download wheels
if: ${{ inputs.run_install_wheels == 'true' }}
uses: actions/[email protected]
with:
name: wheels
path: wheels
- name: Checkout repository
uses: actions/[email protected]
with:
path: source
- name: Setup run scripts
run: |
mkdir scripts
rsync -a source/${{ inputs.build_kit_scripts_directory }}/ scripts
- name: Pull build-kit image
run: |
docker pull --quiet ${{ env.BUILD_KIT_IMAGE }}
docker image tag ${{ env.BUILD_KIT_IMAGE }} build-kit
- name: Create integration-image
run: |
docker run \
--volume "${{ github.workspace }}:/ext" \
--name integration-container \
build-kit run-script create_integration_image
docker commit integration-container ${{ inputs.integration_image_name }}
- name: Run integration tests
id: run_integration_tests
run: |
docker compose run \
-f source/${{ inputs.docker_compose_file_path }} \
${{ inputs.test_service_name }} \
run-script run_integration_tests
- name: Upload result and report as artifact
if: ${{ steps.run_integration_tests.outcome == 'success' or steps.run_integration_tests.outcome == 'failure' }}
uses: actions/[email protected]
with:
if-no-files-found: error
name: integration-test-report
path:
${{ inputs.result_xml_path }}
${{ inputs.report_html_path }}
- name: Render result
if: ${{ steps.run_integration_tests.outcome == 'success' or steps.run_integration_tests.outcome == 'failure' }}
uses: pmeier/[email protected]
with:
path: ${{ inputs.result_xml_path }}
summary: True
display-options: fEX
fail-on-empty: True
title: Test results