Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1: create sample cmake project #2

Open
wants to merge 80 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
b81457d
#1: add sample foo cpp project
tlamonthezie Nov 27, 2024
f592297
#1: add first ci
tlamonthezie Nov 28, 2024
0e509cd
#1: add first env file for build variables
tlamonthezie Nov 28, 2024
cd9d611
#1: update ci test workflow
tlamonthezie Nov 28, 2024
4386e15
#1: fix command in ci
tlamonthezie Nov 28, 2024
94d8d89
#1: fix invalid variable in ci
tlamonthezie Nov 28, 2024
206fb23
#1: update build script
tlamonthezie Nov 28, 2024
bc9da6d
#1: try fix error in ci possibly caused by volumes mount
tlamonthezie Nov 28, 2024
c83b3ed
#1: remove coverage report for the moment in ci
tlamonthezie Nov 28, 2024
4621dbe
#1: update env file
tlamonthezie Nov 28, 2024
13664a7
#1: use latest google test release
tlamonthezie Nov 28, 2024
444c3b6
#1: add debug info to build script
tlamonthezie Nov 28, 2024
55c7a98
#1: test env update in CI
tlamonthezie Nov 28, 2024
fcdc4c9
#1: test turn off warnings in CI
tlamonthezie Nov 28, 2024
f7b5d00
#1: restore cmake variable and add a unit test
tlamonthezie Nov 28, 2024
84695ae
#1: add junit report to ci
tlamonthezie Nov 28, 2024
a52d5e1
#1: fix unique artifact name
tlamonthezie Nov 28, 2024
db0e250
#1: fix ci invalid variable
tlamonthezie Nov 28, 2024
9100016
#1: add google test as local lib
tlamonthezie Nov 29, 2024
ed8a55b
#1: add latest version of google test
tlamonthezie Dec 5, 2024
675b415
#1: add jq workflow matrix filter examples
tlamonthezie Dec 5, 2024
53cc43a
#1: refactor sample project options
tlamonthezie Dec 5, 2024
ec2df47
#1: fix unit tests path
tlamonthezie Dec 5, 2024
a3d3906
#1: update test script to build and test with docker
tlamonthezie Dec 11, 2024
f0d0276
#1: add ccache environment variables
tlamonthezie Dec 11, 2024
12624c3
#1: add ccache caching to ci
tlamonthezie Dec 11, 2024
bb7af6d
#1: enable coverage
tlamonthezie Dec 11, 2024
25216f9
#1: try fix lcov installation in ci
tlamonthezie Dec 11, 2024
7b12e89
#1: fix command in CI
tlamonthezie Dec 11, 2024
a55595f
#1: fix command in ci
tlamonthezie Dec 11, 2024
9e07450
#1: add missing char in ci script
tlamonthezie Dec 11, 2024
7718760
#1: update invalid ci command
tlamonthezie Dec 11, 2024
2e277d5
#1: test setting gcov in env file
tlamonthezie Dec 11, 2024
5c77d57
#1: fix env file
tlamonthezie Dec 11, 2024
c55bc3d
#1: turn on coverage only for the develop image
tlamonthezie Dec 12, 2024
c06a4ee
#1: detect cov report generator and add support of gcovr in build.sh
tlamonthezie Dec 12, 2024
561eaed
#1: remove lcov install in ci
tlamonthezie Dec 12, 2024
5f5153d
#1: update env loading in ci
tlamonthezie Dec 12, 2024
a0d66e8
#1: try changing compiler for macos in ci
tlamonthezie Dec 12, 2024
47fc739
#1: try set clang as darwin compiler
tlamonthezie Dec 12, 2024
1ffc338
#1: add implementation file for foo class
tlamonthezie Dec 12, 2024
3ccee39
#1: add implementation file for bar class
tlamonthezie Dec 12, 2024
89187b5
#1: remove unused comments
tlamonthezie Dec 12, 2024
1e0d829
#1: add missing new lines
tlamonthezie Dec 12, 2024
a947e65
#1: add missing new extra lines
tlamonthezie Dec 12, 2024
373753e
#1: fix invalid keyword in ci script
tlamonthezie Dec 12, 2024
6f9d17d
#1: try fix error in macos runner in ci
tlamonthezie Dec 12, 2024
15a9956
#1: fix possible syntax error in runner shell
tlamonthezie Dec 12, 2024
f570f1d
#1: try fix error in ci
tlamonthezie Dec 12, 2024
f61cba1
#1: try fix environment variables in runner ci
tlamonthezie Dec 12, 2024
a5adfee
#1: try fix UnitTest results display in ci
tlamonthezie Dec 12, 2024
ffcc6f2
#1: clean env file
tlamonthezie Dec 12, 2024
f589d81
#1: try fix env load in ci runner
tlamonthezie Dec 12, 2024
3ad70cb
#1: update environment loading in ci
tlamonthezie Dec 12, 2024
47736da
#1: update default compiler if apple
tlamonthezie Dec 12, 2024
f85b778
#1: update the build-in-docker script and environment variables
tlamonthezie Dec 12, 2024
fafdbd0
#1: add comments to build-in-docker script
tlamonthezie Dec 19, 2024
37aeb5b
#1: fix gcov detection in build script for gcc
tlamonthezie Dec 19, 2024
d00f8e5
#1: update pipelines yaml files and add steps to azure
tlamonthezie Dec 19, 2024
5210ce6
#1: update azure pipeline
tlamonthezie Dec 19, 2024
f1edf89
#1: update azure pipeline syntax
tlamonthezie Dec 19, 2024
dcaee12
#1: fix typos
tlamonthezie Dec 19, 2024
d7eca18
#1: use ci matrix from workflows master
tlamonthezie Dec 19, 2024
1aa3159
#1: try fix syntax in azure pipeline
tlamonthezie Dec 19, 2024
a6c7450
#1: fix trailing whitespaces
tlamonthezie Dec 19, 2024
bfe79e9
#1: remove azure pipeline step failing
tlamonthezie Dec 19, 2024
78cac49
#1: update workflow var name
tlamonthezie Dec 19, 2024
9720c10
#1: fix typo in ci
tlamonthezie Dec 19, 2024
4b7ceaa
#1: try fix artifacts reporting
tlamonthezie Dec 19, 2024
38ff008
#1: try fix azure ci
tlamonthezie Dec 19, 2024
b7d2410
#1: try fix source volume in azure ci
tlamonthezie Dec 19, 2024
3f21ca5
#1: fix unit tests names
tlamonthezie Dec 19, 2024
ddea759
#1: try rename tests step in azure
tlamonthezie Dec 19, 2024
31c5f98
#1: try fix artifacts directory on azure
tlamonthezie Dec 19, 2024
7d0c912
#1: try fix variable in azure ci for cache
tlamonthezie Dec 19, 2024
f1ac588
#1: fix cache name on azure
tlamonthezie Dec 19, 2024
aec4969
#1: update cache name in ci
tlamonthezie Dec 19, 2024
a5586a7
#1: try a fix in azure pipeline
tlamonthezie Dec 19, 2024
2ffaf62
#1: add comment in azure pipeline file
tlamonthezie Dec 19, 2024
33b0014
#1: try fix error with ccache dir in azure
tlamonthezie Dec 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 167 additions & 0 deletions .azure/pipelines/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
name: PR tests

