Skip to content

Commit 32730f0

Browse files
authored
GHA: Cleanup custom swig usage (#2200)
* GHA: Cleanup custom swig usage * Previously the newest swig was downloaded and built, but not used because of a wrong path. Fixed here. * Make scripts/downloadAndBuildSwig.sh accept a version number argument * Use composite action to make it more maintainable and avoid issues as fixed above * ..
1 parent acf526a commit 32730f0

File tree

5 files changed

+31
-16
lines changed

5 files changed

+31
-16
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Set up SWIG
2+
description: |
3+
Download and build SWIG and set the SWIG environment variable to the path of
4+
the SWIG executable.
5+
6+
inputs:
7+
swig_version:
8+
description: 'Swig version to build'
9+
required: false
10+
default: '4.1.1'
11+
12+
runs:
13+
using: "composite"
14+
steps:
15+
- name: Download and build SWIG
16+
run: scripts/downloadAndBuildSwig.sh
17+
shell: bash
18+
19+
- run: echo "SWIG=${AMICI_DIR}/ThirdParty/swig-${{ inputs.swig_version }}/install/bin/swig" >> $GITHUB_ENV
20+
shell: bash

.github/workflows/deploy_branch.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ jobs:
2121
with:
2222
fetch-depth: 20
2323

24-
- run: echo "AMICI_DIR=$(pwd)" >> $GITHUB_ENV
25-
- run: echo "SWIG=${AMICI_DIR}/ThirdParty/swig-4.0.1/install/bin/swig" >> $GITHUB_ENV
24+
- name: Set up SWIG
25+
uses: ./.github/actions/setup-swig
2626

27-
- name: Build swig4
28-
run: |
29-
sudo scripts/downloadAndBuildSwig.sh
27+
- run: echo "AMICI_DIR=$(pwd)" >> $GITHUB_ENV
3028

3129
- name: Create AMICI sdist
3230
run: |

.github/workflows/deploy_release.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ jobs:
2424
with:
2525
fetch-depth: 20
2626

27-
- run: echo "AMICI_DIR=$(pwd)" >> $GITHUB_ENV
28-
- run: echo "SWIG=${AMICI_DIR}/ThirdParty/swig-4.0.1/install/bin/swig" >> $GITHUB_ENV
27+
- name: Set up SWIG
28+
uses: ./.github/actions/setup-swig
2929

30-
- name: Build swig4
31-
run: |
32-
sudo scripts/downloadAndBuildSwig.sh
30+
- run: echo "AMICI_DIR=$(pwd)" >> $GITHUB_ENV
3331

3432
- name: sdist
3533
run: |

.github/workflows/test_doc.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ jobs:
5555
- run: git fetch --prune --unshallow
5656

5757
- run: echo "AMICI_DIR=$(pwd)" >> $GITHUB_ENV
58-
- run: echo "SWIG=${AMICI_DIR}/ThirdParty/swig-4.1.1/install/bin/swig" >> $GITHUB_ENV
5958

6059
- name: Set up doxygen
6160
uses: ./.github/actions/setup-doxygen
@@ -71,9 +70,7 @@ jobs:
7170
pandoc \
7271
python3-venv \
7372
74-
- name: Build swig
75-
run: |
76-
sudo scripts/downloadAndBuildSwig.sh
73+
- uses: ./.github/actions/setup-swig
7774

7875
- name: sphinx
7976
run: scripts/run-sphinx.sh

scripts/downloadAndBuildSwig.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#!/usr/bin/env bash
22
# Download and build SWIG
3-
set -e
3+
#
4+
# Usage: downloadAndBuildSwig.sh [swig_version]
5+
set -euo pipefail
46

57
SCRIPT_PATH=$(dirname "$BASH_SOURCE")
68
AMICI_PATH=$(cd "$SCRIPT_PATH/.." && pwd)
79

8-
swig_version=4.1.1
10+
swig_version="${1:-"4.1.1"}"
911
SWIG_ARCHIVE="swig-${swig_version}.tar.gz"
1012
SWIG_URL="http://downloads.sourceforge.net/project/swig/swig/swig-${swig_version}/${SWIG_ARCHIVE}"
1113
SWIG_DIR="swig-${swig_version}"

0 commit comments

Comments
 (0)