Build, Lint and Test #3216
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build, Lint and Test | |
on: | |
pull_request: {} | |
workflow_dispatch: | |
inputs: | |
runner: | |
description: Which runner to use | |
type: choice | |
default: 'ubuntu-22.04' | |
required: true | |
options: | |
- 'ubuntu-22.04' | |
- 'large-ubuntu-22.04-xxl' | |
schedule: | |
- cron: '37 13,1 * * *' | |
env: | |
DOCKER_REGISTRY: ghcr.io | |
EVEREST_CI_VERSION: v1.3.1 | |
jobs: | |
lint: | |
name: Lint | |
runs-on: ${{ inputs.runner || 'ubuntu-22.04' }} | |
steps: | |
- name: Checkout everest-core | |
uses: actions/[email protected] | |
with: | |
path: source | |
- name: Run clang-format | |
uses: everest/everest-ci/github-actions/[email protected] | |
with: | |
source-dir: source | |
extensions: hpp,cpp | |
exclude: cache | |
# 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 || 'ubuntu-22.04' }} | |
outputs: | |
docker_registry: ${{ env.DOCKER_REGISTRY }} | |
everest_ci_version: ${{ env.EVEREST_CI_VERSION }} | |
steps: | |
- id: check | |
run: | | |
echo "Setting up environment" | |
build-and-push-build-kit: | |
name: Build and Push Build Kit | |
uses: everest/everest-ci/.github/workflows/[email protected] | |
needs: setup-env | |
secrets: | |
SA_GITHUB_PAT: ${{ secrets.SA_GITHUB_PAT }} | |
SA_GITHUB_USERNAME: ${{ secrets.SA_GITHUB_USERNAME }} | |
with: | |
image_name: ${{ github.event.repository.name }}/build-kit-everest-core | |
directory: .ci/build-kit/docker | |
docker_registry: ${{ needs.setup-env.outputs.docker_registry }} | |
github_ref_before: ${{ github.event.before }} | |
github_ref_after: ${{ github.event.after }} | |
platforms: linux/amd64 | |
depends_on_paths: | | |
.ci/build-kit | |
.github/workflows/build_and_test.yaml | |
build_args: | | |
BASE_IMAGE_TAG=${{ needs.setup-env.outputs.everest_ci_version }} | |
build: | |
name: Build and Unit Tests | |
needs: build-and-push-build-kit | |
runs-on: ${{ inputs.runner || 'ubuntu-22.04' }} | |
env: | |
BUILD_KIT_IMAGE: ${{ needs.build-and-push-build-kit.outputs.one_image_tag_long }} | |
steps: | |
- name: Format branch name for cache key | |
run: | | |
BRANCH_NAME_FOR_CACHE="${GITHUB_REF_NAME//-/_}" | |
echo "branch_name_for_cache=${BRANCH_NAME_FOR_CACHE}" >> "$GITHUB_ENV" | |
- name: Setup cache | |
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 everest-core | |
uses: actions/[email protected] | |
with: | |
path: source | |
- name: Setup run scripts | |
run: | | |
mkdir scripts | |
rsync -a source/.ci/build-kit/scripts/ 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 "$(pwd):/ext" \ | |
--name compile-container \ | |
build-kit run-script compile | |
- name: Commit compile-container | |
run: | | |
docker commit compile-container build-image | |
- name: Run unit tests | |
run: | | |
docker run \ | |
--volume "$(pwd):/ext" \ | |
--name unit-tests-container \ | |
build-image run-script run_unit_tests | |
- name: Create dist | |
run: | | |
docker run \ | |
--volume "$(pwd):/ext" \ | |
--name install-container \ | |
build-image run-script install | |
- name: Tar dist dir and keep permissions | |
run: | | |
tar -czf dist.tar.gz dist | |
- name: Upload dist artifact | |
uses: actions/[email protected] | |
with: | |
path: dist.tar.gz | |
name: dist | |
- name: Upload wheels artifact | |
uses: actions/[email protected] | |
with: | |
path: dist-wheels | |
name: wheels | |
- name: Archive unit test results | |
if: always() | |
uses: actions/[email protected] | |
with: | |
name: ctest-report | |
path: ${{ github.workspace }}/ctest-report | |
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 || 'ubuntu-22.04' }} | |
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 | |
uses: actions/[email protected] | |
with: | |
name: wheels | |
path: wheels | |
- name: Checkout everest-core | |
uses: actions/[email protected] | |
with: | |
path: source | |
- name: Setup run scripts | |
run: | | |
mkdir scripts | |
rsync -a source/.ci/build-kit/scripts/ 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 "$(pwd):/ext" \ | |
--name prepare-container \ | |
build-kit run-script prepare_integration_tests | |
docker commit prepare-container integration-image | |
- name: Run integration tests | |
run: | | |
pushd source/.ci/e2e | |
docker compose run \ | |
e2e-test-server \ | |
run-script run_integration_tests | |
- name: Upload result & report as artifact | |
if: always() | |
uses: actions/[email protected] | |
with: | |
path: | | |
${{ github.workspace }}/result.xml | |
${{ github.workspace }}/report.html | |
name: pytest-results | |
- name: Render result | |
if: always() | |
uses: pmeier/[email protected] | |
with: | |
path: ${{ github.workspace }}/result.xml | |
summary: True | |
display-options: fEX | |
fail-on-empty: True | |
title: Test results |