trigger:
branches:
include:
- master

pr:
drafts: false
autoCancel: true
branches:
include:
- '*'
variables:
WF_REPO: DARMA-tasking/workflows
WF_BRANCH: 2-implement-common-docker-containers # master

jobs:
- job: getMatrix
pool:
vmImage: 'ubuntu-latest'
displayName: 'Get matrix'
steps:
# Note: Filtering the test environments
# A jq query can be used to filter the matrix of test environments
# - All (default): `matrix=$(cat azure.json | jq '.matrix')`
# - CLang only: `matrix=$(cat azure.json | jq '.matrix | map(select(.label | contains("clang")))')`
# - gcc>=11: `matrix=$(cat azure.json | jq '.matrix | map(select(.name | test("gcc-[1-9][1-9]+")))')`
# - gcc>=11|clang>=14 `matrix=$(cat azure.json | jq '.matrix | map(select(.name | test("gcc-[1-9][1-9]+-|clang-[1-9][2-9]+")))')`
- bash: |
wget https://raw.githubusercontent.com/${{ variables.WF_REPO }}/refs/heads/${{ variables.WF_BRANCH }}/ci/shared/matrix/azure.json
matrix=$(cat azure.json | jq -c '.matrix')
echo "##vso[task.setvariable variable=matrix;isOutput=true]$matrix"
displayName: 'Get matrix'
name: getMatrixStep

