This repository has been archived by the owner on Dec 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
before_install.sh
87 lines (70 loc) · 3.02 KB
/
before_install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
# Standardize dirs
export BASE_DIR=$GITHUB_WORKSPACE
echo "BASE_DIR=$BASE_DIR" >> $GITHUB_ENV
# Create .netrc file for GitHub authentication
echo "machine api.github.com
login RMGdev
password $GH_TOKEN" > $HOME/.netrc
# Parse message for Github Actions build
# commit message of current head of RMG-tests = SHA1-ID of RMG-Py/database commit to be tested.
MESSAGE=$(git log --format=%B -n 1 HEAD)
echo "Message: "$MESSAGE
# Remove the refs/heads/ prefix to the branch name
if [[ "$GITHUB_REF" == "refs/heads/"* ]];
then
export BRANCH=${GITHUB_REF:11}
echo "BRANCH=${GITHUB_REF:11}" >> $GITHUB_ENV
else
export BRANCH=$GITHUB_REF
echo "BRANCH=$GITHUB_REF" >> $GITHUB_ENV
fi
echo "Branch: "$BRANCH
# split the message on the '-' delimiter
IFS='-' read -a msg_pieces <<< "$MESSAGE"
IFS='-' read -a branch_pieces <<< "$BRANCH"
if [ "${branch_pieces[0]}" == "rmgdb" ]; then
export RMG_TESTING_BRANCH="main"
export RMGDB_TESTING_BRANCH="${branch_pieces[1]}"
export GITHUB_STATUS_PATH="/repos/ReactionMechanismGenerator/RMG-database/statuses/${msg_pieces[1]}"
elif [ "${branch_pieces[0]}" == "rmgpy" ]; then
export RMG_TESTING_BRANCH="${branch_pieces[1]}"
export RMGDB_TESTING_BRANCH="main"
export GITHUB_STATUS_PATH="/repos/ReactionMechanismGenerator/RMG-Py/statuses/${msg_pieces[1]}"
elif [ "${branch_pieces[0]}" == "rmgpydb" ]; then
export RMG_TESTING_BRANCH="${branch_pieces[1]}"
export RMGDB_TESTING_BRANCH="${msg_pieces[2]}"
export GITHUB_STATUS_PATH="/repos/ReactionMechanismGenerator/RMG-Py/statuses/${msg_pieces[1]}"
elif [ "${branch_pieces[0]}" == "rmgdbpy" ]; then
export RMGDB_TESTING_BRANCH="${branch_pieces[1]}"
export RMG_TESTING_BRANCH="${msg_pieces[2]}"
export GITHUB_STATUS_PATH="/repos/ReactionMechanismGenerator/RMG-database/statuses/${msg_pieces[1]}"
fi
# write the variables to the environment
echo "RMG_TESTING_BRANCH=$RMG_TESTING_BRANCH" >> $GITHUB_ENV
echo "RMGDB_TESTING_BRANCH=$RMGDB_TESTING_BRANCH" >> $GITHUB_ENV
echo "GITHUB_STATUS_PATH=$GITHUB_STATUS_PATH" >> $GITHUB_ENV
echo "RMG_TESTING_BRANCH: "$RMG_TESTING_BRANCH
echo "RMGDB_TESTING_BRANCH: "$RMGDB_TESTING_BRANCH
# Url of the Github Actions build page
export BUILD_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
echo "BUILD_URL=$BUILD_URL" >> $GITHUB_ENV
echo "GitHub URL: " $GITHUB_STATUS_PATH
echo "Build URL: " $BUILD_URL
# Update GitHub status to pending
./ok.sh _format_json \
state="pending" \
context="continuous-integration/rmg-tests" \
description="The RMG-tests build is running" \
target_url=$BUILD_URL \
| ./ok.sh _post $GITHUB_STATUS_PATH > /dev/null
# Set up anaconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
bash ./miniconda.sh -b -p $BASE_DIR/miniconda
source "$BASE_DIR/miniconda/etc/profile.d/conda.sh"
conda activate base
# add conda commands to .bash_profile
echo ". $BASE_DIR/miniconda/etc/profile.d/conda.sh" >> "$BASE_DIR/.bash_profile"
echo "conda activate base" >> "$BASE_DIR/.bash_profile"
# Update conda itself
conda update --yes conda