Skip to content

Commit 94df8a6

Browse files
Bring Repo to Working State (#1)
Co-authored-by: Ishaan Desai <[email protected]>
1 parent 1ef0430 commit 94df8a6

File tree

3 files changed

+200
-19
lines changed

3 files changed

+200
-19
lines changed

.github/workflows/test.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: 'Test setup-precice-action'
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- develop
7+
pull_request:
8+
branches:
9+
- main
10+
- develop
11+
12+
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: true
18+
matrix:
19+
precice-version: ['develop', 'main', 'v2.5.0']
20+
21+
steps:
22+
- name: Check out repository
23+
uses: actions/checkout@v3
24+
25+
- name: debug
26+
run: |
27+
echo $GITHUB_WORKSPACE
28+
ls -la
29+
echo $PWD
30+
31+
- name: Set up preCICE
32+
uses: ./
33+
with:
34+
precice-version: ${{ matrix.precice-version }}
35+
build-tests: 'ON'
36+
37+
- name: Check release version
38+
id: check-release
39+
run: |
40+
if [[ ${{ matrix.precice-version }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
41+
echo "release=true" >> $GITHUB_OUTPUT
42+
echo "release=true"
43+
else
44+
echo "release=false" >> $GITHUB_OUTPUT
45+
echo "release=false"
46+
fi
47+
48+
- name: debug
49+
run: |
50+
echo ${{ steps.check-release.outputs.release }}
51+
echo $GITHUB_WORKSPACE
52+
ls -la
53+
echo $PWD
54+
echo $LD_LIBRARY_PATH
55+
56+
57+
- name: Run tests if not release tag
58+
if: steps.check-release.outputs.release == 'false'
59+
working-directory: precice/build
60+
run: |
61+
ctest
62+
make test_install

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,27 @@
1-
# setup-precice-action
1+
# setup-precice-action
2+
3+
This action installs preCICE in the given prefix and adds it to the path.
4+
5+
## Inputs
6+
7+
### `precice-version`
8+
9+
The version of preCICE to use. Can be a branch or tag or SHA. Defaults to `develop`
10+
11+
### `install-prefix`
12+
13+
The installation prefix for preCICE. Default is `/usr/local`
14+
15+
### `build-tests`
16+
17+
Whether to build tests. Should be `OFF` off for all non-develop builds. Defaults to `OFF`
18+
19+
## Example usage
20+
21+
```yml
22+
- name: build preCICE
23+
uses: precice/setup-precice-action@main
24+
with:
25+
precice-version: develop
26+
install-prefix: /usr/local
27+
```

action.yml

Lines changed: 111 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,141 @@
11
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.'
33

44
inputs:
55
precice-version:
66
required: true
77
default: 'develop'
88
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`'
917

1018
runs:
1119
using: "composite"
1220
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+
1369
- name: check out repository
70+
if: steps.check.outputs.release == 'false' && steps.cache.outputs.cache-hit != 'true'
1471
uses: actions/checkout@v3
1572
with:
1673
repository: precice/precice
1774
ref: ${{ inputs.precice-version }}
75+
path: precice
76+
env:
77+
GITHUB_WORKSPACE: $HOME
1878

1979
- 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
2385

2486
- 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
2699

27100
- 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
29106
run: |
30107
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 }} ..
32109
33110
- 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
35116
run: |
36117
make -j $(nproc)
37-
38-
- name: Install
39-
working-directory: build
40-
run: make install
118+
make install
41119
42120
- 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

Comments
 (0)