- job: run
displayName: 'Run'
dependsOn: getMatrix
strategy:
matrix: $[ dependencies.getMatrix.outputs['getMatrixStep.matrix'] ]
pool:
vmImage: $(vmImage)
timeoutInMinutes: 180
variables:
TS_YEAR: ~
TS_MONTH: ~
TS_DAY: ~
TS: ~
BUILD_DIR: /opt/foo/build
OUTPUT_DIR: /opt/foo/output
CCACHE_DIR: /opt/foo/build/ccache
COVERAGE_ENABLED: 0
JUNIT_REPORT_PATH: /opt/foo/output/junit.xml
cache_name: $(name)
steps:
- checkout: self
fetchDepth: 0
- bash: |
echo "Environment=$(label)"
echo "Runner=$(vmImage)"
if [ "$(image)" != "" ]
then
echo "> With Docker Image=$(image)"
else
echo "> With Runner Setup=$(setup)"
fi
displayName: Display configuration

- bash: |
if [ "$(name)" == "wf-amd64-ubuntu-22.04-gcc-12-cpp" ]
then
echo "##vso[task.setvariable variable=COVERAGE_ENABLED]1"
fi
if [[ "$(image)" == "" ]]; then
echo "::group::Setup in runner"
echo "Set setup permissions..."
sudo mkdir -p /opt
sudo chown $(whoami) /opt
wget -O setup.sh https://raw.githubusercontent.com/${{ variables.CI_REPO }}/refs/heads/${{ variables.CI_BRANCH }}/ci/shared/scripts/setup-$(setup).sh
chmod +x setup.sh
export WF_SETUP_ID=$(setup)
./setup.sh
echo "::endgroup::"
elif [[ "$(image)" != "" ]]; then
echo "::group::Pull Docker image"
docker image pull $(image)
echo "::endgroup::"
fi
displayName: Set up dependencies

- bash: |
echo "##vso[task.setvariable variable=TS_YEAR]$(date -u +%Y)"
echo "##vso[task.setvariable variable=TS_MONTH]$(date -u +%m)"
echo "##vso[task.setvariable variable=TS_DAY]$(date -u +%d)"
echo "##vso[task.setvariable variable=TS]$(date -u +%H%M%S)"
displayName: Build timestamp for caching

- task: Cache@2
displayName: Update cache
continueOnError: true
inputs:
securityNamespace: cache
key: $(Agent.OS) | "$(cache_name)" | $(TS_YEAR) | $(TS_MONTH) | $(TS_DAY) | $(TS)
path: $(CCACHE_DIR)
restoreKeys: |
$(Agent.OS) | "$(cache_name)" | $(TS_YEAR) | $(TS_MONTH) | $(TS_DAY)
$(Agent.OS) | "$(cache_name)" | $(TS_YEAR) | $(TS_MONTH)
$(Agent.OS) | "$(cache_name)" | $(TS_YEAR)
$(Agent.OS) | "$(cache_name)"

- bash: |
mkdir -p $(CCACHE_DIR)
WORKSPACE=$(Pipeline.Workspace)/s
if [[ "$(image)" != "" ]]; then
WORKSPACE=/workspace
fi
CMD='
cd '${WORKSPACE}'; \
ls -l; \
chmod +x ./build.sh; \
\
FOO_COVERAGE_ENABLED="$(COVERAGE_ENABLED)" \
FOO_TEST_REPORT="$(JUNIT_REPORT_PATH)" \
./build.sh'

echo "Running ${CMD}"

if [[ "$(image)" == "" ]]; then
bash -c "export $(cat .env | sed '/^[[:blank:]]*#/d;s/#.*//' | xargs) && $CMD";
else
docker run \
--name test-container \
--env-file .env \
-w $WORKSPACE \
-v $(Pipeline.Workspace)/s:/workspace \
-v $(BUILD_DIR):/opt/foo/build \
-v $(OUTPUT_DIR):/opt/foo/output \
-e CI="1" \
-e https_proxy="" \
-e http_proxy="" \
$(image) \
bash -c "$CMD"
exit $(docker container inspect --format '{{.State.ExitCode}}' test-container)
fi

