Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spack-solvable versions, add tests to Spack workflow #2156

Merged
merged 50 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
57fbee9
Spack-solvable versions, add tests to Spack workflow
brenthuisman Jul 19, 2023
c6b34ae
install fresh deps, if available
brenthuisman Jul 19, 2023
3cf50c2
Tell Spack to install develop version of Arbor, which is the locally …
brenthuisman Jul 19, 2023
ee001f7
TODO: can --fresh refer only to deps?
brenthuisman Jul 19, 2023
f1c20d1
Maybe: spack load doesnt persist over GA steps
brenthuisman Jul 20, 2023
82342fe
Persist Spack across GH Action steps
brenthuisman Jul 20, 2023
f66e989
Persist Spack across GH Action steps 2
brenthuisman Jul 20, 2023
8ef9e8e
black
brenthuisman Jul 20, 2023
9e353c4
Without quotes?
brenthuisman Jul 21, 2023
50d8f10
quotes are hard to find
brenthuisman Jul 21, 2023
4cdf312
It aint pretty, but...
brenthuisman Jul 21, 2023
e211a09
Prevent Arbor from entering Spack cache
brenthuisman Jul 21, 2023
075a56d
generate Spack cache
brenthuisman Jul 21, 2023
d98727e
by all means
brenthuisman Jul 21, 2023
52a47b7
a-b-c verbose=off prints MORE info
brenthuisman Jul 25, 2023
1ea55f9
better a-b-c error message?
brenthuisman Jul 25, 2023
4e38432
twas Github stealing stdout all along
brenthuisman Jul 25, 2023
23edbb6
a-b-c: remove useless try block. force nonspack c++ compiler
brenthuisman Jul 25, 2023
47844b4
add flags to correct place.
brenthuisman Jul 25, 2023
b9edb63
does order matter for Spack?
brenthuisman Jul 25, 2023
6879c77
Use BUILD_TESTING
brenthuisman Jul 26, 2023
ad0375c
Better GH Actions workflow for Spack
brenthuisman Jul 26, 2023
57bcc90
whelp
brenthuisman Jul 26, 2023
673ef86
whelp2
brenthuisman Jul 26, 2023
23f3e69
single quotes?
brenthuisman Jul 26, 2023
b13c9cf
single quotes everywhere
brenthuisman Jul 26, 2023
6b7e2cd
single quotes: its never enough
brenthuisman Jul 26, 2023
b53d84b
sloppy copy past
brenthuisman Jul 26, 2023
83f99a0
maybe
brenthuisman Jul 26, 2023
561abbc
geen idee
brenthuisman Jul 27, 2023
6d35dc8
naming things
brenthuisman Jul 27, 2023
d62d1c6
more debug
brenthuisman Jul 27, 2023
f5603d5
more debug2
brenthuisman Jul 27, 2023
57d6fc4
I still think this should work
brenthuisman Jul 27, 2023
32657ca
this may be it
brenthuisman Jul 28, 2023
0921820
disable spack-arbor unit tests for now and see if the rest works
brenthuisman Jul 28, 2023
80d9cbe
fix syntax
brenthuisman Jul 28, 2023
8a98d50
a-b-c test: was setting `c++` required?
brenthuisman Jul 28, 2023
f0475cf
remove github debugging
brenthuisman Jul 28, 2023
f0d2aa3
re-add setting cxx for modcc test
brenthuisman Jul 28, 2023
2c5e9fd
typo
brenthuisman Jul 28, 2023
2142e5c
remove stale code
brenthuisman Jul 28, 2023
c9a2b72
Drop Spack unit test for now.
brenthuisman Jul 28, 2023
93b23f6
more steps
brenthuisman Jul 28, 2023
f0c7c8a
cibuildwheelhotfix
brenthuisman Jul 31, 2023
73ae831
whoops
brenthuisman Jul 31, 2023
84641c9
Update pip during ciwheelbuild the new way
brenthuisman Jul 31, 2023
11358d5
review
brenthuisman Jul 31, 2023
f9674fc
words
brenthuisman Jul 31, 2023
e3c6532
Merged master.
brenthuisman Aug 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 49 additions & 16 deletions .github/workflows/spack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ jobs:
strategy:
matrix:
os: [ubuntu-22.04]
python-version: [3.8]
python-version: ['3.10']
spack-version: ['develop', 'latest_release']
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -25,18 +27,49 @@ jobs:
uses: actions/cache@v3
with:
path: ~/.spack-cache
key: spack-cache-${{ matrix.os }}-${{ github.run_id }}
restore-keys: spack-cache-${{ matrix.os }}-

