-
Notifications
You must be signed in to change notification settings - Fork 0
/
misc_env
executable file
·42 lines (37 loc) · 1.63 KB
/
misc_env
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
#!/usr/bin/env bash
# This script sets the following environment variables for GitHub Actions:
# ROOT_DIR: the root directory of the current repo
# TEST_DIR: a random directory under /tmp for testing
# SEDI: sed -i "" (mocOS) or sed -i (Linux/Windows)
#
# Usage: bash misc_env
# Set ROOT_DIR to the root directory of the current repo.
ROOT_DIR="$(pwd -P)" # `realpath` is unavailable on macOS; -P is needed
echo "$ROOT_DIR"
echo "ROOT_DIR=$ROOT_DIR" >> "$GITHUB_ENV"
# Set TEST_DIR to a random directory. It is needed in the Makefiles for the Fortran tests of PRIM.
TEST_DIR=/tmp/gittest_$(date +%s)_"$((RANDOM*RANDOM))"
echo "$TEST_DIR"
echo "TEST_DIR=$TEST_DIR" >> "$GITHUB_ENV"
# Set SEDI to either 'sed -i ""' (macOS) or 'sed -i' (Linux/Windows).
# When calling "sed -i" on macOS, it is obligatory to specify a string (e.g., .bak) after -i as the
# extension for saving a backup. If the string is "", then no backup will be saved. If no string is
# specified, then an error will be raised, saying "invalid command code".
if [[ "$RUNNER_OS" = "macOS" ]] ; then
SEDI='sed -i ""'
else
SEDI='sed -i'
fi
echo "$SEDI"
echo "SEDI=$SEDI" >> "$GITHUB_ENV"
# Set GFORTRAN_VERSION to the version of gfortran used when mexifying and linting Fortran code.
GFORTRAN_VERSION=13
echo "$GFORTRAN_VERSION"
echo "GFORTRAN_VERSION=$GFORTRAN_VERSION" >> "$GITHUB_ENV"
# The following does not work. Why?
# Make tools such as grep, make, and git available on Windows.
#if [[ "$RUNNER_OS" = "Windows" ]] ; then
# PATH="$PATH"":/c/Program Files/Git/usr/bin:/c/Program Files/Git/bin:/c/ProgramData/Chocolatey/bin"
# echo "$PATH"
# echo "PATH=$PATH" >> "$GITHUB_ENV"
#fi