if [ -f "$FOO_TEST_REPORT" ]; then
echo "##vso[task.setvariable variable=JUNIT_REPORT_PATH]${FOO_TEST_REPORT}"
fi
displayName: PR tests

- task: PublishTestResults@2
displayName: Tests ($(name))
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: $(JUNIT_REPORT_PATH)

- task: PublishPipelineArtifact@1
displayName: Upload artifacts
continueOnError: true
inputs:
targetPath: $(OUTPUT_DIR)
artifact: foo-output-$(name)
publishLocation: 'pipeline'

# FEAT: include also coverage reporting for Azure (require cobertura or JaCoCo format)
# task: PublishCodeCoverageResults@1
26 changes: 26 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Common environment variables to build and run the foo library

# Usage: `source .env && build.sh`

# CCache
CCACHE_COMPILERCHECK=content
CCACHE_COMPRESS=1
CCACHE_COMPRESSLEVEL=5
CCACHE_MAXSIZE=700M
# Note: If building with a docker image you should use a specific cache directory
# CCACHE_DIR=/opt/foo/build/ccache-{image_tag}
CCACHE_DIR=/opt/foo/build/ccache

# Compile
CMAKE_CXX_STANDARD=17
CMAKE_BUILD_TYPE=Release

# Project
FOO_BUILD_DIR=/opt/foo/build
FOO_OUTPUT_DIR=/opt/foo/output
FOO_TESTS_ENABLED=ON
FOO_RUN_TESTS=ON
FOO_CLEAN=OFF
FOO_WERROR_ENABLED=ON
FOO_COVERAGE_ENABLED=OFF
FOO_COVERAGE_REPORT=/opt/foo/output/cov
175 changes: 175 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
name: PR tests

on:
push:
branches:
- '*' # master
pull_request:
branches:
- '*'

env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WF_REPO: DARMA-tasking/workflows
WF_BRANCH: master

jobs:
get-matrix:
name: Get matrix
runs-on: ubuntu-latest
steps:
# Note: Filtering the test environments
# A jq query can be used to filter the matrix of test environments
# - All (default): `matrix=$(cat github.json | jq '.matrix')`
# - CLang only: `matrix=$(cat github.json | jq '.matrix | map(select(.label | contains("clang")))')`
# - gcc>=11: `matrix=$(cat github.json | jq '.matrix | map(select(.name | test("gcc-[1-9][1-9]+")))')`
# - gcc>=11|clang>=14 `matrix=$(cat github.json | jq '.matrix | map(select(.name | test("gcc-[1-9][1-9]+-|clang-[1-9][2-9]+")))')`
- name: Get matrix
id: get-matrix
run: |
wget https://raw.githubusercontent.com/${{ env.WF_REPO }}/refs/heads/${{ env.WF_BRANCH }}/ci/shared/matrix/github.json
matrix=$(cat github.json | jq '.matrix')
echo "runner=$(echo $matrix)" >> $GITHUB_OUTPUT

outputs:
matrix: ${{ steps.get-matrix.outputs.runner }}

