generated from DARMA-tasking/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (131 loc) · 5.13 KB
/
build-and-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# 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
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
run: |
FOO_SRC_DIR=${{ github.workspace }}
FOO_BUILD_DIR=/opt/foo/build
if [[ "${{ matrix.runner.image }}" != "" ]]; then
FOO_SRC_DIR=opt/foo/src
fi
CMD='
cd $FOO_SRC_DIR; \
chmod +x build.sh; \
\
FOO_BUILD_DIR=$FOO_BUILD_DIR \
FOO_COVERAGE_ENABLED=ON \
FOO_RUN_TESTS=ON \
build.sh;'
echo "Running ${CMD}"
if [[ "${{ matrix.runner.image }}" == "" ]]; then
bash -c "$CMD";
else
docker run \
--name test-container \
-w $FOO_SRC_DIR \
-v ${{ github.workspace }} :/opt/foo/src \
-v /opt/foo/build:/opt/foo/build \
-v /opt/foo/output:/opt/foo/output \
-e CI="1" \
-e CMAKE_CXX_STANDARD="17" \
-e CMAKE_BUILD_TYPE="Release" \
${{ matrix.runner.image }} \
bash -c "$CMD"
exit $(docker container inspect --format '{{.State.ExitCode}}' test-container)
fi
# - 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