Skip to content

#1: try set clang as darwin compiler #53

#1: try set clang as darwin compiler

#1: try set clang as darwin compiler #53

# Template workflow (Github Workflows). VT example.
# Build and test a project in all available setup configurations provided by DARMA-taking/workflows.
# See also: Azure Pipelines version at ./azure/pipelines/build-and-test.yml
name: PR tests
on:
push:
branches:
- '*' # master
pull_request:
branches:
- '*'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CI_REPO: DARMA-tasking/workflows
CI_BRANCH: 2-implement-common-docker-containers # 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.CI_REPO }}/refs/heads/${{ env.CI_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:
JUNIT_REPORT_PATH: ~
TS_YEAR: ~
TS_MONTH: ~
TS_DAY: ~
TS: ~
BUILD_DIR: /opt/foo/build
OUTPUT_DIR: /opt/foo/output
CACHE_DIR: /opt/foo/build/ccache
COVERAGE_ENABLED: ${{ matrix.runner.name == 'wf-amd64-ubuntu-22.04-gcc-12-cpp' && 1 || 0 }}
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.CI_REPO }}/refs/heads/${{ env.CI_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
# TODO: remove the commented lines if
# - name: Extract timestamps for caching (using CMake as in VT)
# run: |
# echo "$1=$2" >> $GITHUB_ENV
# mkdir -p /opt/scripts
# cd /opt/scripts
# wget https://raw.githubusercontent.com/${{ env.CI_REPO }}/refs/heads/${{ env.CI_BRANCH }}/ci/shared/scripts/runner/set-variable.sh && chmod +x set-variable.sh
# wget https://raw.githubusercontent.com/${{ env.CI_REPO }}/refs/heads/${{ env.CI_BRANCH }}/ci/shared/scripts/runner/set-timestamps.sh && chmod +x set-timestamps.sh
# ./set-timestamps.sh
- 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: Output timestamp for caching
continue-on-error: true
run: |
echo "my pipeline variable is $(TS) $(TS_YEAR) $(TS_MONTH) $(TS_DAY)"
- name: Update cache
continue-on-error: true
uses: actions/cache@v3
env:
cache_name: ${{ matrix.runner.name }}
with:
path: ${{ env.CACHE_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; \
\
export FOO_COVERAGE_ENABLED=${{ env.COVERAGE_ENABLED }} && ./build.sh'
echo "Running ${CMD}"
if [[ "${{ matrix.runner.image }}" == "" ]]; then
source .env && bash -c "$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 [ $FOO_TEST_REPORT != "" ]; then
echo "JUNIT_REPORT_PATH=${FOO_TEST_REPORT}" >> "$GITHUB_OUTPUT"
else
# - name: Build and test
# TODO: Build an test step.
# > Option 1: Docker image (Environment Setup="docker") WIP
# - pull the docker image
# - build & Test using `docker exec [container] build_and_test.sh` for example or by using an inner build_and_test docker image
# - (TODO: copy artifacts using a volume)
# > Option 2: Current runner (Environment Setup="local") (Future for some macos)
# - setup dependencies here directly
# (Here a work needs to be done to determine how to get the dependencies script. It might be shared by the workflows repo and put in matrix)
# - build & Test using build_and_test.sh
# - name: Upload artifacts
# - name: Report test results
# note: (as in vt-tv or LBAF)
# - name: Report coverage
- name: Unit tests
if: ${{ 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 }}