-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmisc_env
More file actions
executable file
·47 lines (43 loc) · 2.31 KB
/
misc_env
File metadata and controls
executable file
·47 lines (43 loc) · 2.31 KB
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
#!/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 "" (macOS/FreeBSD) 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=$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 PRIMA.
TEST_DIR=/tmp/gittest_$(date +%s)_"$((RANDOM*RANDOM))"
echo "TEST_DIR=$TEST_DIR"
echo "TEST_DIR=$TEST_DIR" >> "$GITHUB_ENV"
# Set SEDI to either 'sed -i ""' (macOS/FreeBSD) or 'sed -i' (Linux/Windows).
# When calling "sed -i" on macOS and FreeBSD, 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 [[ "$(uname)" == Darwin || "$(uname)" == FreeBSD ]] ; then
SEDI='sed -i ""'
else
SEDI='sed -i'
fi
echo "SEDI=$SEDI"
echo "SEDI=$SEDI" >> "$GITHUB_ENV"
# Zaikun 20260215: As of 20260215, the following is not needed. In addition, on windows-2025, it will
# make gfortran fail due to missing DLL, and consequently, Makefile fail with Error -1073741515
# (interestingly, the same problem does not occur on windows-11-arm); more seriously, it even makes
# windows-2025 fail to recognize cmd.exe ("The term 'cmd.exe' is not recognized as a name of a cmdlet,
# function, script file, or executable program"). In brief, it will destroy the windows-2025 runner.
# No idea why. Anyway, don't do it!
#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
## 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"
# type grep && grep --version || true
# type make && make --version || true
# type git && git --version || true
#fi
#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX