Junxiao Shi | 439d972 | 2015-03-20 15:08:44 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Davide Pesavento | bd3642f | 2022-08-12 18:19:31 -0400 | [diff] [blame] | 2 | set -eo pipefail |
Junxiao Shi | 439d972 | 2015-03-20 15:08:44 -0700 | [diff] [blame] | 3 | |
Davide Pesavento | bd3642f | 2022-08-12 18:19:31 -0400 | [diff] [blame] | 4 | case $(uname) in |
| 5 | Linux) |
| 6 | if [[ -e /etc/os-release ]]; then |
| 7 | source /etc/os-release |
| 8 | else |
| 9 | source /usr/lib/os-release |
| 10 | fi |
| 11 | export ID VERSION_ID |
| 12 | export ID_LIKE="${ID} ${ID_LIKE} linux" |
Davide Pesavento | 0771dc5 | 2025-03-25 01:15:30 -0400 | [diff] [blame^] | 13 | if [[ -z $GITHUB_ACTIONS ]]; then |
| 14 | export PATH="${HOME}/.local/bin${PATH:+:}${PATH}" |
| 15 | fi |
Davide Pesavento | bd3642f | 2022-08-12 18:19:31 -0400 | [diff] [blame] | 16 | ;; |
| 17 | Darwin) |
| 18 | # Emulate a subset of os-release(5) |
| 19 | export ID=macos |
| 20 | export VERSION_ID=$(sw_vers -productVersion) |
Davide Pesavento | 0771dc5 | 2025-03-25 01:15:30 -0400 | [diff] [blame^] | 21 | if [[ -z $GITHUB_ACTIONS ]]; then |
| 22 | export PATH="/usr/local/bin${PATH:+:}${PATH}" |
| 23 | fi |
Davide Pesavento | bd3642f | 2022-08-12 18:19:31 -0400 | [diff] [blame] | 24 | if [[ -x /opt/homebrew/bin/brew ]]; then |
| 25 | eval "$(/opt/homebrew/bin/brew shellenv)" |
| 26 | elif [[ -x /usr/local/bin/brew ]]; then |
| 27 | eval "$(/usr/local/bin/brew shellenv)" |
| 28 | fi |
| 29 | ;; |
| 30 | esac |
| 31 | |
Davide Pesavento | d839882 | 2020-03-29 18:46:19 -0400 | [diff] [blame] | 32 | export CACHE_DIR=${CACHE_DIR:-/tmp} |
Davide Pesavento | d66fb49 | 2022-11-30 19:52:35 -0500 | [diff] [blame] | 33 | |
Davide Pesavento | 0771dc5 | 2025-03-25 01:15:30 -0400 | [diff] [blame^] | 34 | if [[ $JOB_NAME == *code-coverage ]]; then |
| 35 | export DISABLE_ASAN=1 |
| 36 | export DISABLE_HEADERS_CHECK=1 |
Davide Pesavento | d66fb49 | 2022-11-30 19:52:35 -0500 | [diff] [blame] | 37 | fi |
Davide Pesavento | a1a9d70 | 2020-03-29 00:58:15 -0400 | [diff] [blame] | 38 | |
Davide Pesavento | ad26607 | 2023-03-07 21:10:55 -0500 | [diff] [blame] | 39 | # https://reproducible-builds.org/docs/source-date-epoch/ |
| 40 | export SOURCE_DATE_EPOCH=$(git log -1 --format=%ct) |
| 41 | |
Davide Pesavento | cbef7b8 | 2019-10-09 00:15:13 -0400 | [diff] [blame] | 42 | for file in .jenkins.d/*; do |
Junxiao Shi | 439d972 | 2015-03-20 15:08:44 -0700 | [diff] [blame] | 43 | [[ -f $file && -x $file ]] || continue |
Davide Pesavento | cbef7b8 | 2019-10-09 00:15:13 -0400 | [diff] [blame] | 44 | |
Davide Pesavento | e8c82ef | 2021-07-28 02:38:51 -0400 | [diff] [blame] | 45 | if [[ -n $GITHUB_ACTIONS ]]; then |
Davide Pesavento | 2c8ec07 | 2021-09-30 00:04:23 -0400 | [diff] [blame] | 46 | label=$(basename "$file" | sed -E 's/[[:digit:]]+-(.*)\..*/\1/') |
Davide Pesavento | e8c82ef | 2021-07-28 02:38:51 -0400 | [diff] [blame] | 47 | echo "::group::${label}" |
Davide Pesavento | cbef7b8 | 2019-10-09 00:15:13 -0400 | [diff] [blame] | 48 | fi |
| 49 | |
| 50 | echo "\$ $file" |
Junxiao Shi | 439d972 | 2015-03-20 15:08:44 -0700 | [diff] [blame] | 51 | "$file" |
Davide Pesavento | cbef7b8 | 2019-10-09 00:15:13 -0400 | [diff] [blame] | 52 | |
Davide Pesavento | e8c82ef | 2021-07-28 02:38:51 -0400 | [diff] [blame] | 53 | if [[ -n $GITHUB_ACTIONS ]]; then |
| 54 | echo "::endgroup::" |
Davide Pesavento | cbef7b8 | 2019-10-09 00:15:13 -0400 | [diff] [blame] | 55 | fi |
Junxiao Shi | 439d972 | 2015-03-20 15:08:44 -0700 | [diff] [blame] | 56 | done |