run:
name: Run ${{ matrix.runner.name }}
runs-on: ${{ matrix.runner.runs-on }}
needs: get-matrix
env:
TS_YEAR: ~
TS_MONTH: ~
TS_DAY: ~
TS: ~
BUILD_DIR: /opt/foo/build
OUTPUT_DIR: /opt/foo/output
CCACHE_DIR: /opt/foo/build/ccache
COVERAGE_ENABLED: ${{ matrix.runner.name == 'wf-amd64-ubuntu-22.04-gcc-12-cpp' && 1 || 0 }}
JUNIT_REPORT_PATH: /opt/foo/output/junit.xml
strategy:
fail-fast: false
matrix:
runner: ${{ fromJson(needs.get-matrix.outputs.matrix ) }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Display configuration
run: |
echo "Environment=${{ matrix.runner.name }}"
echo "Runner=${{ matrix.runner.runs-on }}"
if [ "${{ matrix.runner.image }}" != "" ]
then
echo "> With Docker Image=${{ matrix.runner.image }}"
else
echo "> With Runner Setup=${{ matrix.runner.setup }}"
fi

- name: Set up dependencies
run: |
if [[ "${{ matrix.runner.image }}" == "" ]]; then
echo "::group::Setup in runner"
echo "Set setup permissions..."
sudo mkdir -p /opt
sudo chown $(whoami) /opt
wget -O setup.sh https://raw.githubusercontent.com/${{ env.WF_REPO }}/refs/heads/${{ env.WF_BRANCH }}/ci/shared/scripts/setup-${{ matrix.runner.setup }}.sh
chmod +x setup.sh
export WF_SETUP_ID=${{ matrix.runner.setup }}
./setup.sh
echo "::endgroup::"
elif [ "${{ matrix.runner.image }}" != "" ]; then
echo "::group::Pull Docker image"
docker image pull ${{ matrix.runner.image }}
echo "::endgroup::"
fi

- name: Display System Information
run: |
CMD="uname -a"
if [[ "${{ matrix.runner.image }}" == "" ]]
then
echo "Runner System Information:"
$CMD
else
echo "Docker System Information:"
docker run ${{ matrix.runner.image }} $CMD
fi

- name: Build timestamp for caching
continue-on-error: true
run: |
echo "TS_YEAR=$(date -u +%Y)" >> $GITHUB_ENV
echo "TS_MONTH=$(date -u +%m)" >> $GITHUB_ENV
echo "TS_DAY=$(date -u +%d)" >> $GITHUB_ENV
echo "TS=$(date -u +%H%M%S)" >> $GITHUB_ENV

- name: Update cache
continue-on-error: true
uses: actions/cache@v3
env:
cache_name: ${{ matrix.runner.name }}
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ runner.os }}-${{ env.cache_name }}-${{ env.TS_YEAR }}-${{ env.TS_MONTH }}-${{ env.TS_DAY }}-${{ env.TS }}
restore-keys: |
${{ runner.os }}-${{ env.cache_name }}-${{ env.TS_YEAR }}-${{ env.TS_MONTH }}-${{ env.TS_DAY }}-
${{ runner.os }}-${{ env.cache_name }}-${{ env.TS_YEAR }}-${{ env.TS_MONTH }}-
${{ runner.os }}-${{ env.cache_name }}-${{ env.TS_YEAR }}-
${{ runner.os }}-${{ env.cache_name }}-

- name: PR tests
run: |
WORKSPACE=${{ github.workspace }}
if [[ "${{ matrix.runner.image }}" != "" ]]; then
WORKSPACE=/workspace
fi
CMD='
cd '${WORKSPACE}'; \
ls -l; \
chmod +x ./build.sh; \
\
FOO_COVERAGE_ENABLED="${{ env.COVERAGE_ENABLED }}" \
FOO_TEST_REPORT="${{ env.JUNIT_REPORT_PATH }}" \
./build.sh'

echo "Running ${CMD}"

if [[ "${{ matrix.runner.image }}" == "" ]]; then
bash -c "export $(cat .env | sed '/^[[:blank:]]*#/d;s/#.*//' | xargs) && $CMD";
else
docker run \
--name test-container \
--env-file .env \
-w $WORKSPACE \
-v ${{ github.workspace }}:/workspace \
-v ${{ env.BUILD_DIR }}:/opt/foo/build \
-v ${{ env.OUTPUT_DIR }}:/opt/foo/output \
-e CI="1" \
-e https_proxy="" \
-e http_proxy="" \
${{ matrix.runner.image }} \
bash -c "$CMD"
exit $(docker container inspect --format '{{.State.ExitCode}}' test-container)
fi

if [ -f "$FOO_TEST_REPORT" ]; then
echo "JUNIT_REPORT_PATH=${FOO_TEST_REPORT}" >> "$GITHUB_OUTPUT"
fi

- name: Unit tests
if: (success() || failure()) && ${{ env.JUNIT_REPORT_PATH != '' }}
uses: phoenix-actions/test-reporting@v15
with:
name: Tests report
path: ${{ env.JUNIT_REPORT_PATH }}
reporter: java-junit
output-to: step-summary

- name: Upload artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: foo-output-${{ matrix.runner.name }}
path: ${{ env.OUTPUT_DIR }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/
output/
Loading
Loading