Skip to content

Commit

Permalink
Make library compilation on CI work for PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
JanCBrammer committed Sep 19, 2024
1 parent 088c295 commit 6b1467d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
12 changes: 5 additions & 7 deletions .github/actions/compile_inchi_lib/action.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
name: Compile InChI library from triggering branch
name: Compile InChI library from triggering commit

runs:
using: "composite"
steps:
- run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE" # https://github.com/actions/runner-images/issues/6775
mkdir "$GITHUB_WORKSPACE/$LIB_DIR"
./INCHI-1-TEST/compile_inchi_lib.sh $BRANCH "$GITHUB_WORKSPACE/$LIB_DIR"
if [ "$BRANCH" != "main" ]; then
# Rename library to libinchi.so.main, since that's the name the tests expect.
mv "$GITHUB_WORKSPACE/$LIB_DIR/libinchi.so.$BRANCH" "$GITHUB_WORKSPACE/$LIB_DIR/libinchi.so.main"
fi
./INCHI-1-TEST/compile_inchi_lib.sh $COMMIT "$GITHUB_WORKSPACE/$LIB_DIR"
# Rename library to libinchi.so.main, since that's the name the tests expect.
mv "$GITHUB_WORKSPACE/$LIB_DIR/libinchi.so.$COMMIT" "$GITHUB_WORKSPACE/$LIB_DIR/libinchi.so.main"
shell: bash
env:
BRANCH: ${{ github.ref_name }}
COMMIT: ${{ github.sha }}
LIB_DIR: INCHI-1-TEST/libs
7 changes: 3 additions & 4 deletions INCHI-1-TEST/compile_inchi_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

inchi_version=$1 # Must be one of the tags in `git tag` or branches in `git branch`.
inchi_version=$1 # Must be one of the tags in `git tag`, branches in `git branch`, or a commit hash.
inchi_lib_dir=$2 # Path must be absolute.
current_branch=$(git rev-parse --abbrev-ref HEAD)
makefile_dir="INCHI-1-SRC/INCHI_API/libinchi/gcc"
Expand All @@ -24,21 +24,20 @@ if [ -n "$(git status --porcelain)" ]; then
exit 1
fi

# Check out the specified tag or branch.
if git rev-parse --verify --quiet refs/tags/$inchi_version; then
echo "Checking out version tag '$inchi_version'."
git checkout "tags/$inchi_version"
checkout_successful=1
fi

if git rev-parse --verify --quiet $inchi_version; then
echo "Checking out branch '$inchi_version'."
echo "Checking out branch or commit '$inchi_version'."
git checkout $inchi_version
checkout_successful=1
fi

if [ $checkout_successful -eq 0 ]; then
echo "Version tag or branch '$inchi_version' does not exist."
echo "'$inchi_version' does not exist."
exit 1
fi

Expand Down

0 comments on commit 6b1467d

Please sign in to comment.