diff --git a/.github/workflows/build-env.yml b/.github/workflows/build-env.yml new file mode 100644 index 00000000..273d90f0 --- /dev/null +++ b/.github/workflows/build-env.yml @@ -0,0 +1,28 @@ +name: Update build environment + +on: + workflow_dispatch: # Trigger by hand from the UI + schedule: + - cron: '0 0 * * 0' # Schedule it every Sunday + +jobs: + build-spack-pyprecice-deps: + name: Builds the baseimage for spack providing dependencies + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + - name: Set up Docker + uses: docker/setup-buildx-action@v1 + - name: Login to registry + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v2 + with: + push: true + context: . + file: spack/ci-spack-pyprecice-deps-1804.dockerfile + tags: precice/ci-spack-pyprecice-deps-1804 diff --git a/.github/workflows/build-spack.yml b/.github/workflows/build-spack.yml index 39fcf4fe..1d734b7c 100644 --- a/.github/workflows/build-spack.yml +++ b/.github/workflows/build-spack.yml @@ -9,32 +9,17 @@ jobs: name: build_spack runs-on: ubuntu-latest timeout-minutes: 15 - container: benjaminrueth/ci-spack-pyprecice-deps-1804 + container: precice/ci-spack-pyprecice-deps-1804 defaults: run: shell: "bash --login -eo pipefail {0}" steps: - name: Checkout Repository uses: actions/checkout@v2 - - name: Install pip3 + - name: Move Package Script run: | - curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py - python3 get-pip.py - - name: Install jinja2 - run: pip3 install --user jinja2 - - name: Extract branch name # from https://stackoverflow.com/a/58035262/5158031 - shell: bash - run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" - id: extract_branch - - name: Specify Package Script + cp spack/repo/packages/py-pyprecice/package.py /py-pyprecice-repo/packages/py-pyprecice/ + cp spack/repo/packages/py-pyprecice/*.patch /py-pyprecice-repo/packages/py-pyprecice/ + - name: Try to build py-pyprecice with spack and test it run: | - python3 spack/jinja-instantiate.py --branch ${{ steps.extract_branch.outputs.branch }} > /opt/spack/var/spack/repos/builtin/packages/py-pyprecice/package.py - ls spack/var/spack/repos/builtin/packages/py-pyprecice - cp spack/var/spack/repos/builtin/packages/py-pyprecice/*.patch /opt/spack/var/spack/repos/builtin/packages/py-pyprecice/ - ls spack/var/spack/repos/builtin/packages/py-pyprecice - - name: Try to build py-pyprecice with spack - run: | - . /opt/spack/share/spack/setup-env.sh && spack env activate precice && spack add py-pyprecice@develop ^precice@develop && spack concretize -f && spack install -v - - name: Import precice and print version - run: | - . /opt/spack/share/spack/setup-env.sh && spack env activate precice && python3 -c "import precice; print(precice.__version__)" + . /opt/spack/share/spack/setup-env.sh && spack env activate ci && spack arch && spack find && spack dev-build py-pyprecice@develop target=x86_64 && spack load precice py-numpy py-mpi4py py-cython openssh openmpi && mkdir runner && cd runner && python3 -c "import precice; print(precice.__version__)" diff --git a/spack/README.md b/spack/README.md index 0c721e06..71c8bc42 100644 --- a/spack/README.md +++ b/spack/README.md @@ -2,20 +2,13 @@ The Spack package `py-pyprecice` provides the python bindings via Spack and was submitted via https://github.com/spack/spack/pull/19558. This folder contains the Spack package script that can be used for testing whether the Spack installation works. -Note that the file `var/spack/repos/builtin/packages/py-pyprecice/package.py` is a template that can be specified using `jinja2`. Run `python3 jinja-instrantiate.py` to do so. You may use the `--branch` argument to specify a branch. Example: -``` -python3 jinja-instantiate.py --branch feature > my_package_script.py -``` +## Docker image `precice/ci-spack-pyprecice-deps-1804` -## Docker image ci-spack-pyprecice-deps-1804 +The workflow `build_env` in `.github/workflows/build-spack.yml` creates the image `precice/ci-spack-pyprecice-deps-1804`. This image contains all dependencies of `py-pyprecice@develop`. + +The workflow `build_spack` in `.github/workflows/build-spack.yml` uses the image `precice/ci-spack-pyprecice-deps-1804` to reduce build time. The workflow uses the `package.py` from this repository to build the latest version of the bindings and run a small test on this version. -The test `build_spack` in `.github/workflows/build-spack.yml` uses the image `benjaminrueth/ci-spack-pyprecice-deps-1804` to reduce build time. Use the file `ci-spack-pyprecice-deps-1804.dockerfile` from this folder for building this image: -``` -docker build -f ci-spack-pyprecice-deps-1804.dockerfile -t USERNAME/ci-spack-pyprecice-deps-1804.dockerfile . -docker push USERNAME/ci-spack-pyprecice-deps-1804.dockerfile -``` ## When a new spack release is necessary -* Add checksum of newest version(s) to https://github.com/precice/python-bindings/blob/develop/spack/var/spack/repos/builtin/packages/py-pyprecice/package.py. You can get checksum for any released version by running `spack checksum py-pyprecice`. -* Run `python3 jinja-instantiate > package.py` to generate the latest version of `package.py`. -* Use `package.py` together with the patches provided in `python-bindings/spack/var/spack/repos/builtin/packages/py-pyprecice` to [create a pull request for Spack](https://github.com/spack/spack/compare) and submit the new release. +* Add checksum of newest version(s) to https://github.com/precice/python-bindings/blob/develop/spack/repo/packages/py-pyprecice/package.py. You can get checksum for any released version by running `spack checksum py-pyprecice`. +* Use `package.py` together with the patches provided in `python-bindings/spack/repo/packages/py-pyprecice` to [create a pull request for Spack](https://github.com/spack/spack/compare) and submit the new release. diff --git a/spack/ci-spack-pyprecice-deps-1804.dockerfile b/spack/ci-spack-pyprecice-deps-1804.dockerfile index ada55360..fb7c3cfa 100644 --- a/spack/ci-spack-pyprecice-deps-1804.dockerfile +++ b/spack/ci-spack-pyprecice-deps-1804.dockerfile @@ -1,8 +1,11 @@ # Build stage with Spack pre-installed and ready to be used -FROM spack/ubuntu-bionic:latest -RUN spack env create precice -# Install dependencies for precice and py-pyprecice -RUN spack env activate precice \ - && spack add boost@1.74.0 cmake@3.18.4 eigen@3.3.8 openssh petsc@3.14.1 pkgconfig precice@develop py-setuptools py-wheel py-cython py-numpy py-mpi4py \ - && spack concretize -f \ - && spack install +FROM spack/ubuntu-bionic:latest + +# Mount the current sources into the build container +# and build the default environment +ADD ./spack/repo /py-pyprecice-repo +RUN spack --color=always env create --without-view ci && \ + spack --color=always -e ci add py-pyprecice@develop target=x86_64 && \ + spack --color=always -e ci repo add /py-pyprecice-repo && \ + spack --color=always -e ci install --fail-fast --only=dependencies && \ + spack --color=always clean -a diff --git a/spack/jinja-instantiate.py b/spack/jinja-instantiate.py deleted file mode 100644 index e26877b0..00000000 --- a/spack/jinja-instantiate.py +++ /dev/null @@ -1,15 +0,0 @@ -import jinja2 -import argparse -from os import path - -parser = argparse.ArgumentParser() -parser.add_argument('--branch', type=str, help="Branch to be checked out", - default="develop") -args = parser.parse_args() - -f = open(path.join(path.dirname(__file__), - "var/spack/repos/builtin/packages/py-pyprecice/package.py"), - "r") - -template = jinja2.Template(f.read()) -print(template.render(branch=args.branch)) diff --git a/spack/var/spack/repos/builtin/packages/py-pyprecice/deactivate-version-check-via-pip.patch b/spack/repo/packages/py-pyprecice/deactivate-version-check-via-pip.patch similarity index 100% rename from spack/var/spack/repos/builtin/packages/py-pyprecice/deactivate-version-check-via-pip.patch rename to spack/repo/packages/py-pyprecice/deactivate-version-check-via-pip.patch diff --git a/spack/var/spack/repos/builtin/packages/py-pyprecice/package.py b/spack/repo/packages/py-pyprecice/package.py similarity index 98% rename from spack/var/spack/repos/builtin/packages/py-pyprecice/package.py rename to spack/repo/packages/py-pyprecice/package.py index 23f16bc9..dd65c005 100644 --- a/spack/var/spack/repos/builtin/packages/py-pyprecice/package.py +++ b/spack/repo/packages/py-pyprecice/package.py @@ -18,7 +18,7 @@ class PyPyprecice(PythonPackage): maintainers = ["ajaust", "BenjaminRodenberg"] # Always prefer final version of release candidate - version("develop", branch="{{ branch }}") + version("develop", branch="develop") version('2.2.0.1', sha256='032fa58193cfa69e3be37557977056e8f507d89b40c490a351d17271269b25ad') version('2.1.1.2', sha256='363eb3eeccf964fd5ee87012c1032353dd1518662868f2b51f04a6d8a7154045') version("2.1.1.1", sha256="972f574549344b6155a8dd415b6d82512e00fa154ca25ae7e36b68d4d2ed2cf4") diff --git a/spack/repo/repo.yaml b/spack/repo/repo.yaml new file mode 100644 index 00000000..61517481 --- /dev/null +++ b/spack/repo/repo.yaml @@ -0,0 +1,2 @@ +repo: + namespace: 'spack'