- name: Build Arbor's Spack package against the develop branch
run: arbor/scripts/build_spack_package.sh arbor develop

# build_spack_package.sh only builds, does not install, therefore can't run Python code.
# - name: Run Python examples
# run: |
# cd arbor
# scripts/run_python_examples.sh
# - name: Test executables
# run: |
# cd arbor
# scripts/test_executables.sh
key: spack-cache-${{ matrix.os }}-${{ matrix.spack-version }}-${{ github.run_id }}
restore-keys: spack-cache-${{ matrix.os }}-${{ matrix.spack-version }}-
- name: Get Spack (develop)
if: ${{ matrix.spack-version == 'develop' }}
run: |
git clone -c feature.manyFiles=true --depth 1 https://github.com/spack/spack.git
- name: Get Spack (latest_release)
if: ${{ matrix.spack-version == 'latest_release' }}
run: |
wget "$(curl -sH "Accept: application/vnd.github.v3+json" https://api.github.com/repos/spack/spack/releases/latest | grep browser_download_url | cut -d '"' -f 4)"
thorstenhater marked this conversation as resolved.
Show resolved Hide resolved
tar xfz spack*.tar.gz
mv spack*/ spack
- name: Prep
run: |
mkdir ~/.spack
cp arbor/spack/config.yaml ~/.spack
source spack/share/spack/setup-env.sh
spack repo create custom_repo
mkdir -p custom_repo/packages/arbor
spack repo add custom_repo
spack reindex
cp arbor/spack/package.py custom_repo/packages/arbor
- name: Build Arbor
run: |
source spack/share/spack/setup-env.sh
cd arbor
spack dev-build arbor@develop +python
- name: Load Arbor and verify installation, Python Examples.
run: |
source spack/share/spack/setup-env.sh
spack load arbor
cd arbor
scripts/run_python_examples.sh
scripts/test_executables.sh
- name: Remove Arbor
run: |
source spack/share/spack/setup-env.sh
spack uninstall -yafR arbor
- name: Failure, upload logs
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: spack-log-${{ matrix.spack-version }}
path: |
arbor/*.txt
!arbor/CMakeLists.txt
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ include(ErrorTarget) # reguired for add_error_target

# Set release as the default build type (CMake default is debug.)

if (NOT CMAKE_BUILD_TYPE)
if (NOT CMAKE_BUILD_TYPE AND NOT BUILD_TESTING)
set(CMAKE_BUILD_TYPE release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "debug" "release")
Expand Down
6 changes: 3 additions & 3 deletions doc/contrib/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ Update tags/versions and test
- Double check that all examples/tutorials/etc are covered by CI
- Check Python/pip/PyPi metadata and scripts, e.g. ``setup.py``, ``pyproject.toml``

#. Create new temp-branch ending in ``-rc``. E.g. ``v0.6-rc``
#. Create new temp-branch ending in ``-rc``. E.g. ``v0.9.0-rc``
#. Bump the ``VERSION`` file:

- For as long as `scikit-build-core` does not support loading fields from external files, also bump in `pyproject.toml`
- See also :ref:`dev-version`
- Append ``-rc``. (Make sure there's no ``-dev``)

#. Create a draft PR. Tag and push with ``-rc``. E.g. ``v0.6-rc``
#. Create a draft PR. Tag and push with ``-rc``. E.g. ``v0.9.0-rc``

- on cmdline: ``git tag -a TAGNAME``
- ``git push upstream refs/tags/TAGNAME``
Expand Down Expand Up @@ -126,7 +126,7 @@ Post Release

#. Update Zenodo with authors and changelog created in previous step and submit.

#. Make a new PR setting ``VERSION`` to the next with a trailing ``-dev``. E.g. if you just release ``3.14``, change ``VERSION`` to ``3.15-dev``
#. Make a new PR setting ``VERSION`` to the next with a trailing ``-dev``. E.g. if you just released ``3.14.15``, change ``VERSION`` to ``3.15.16-dev``. Make the number portion always consists of a triple. Shorter versions are uninstallable by Spack (``spack install [email protected]`` will install v0.8.1, due to anything shorter than a triple being interpreted as a version range).
brenthuisman marked this conversation as resolved.
Show resolved Hide resolved

- Update ``spack/package.py``. The checksum of the targz is the sha256sum.
- Include changes such as to ``CITATIONS``, ``doc/index.rst`` in postrel PR. Copy Zenodo BibTex export to ``CITATIONS``.
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ build-frontend = "build"
build = ["cp3*-*linux*","cp3*-macosx*"]
skip = ["cp36*", "pp*", "*musllinux*"]
test-command = "python -m unittest discover -v -s {project}/python"
before-build = "python -m pip install pip --upgrade"
before-test = "python -m pip install pip --upgrade"
dependency-versions = "latest"

[tool.cibuildwheel.macos]
archs = ["universal2"]
Expand Down
29 changes: 13 additions & 16 deletions scripts/arbor-build-catalogue
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ config = A.config()
prefix = Path(config["prefix"])
CXX = Path(config["CXX"])
if not CXX.exists():
try:
# Example <>/lib/python3.10/site-packages/arbor
altern = "c++"
print(
f"Warning: prefix '{CXX}' does not exist, falling back to '{altern}'.",
file=sys.stderr,
)
CXX = altern
except:
# Example <>/lib/python3.10/site-packages/arbor
altern = "c++"
from shutil import which
if which(altern) == None:
print(
f"Error: Neither prefix '{CXX}' nor fallback '{altern}' exist. Please provide a path to a C++ compiler with --cxx",
file=sys.stderr,
)
exit(-1)
print(
f"Warning: prefix '{CXX}' does not exist, falling back to '{altern}'.",
file=sys.stderr,
)
CXX = altern


def parse_arguments():
Expand Down Expand Up @@ -312,13 +312,10 @@ with TemporaryDirectory() as tmp:
cmake_cmd = "cmake .."
make_cmd = "make"
if verbose:
out, err = (None, None)
make_cmd += " VERBOSE=1"
else:
out, err = (sp.PIPE, sp.PIPE)
try:
sp.run(cmake_cmd, shell=True, check=True, stdout=out, stderr=err)
sp.run(make_cmd, shell=True, check=True, stdout=out, stderr=err)
sp.run(cmake_cmd, shell=True, check=True, capture_output = True, text = True)
sp.run(make_cmd, shell=True, check=True, capture_output = True, text = True)
shutil.copy2(f"{name}-catalogue.so", pwd)
except sp.CalledProcessError as e:
import traceback as tb
Expand All @@ -327,9 +324,9 @@ with TemporaryDirectory() as tmp:
# Not in verbose mode, so we have captured the
# `stdout` and `stderr` and can print it to the user.
sys.stdout.write("Build log:\n")
sys.stdout.write(e.stdout.decode())
sys.stdout.write(e.stdout)
sys.stderr.write(tb.format_exc() + " Error:\n\n")
sys.stderr.write(e.stderr.decode())
sys.stderr.write(e.stderr)
else:
# In verbose mode the outputs weren't captured and
# have been streamed to `stdout` and `stderr` already.
Expand Down
4 changes: 2 additions & 2 deletions scripts/build_spack_package.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
# checks out Spack and Arbor and builds it with the package.py from Arbor's repo
# Spack can be the latest release or the develop branch
# Also runs unit tests.

set -Eeuo pipefail

Expand Down Expand Up @@ -61,5 +62,4 @@ spack reindex

cp $ARBOR_DIR/spack/package.py $SPACK_CUSTOM_REPO/packages/arbor
cd $ARBOR_DIR
ARBOR_VERSION=$(cat "$ARBOR_DIR/VERSION")
spack dev-build arbor@${ARBOR_VERSION} +python
spack dev-build --test root arbor@develop +python
1 change: 1 addition & 0 deletions scripts/run_python_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ $PREFIX python3 -m pip install -r python/example/example_requirements.txt -U
runpyex () {
echo "=== Executing $1 ======================================"
$PREFIX python3 python/example/$*
echo "### Example $1: OK."
}

runpyex brunel.py -n 400 -m 100 -e 20 -p 0.1 -w 1.2 -d 1 -g 0.5 -l 5 -t 100 -s 1 -G 50 -S 123
Expand Down
4 changes: 3 additions & 1 deletion scripts/test_executables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ set -Eeuo pipefail
echo "=== Executing modcc test ======================================"
modcc python/example/cat/dummy.mod
test -f "dummy.hpp"
echo "executable modcc: OK."

echo "=== Executing a-b-c test ======================================"
arbor-build-catalogue -v cat python/example/cat
arbor-build-catalogue --cxx=c++ cat python/example/cat
./scripts/test-catalogue.py ./cat-catalogue.so
echo "executable a-b-c: OK."
28 changes: 13 additions & 15 deletions spack/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@

from spack.package import *

try:
with open("VERSION", "r") as file:
DEVVERSION = file.readline().strip()
except:
DEVVERSION = None


class Arbor(CMakePackage, CudaPackage):
"""Arbor is a high-performance library for computational neuroscience
Expand All @@ -21,26 +15,25 @@ class Arbor(CMakePackage, CudaPackage):
url = "https://github.com/arbor-sim/arbor/releases/download/v0.8.1/arbor-v0.8.1-full.tar.gz"
maintainers = ["thorstenhater", "brenthuisman", "haampie"]

version("master", branch="master", submodules=True)
if DEVVERSION:
version(DEVVERSION)
version("master", branch="master")
version("develop")
version(
"0.8.1",
sha256="caebf96676ace6a9c50436541c420ca4bb53f0639dcab825de6fa370aacf6baa",
url="https://github.com/arbor-sim/arbor/releases/download/v0.8.1/arbor-v0.8.1-full.tar.gz",
)
version(
"0.8",
"0.8.0",
sha256="18df5600308841616996a9de93b55a105be0f59692daa5febd3a65aae5bc2c5d",
url="https://github.com/arbor-sim/arbor/releases/download/v0.8/arbor-v0.8-full.tar.gz",
)
version(
"0.7",
"0.7.0",
sha256="c3a6b7193946aee882bb85f9c38beac74209842ee94e80840968997ba3b84543",
url="https://github.com/arbor-sim/arbor/releases/download/v0.7/arbor-v0.7-full.tar.gz",
)
version(
"0.6",
"0.6.0",
sha256="4cd333b18effc8833428ddc0b99e7dc976804771bc85da90034c272c7019e1e8",
url="https://github.com/arbor-sim/arbor/releases/download/v0.6/arbor-v0.6-full.tar.gz",
)
Expand Down Expand Up @@ -99,9 +92,9 @@ class Arbor(CMakePackage, CudaPackage):
depends_on("[email protected]:", when="+python", type=("build", "run"))
depends_on("py-numpy", when="+python", type=("build", "run"))
with when("+python"):
depends_on("[email protected]:", type=("build"))
depends_on("[email protected]:", when="@0.5.3:", type=("build"))
depends_on("[email protected]:", when="@0.7.1:", type=("build"))
depends_on("[email protected]:", type="build")
depends_on("[email protected]:", when="@0.5.3:", type="build")
depends_on("[email protected]:", when="@0.7.1:", type="build")

# sphinx based documentation
depends_on("[email protected]:", when="+doc", type="build")
Expand Down Expand Up @@ -132,3 +125,8 @@ def cmake_args(self):
args.append("-DARB_CXX_FLAGS_TARGET=" + opt_flags)

return args

@run_after("install", when="+python")
@on_package_attributes(run_tests=True)
def install_test(self):
python("-c", "import arbor")
Loading