Skip to content

Commit

Permalink
CI: move and polish install_nim.sh, fix MacOS using msys2
Browse files Browse the repository at this point in the history
  • Loading branch information
mratsim committed Jan 26, 2025
1 parent a2fa8e4 commit a3228ea
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 12 deletions.
32 changes: 21 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ jobs:
if: steps.nim-compiler-cache.outputs.cache-hit != 'true'
shell: bash
run: |
bash constantine/.github/workflows/install_nim.sh \
bash constantine/scripts/install_nim.sh \
--nim-channel ${{ matrix.nim_channel }} \
--nim-version ${{ matrix.nim_version }} \
--os ${{ matrix.target.os }} \
Expand Down Expand Up @@ -422,19 +422,29 @@ jobs:
cd constantine
CTT_ASM=0 nimble test_parallel --verbose
# On Windows
# So "test_bindings" uses C and can find GMP
# but nim-gmp cannot find GMP on Windows CI
# Also need to workaround asynctools not being able to create pipes https://github.com/nim-lang/Nim/issues/23118
# And LTO impossible constraint in the deneb_kzg test (but not MSM for some reason)
#
# On mac
# Homebrew install is not in default PATH
# this can be workaround with LD_LIBRARY_PATH for libraries
# but headers would need a
# --passC:-I$(brew --prefix)/include (-I/opt/homebrew/include on latest MacOS versions)
- name: Run Constantine in-depth tests (MacOS/Windows - no GMP, with Assembly)=
if: runner.os != 'Linux' && matrix.target.ctt_backend == 'ASM'
- name: Run Constantine in-depth tests (MacOS - no GMP, with Assembly)=
if: runner.os == 'macOS' && matrix.target.ctt_backend == 'ASM'
run: |
cd constantine
nimble test_parallel_no_gmp --verbose
- name: Run Constantine in-depth tests (MacOS - no GMP, no Assembly)
if: runner.os == 'macOS' && matrix.target.ctt_backend == 'NO_ASM'
run: |
cd constantine
CTT_ASM=0 nimble test_parallel_no_gmp --verbose
# On Windows
# So "test_bindings" uses C and can find GMP
# but nim-gmp cannot find GMP on Windows CI
# Also need to workaround asynctools not being able to create pipes https://github.com/nim-lang/Nim/issues/23118
# And LTO impossible constraint in the deneb_kzg test (but not MSM for some reason)
- name: Run Constantine in-depth tests (Windows - no GMP, with Assembly)=
if: runner.os == 'Windows' && matrix.target.ctt_backend == 'ASM'
shell: msys2 {0}
run: |
cd constantine
Expand All @@ -443,8 +453,8 @@ jobs:
else
nimble test_parallel_no_gmp --verbose
fi
- name: Run Constantine in-depth tests (MacOS/Windows - no GMP, no Assembly)
if: runner.os != 'Linux' && matrix.target.ctt_backend == 'NO_ASM'
- name: Run Constantine in-depth tests (Windows - no GMP, no Assembly)
if: runner.os == 'Windows' && matrix.target.ctt_backend == 'NO_ASM'
shell: msys2 {0}
run: |
cd constantine
Expand Down
38 changes: 37 additions & 1 deletion .github/workflows/install_nim.sh → scripts/install_nim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,40 @@ _nightlies_url=https://github.com/nim-lang/nightlies/releases
# UI
# -------------------------

print-help() {
cat <<EOF
Usage: $0 [options]
Download Nim with the options detailed below.
This script is written for Github Action use.
Options:
--nim-version <VERSION>
defaults to "stable".
VERSION can be
- a version number like '2.2.0'.
- a version number with wildcard like '2.x' or '2.2.x',
which will be replaced by the latest of the specified serie.
- a branch like 'devel' or 'version-2-2'
--nim-channel <stable|nightly|source>
defaults to "stable".
The channel specifies the download source of the Nim compiler
- "stable" downloads from Nim website, for Linux and Windows (x86 and x86-64) only
- "nightly" downloads from https://github.com/nim-lang/nightlies/releases
use a branch name like 'devel' or 'version-2-2'.
For Linux (x86, x86-64, arm64), MacOS (x86-64 only), Windows (x86, x86-64)
- "source" builds the compiler from source https://github.com/nim-lang/Nim
--install-dir <DIR>
defaults to "nim-install".
--os <OS>
defaults to host OS
--arch <CPU_ARCH>
defaults to host CPU architecture
-h, --help
prints this help
EOF
}

info() {
echo "$(date +"$DATE_FORMAT")" $'\e[1m\e[36m[INF]\e[0m' "$@"
}
Expand Down Expand Up @@ -89,8 +123,10 @@ while ((0 < $#)); do
--install-dir) cli_install_dir="$2"; shift 2;;
--os) cli_os="$2"; shift 2;;
--arch) cli_arch="$2"; shift 2;;
-h|--help) print-help; exit 0;;
*)
err "Unknown option '$opt'"
print-help
exit 1
;;
esac
Expand Down Expand Up @@ -190,7 +226,7 @@ CPU_ARCH=$(get-cpu-arch "${cli_arch}")
OS=$(get-os "${cli_os}")
NIM_CHANNEL=$(get-channel "${OS}" "${cli_nim_channel}")
NIM_VERSION=$(get-version "${cli_nim_version:-"stable"}") # Depends on channel to add the `v`
NIM_INSTALL_DIR=${cli_install_dir:="$(pwd)/nim-binaries"}
NIM_INSTALL_DIR=${cli_install_dir:="$(pwd)/nim-install"}
REPO_GITHUB_TOKEN="" # Placeholder

info "✔ CPU architecture: ${CPU_ARCH}"
Expand Down

0 comments on commit a3228ea

Please sign in to comment.