Skip to content

Commit

Permalink
GHA: Cleanup custom swig usage (#2200)
Browse files Browse the repository at this point in the history
* 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

* ..
  • Loading branch information
dweindl authored Nov 16, 2023
1 parent acf526a commit 32730f0
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 16 deletions.
20 changes: 20 additions & 0 deletions .github/actions/setup-swig/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Set up SWIG
description: |
Download and build SWIG and set the SWIG environment variable to the path of
the SWIG executable.
inputs:
swig_version:
description: 'Swig version to build'
required: false
default: '4.1.1'

runs:
using: "composite"
steps:
- name: Download and build SWIG
run: scripts/downloadAndBuildSwig.sh
shell: bash

- run: echo "SWIG=${AMICI_DIR}/ThirdParty/swig-${{ inputs.swig_version }}/install/bin/swig" >> $GITHUB_ENV
shell: bash
8 changes: 3 additions & 5 deletions .github/workflows/deploy_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ jobs:
with:
fetch-depth: 20

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

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

- name: Create AMICI sdist
run: |
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/deploy_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ jobs:
with:
fetch-depth: 20

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

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

- name: sdist
run: |
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/test_doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ jobs:
- run: git fetch --prune --unshallow

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

- name: Set up doxygen
uses: ./.github/actions/setup-doxygen
Expand All @@ -71,9 +70,7 @@ jobs:
pandoc \
python3-venv \
- name: Build swig
run: |
sudo scripts/downloadAndBuildSwig.sh
- uses: ./.github/actions/setup-swig

- name: sphinx
run: scripts/run-sphinx.sh
6 changes: 4 additions & 2 deletions scripts/downloadAndBuildSwig.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/usr/bin/env bash
# Download and build SWIG
set -e
#
# Usage: downloadAndBuildSwig.sh [swig_version]
set -euo pipefail

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

swig_version=4.1.1
swig_version="${1:-"4.1.1"}"
SWIG_ARCHIVE="swig-${swig_version}.tar.gz"
SWIG_URL="http://downloads.sourceforge.net/project/swig/swig/swig-${swig_version}/${SWIG_ARCHIVE}"
SWIG_DIR="swig-${swig_version}"
Expand Down

0 comments on commit 32730f0

Please sign in to comment.