1
1
name : ' Build preCICE'
2
- description : ' Installs preCICE and adds it to the path. Ends in `$GITHUB_WORKSPACE/precice` '
2
+ description : ' Installs preCICE in the given prefix and adds it to the path.'
3
3
4
4
inputs :
5
5
precice-version :
6
6
required : true
7
7
default : ' develop'
8
8
description : ' The version of preCICE to use. Can be a branch or tag or SHA. Defaults to `develop`'
9
+ build-tests :
10
+ required : false
11
+ default : ' OFF'
12
+ description : ' Whether to build tests. Default is `OFF`'
13
+ install-prefix :
14
+ required : false
15
+ default : ' $HOME/precice'
16
+ description : ' The installation prefix for preCICE. Default is `$HOME/precice`'
9
17
10
18
runs :
11
19
using : " composite"
12
20
steps :
21
+
22
+ - name : check for release # if the version is a release, install from prebuilt binaries
23
+ id : check
24
+ shell : bash
25
+ run : |
26
+ if [[ ${{ inputs.precice-version }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
27
+ echo "release=true" >> $GITHUB_OUTPUT
28
+ else
29
+ echo "release=false" >> $GITHUB_OUTPUT
30
+ fi
31
+
32
+ - name : install prebuilt binaries
33
+ if : steps.check.outputs.release == 'true'
34
+ shell : bash
35
+ run : |
36
+ sudo apt update
37
+ sudo apt install -y wget
38
+ VERSION=${{ inputs.precice-version }}
39
+ wget https://github.com/precice/precice/releases/download/${VERSION}/libprecice2_${VERSION#v}_$(lsb_release -cs).deb
40
+ sudo apt install -y ./libprecice2_${VERSION#v}_$(lsb_release -cs).deb
41
+ rm libprecice2_${VERSION#v}_$(lsb_release -cs).deb
42
+
43
+ - name : Get preCICE version hash
44
+ if : steps.check.outputs.release == 'false'
45
+ id : get-hash
46
+ shell : bash
47
+ run : |
48
+ echo "precice-hash=$(git ls-remote --exit-code --heads https://github.com/precice/precice.git ${{ inputs.precice-version }} | awk '{print $1}')" >> $GITHUB_OUTPUT
49
+
50
+ - name : cache preCICE
51
+ id : cache
52
+ if : steps.check.outputs.release == 'false'
53
+ uses : actions/cache@v3
54
+ with :
55
+ path : ${{ inputs.install-prefix }}
56
+ key : ${{ runner.os }}-precice-${{ steps.get-hash.outputs.precice-hash }}
57
+ restore-keys : |
58
+ ${{ runner.os }}-precice-${{ steps.get-hash.outputs.precice-hash }}
59
+
60
+ - name : debug
61
+ if : steps.check.outputs.release == 'false'
62
+ shell : bash
63
+ run : |
64
+ echo "cache-hit=${{ steps.cache.outputs.cache-hit }}"
65
+ echo "precice-hash=${{ steps.get-hash.outputs.precice-hash }}"
66
+ echo "precice-version=${{ inputs.precice-version }}"
67
+ echo "install-prefix=${{ inputs.install-prefix }}"
68
+
13
69
- name : check out repository
70
+ if : steps.check.outputs.release == 'false' && steps.cache.outputs.cache-hit != 'true'
14
71
uses : actions/checkout@v3
15
72
with :
16
73
repository : precice/precice
17
74
ref : ${{ inputs.precice-version }}
75
+ path : precice
76
+ env :
77
+ GITHUB_WORKSPACE : $HOME
18
78
19
79
- name : install dependencies
20
- run : |
21
- apt update
22
- apt install -y build-essential cmake libeigen3-dev libxml2-dev libboost-all-dev petsc-dev python3-dev python3-numpy
80
+ if : steps.check.outputs.release == 'false' && steps.cache.outputs.cache-hit != 'true'
81
+ run : |
82
+ sudo apt update
83
+ sudo apt install -y build-essential cmake libeigen3-dev libxml2-dev libboost-all-dev petsc-dev python3-dev python3-numpy
84
+ shell : bash
23
85
24
86
- name : Generate build directory
25
- run : mkdir -p build
87
+ if : steps.check.outputs.release == 'false' && steps.cache.outputs.cache-hit != 'true'
88
+ shell : bash
89
+ working-directory : precice
90
+ env :
91
+ GITHUB_WORKSPACE : $HOME
92
+ run : mkdir -p build
93
+
94
+ - name : Show preCICE state
95
+ if : steps.check.outputs.release == 'false' && steps.cache.outputs.cache-hit != 'true'
96
+ shell : bash
97
+ working-directory : precice
98
+ run : git log -n 1
26
99
27
100
- name : Configure
28
- working-directory : build
101
+ if : steps.check.outputs.release == 'false' && steps.cache.outputs.cache-hit != 'true'
102
+ shell : bash
103
+ working-directory : precice/build
104
+ env :
105
+ GITHUB_WORKSPACE : $HOME
29
106
run : |
30
107
cmake --version
31
- cmake -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/precice - DCMAKE_BUILD_TYPE=Release -DPRECICE_PETScMapping=OFF -DPRECICE_Python_Actions=OFF ..
108
+ cmake -DCMAKE_INSTALL_PREFIX=${{ inputs.install-prefix }} - DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=${{ inputs.build-tests }} ..
32
109
33
110
- name : Compile
34
- working-directory : build
111
+ if : steps.check.outputs.release == 'false' && steps.cache.outputs.cache-hit != 'true'
112
+ shell : bash
113
+ working-directory : precice/build
114
+ env :
115
+ GITHUB_WORKSPACE : $HOME
35
116
run : |
36
117
make -j $(nproc)
37
-
38
- - name : Install
39
- working-directory : build
40
- run : make install
118
+ make install
41
119
42
120
- name : Add to path
43
- run : |
44
- echo "$GITHUB_WORKSPACE/precice/bin" >> $PATH
45
- echo "$GITHUB_WORKSPACE/precice/lib" >> $LD_LIBRARY_PATH
46
- echo "$GITHUB_WORKSPACE/precice/include" >> $CPATH
47
- echo "$GITHUB_WORKSPACE/precice/lib/pkgconfig" >> $PKG_CONFIG_PATH
48
- echo "$GITHUB_WORKSPACE/precice" >> $CMAKE_PREFIX_PATH
121
+ if : steps.check.outputs.release == 'false' && steps.cache.outputs.cache-hit != 'true'
122
+ shell : bash
123
+ run : |
124
+ echo "PATH=$HOME/precice/bin:$PATH" >> $GITHUB_ENV
125
+ echo "LD_LIBRARY_PATH=$HOME/precice/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
126
+ echo "PKG_CONFIG_PATH=$HOME/precice/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV
127
+ echo "CPATH=$HOME/precice/include:$CPATH" >> $GITHUB_ENV
128
+ echo "CMAKE_PREFIX_PATH=$HOME/precice:$CMAKE_PREFIX_PATH" >> $GITHUB_ENV
129
+
130
+ - name : More debugging
131
+ if : steps.check.outputs.release == 'false' && steps.cache.outputs.cache-hit != 'true'
132
+ shell : bash
133
+ run : |
134
+ ls -l $HOME/precice/
135
+
136
+ - name : cache preCICE
137
+ if : steps.check.outputs.release == 'false' && steps.cache.outputs.cache-hit != 'true'
138
+ uses : actions/cache/save@v3
139
+ with :
140
+ path : ${{ inputs.install-prefix }}
141
+ key : ${{ runner.os }}-precice-${{ steps.get-hash.outputs.precice-hash }}
0 commit comments