Skip to content

#1: add junit report to ci #29

#1: add junit report to ci

#1: add junit report to ci #29

# 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:
- 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: ~
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: Run (example)
# run: |
# CMD="uname -a"
# if [[ "${{ matrix.runner.image }}" == "" ]]
# then
# $CMD
# else
# docker run ${{ matrix.runner.image }} $CMD
# fi
# - name: Extract timestamps for caching
# run: |
# 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: Setup build cache (vt)
run: |
echo "TODO: implement cache usage if required by your project"
- name: PR tests env
run: |
echo 'TODO...'
echo '1. Load environment variables from a matrix file (env set per env id) into .env'
echo '2. Load .env file to build `export $(cat .env | egrep -v "(^#.*|^$)" | xargs) && ./build.sh`'
- 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 $(cat .env | egrep -v "(^#.*|^$)" | xargs) && ./build.sh'
echo "Running ${CMD}"
if [[ "${{ matrix.runner.image }}" == "" ]]; then
bash -c "$CMD";
else
docker run \
--name test-container \
-w $WORKSPACE \
-v ${{ github.workspace }}:/workspace \
-v /opt/foo/build:/opt/foo/build \
-v /opt/foo/output:/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 "FOO_TEST_REPORT=${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 != '' }}
uses: phoenix-actions/test-reporting@v15
with:
name: Tests report
path: ${{ env.JUNIT_REPORT }}
reporter: java-junit
output-to: step-summary
- name: Upload artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: foo-output-${{ matrix.runner.setup }}
path: /opt/foo/output