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

CI: test macos (M1) arm64 #1978

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
232 changes: 10 additions & 222 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,60 +22,27 @@ on:
- 'NOTICE.txt'
- 'README.md'
jobs:
test-cuda:
defaults: {run: {shell: 'bash -el {0}'}}
runs-on: [self-hosted, python, cuda]
strategy:
matrix:
python-version: [3.11]
numpy-version: [1.25]
steps:
- uses: actions/checkout@v4
with: {fetch-depth: 0, submodules: recursive}
- id: reqs
name: set requirements
run: |
envname="${GITHUB_REPOSITORY##*/}-${GITHUB_RUN_ID}.${GITHUB_RUN_NUMBER}"
echo "envname=$envname" >> $GITHUB_OUTPUT
sed -ri -e 's/^(name: ).*/\1$envname/' -e '/ python /d' -e 's/(.* numpy) .*/\1=${{ matrix.numpy-version }}/' scripts/requirements-test.yml
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
environment-file: scripts/requirements-test.yml
activate-environment: ${{ steps.reqs.outputs.envname }}
run-post: false
- id: build
name: build
run: |
conda activate "${{ steps.reqs.outputs.envname }}"
cmake -S . -B ./build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONDA_BUILD=ON -DCMAKE_INSTALL_PREFIX="$CONDA_PREFIX"
cmake --build ./build --target install
- name: test
run: |
conda activate "${{ steps.reqs.outputs.envname }}"
TESTS_FORCE_GPU=1 python -m unittest discover -v -k tigre -k TIGRE -k astra -k ASTRA -k gpu -k GPU ./Wrappers/Python/test
- if: always()
name: Post Run conda-incubator/setup-miniconda@v3
shell: bash
run: |
sed -i '/${{ steps.reqs.outputs.envname }}/d' ~/.profile
source ~/.profile
conda env remove -n "${{ steps.reqs.outputs.envname }}"
test:
defaults: {run: {shell: 'bash -el {0}'}}
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
include:
- python-version: '3.10'
numpy-version: 1.23
- python-version: 3.12
numpy-version: 1.26
os: macos
steps:
- uses: actions/checkout@v4
with: {fetch-depth: 0, submodules: recursive}
- name: set requirements
run: sed -ri -e '/ python /d' -e 's/(.* numpy) .*/\1=${{ matrix.numpy-version }}/' -e 's/=cuda*//' -e '/tigre/d' scripts/requirements-test.yml
run: |
case ${{ matrix.os }} in
ubuntu)
sed -ri -e '/ python /d' -e 's/(.* numpy) .*/\1=${{ matrix.numpy-version }}/' -e 's/=cuda*//' -e '/tigre/d' scripts/requirements-test.yml ;;
macos)
sed -ri '' -e '/ python /d' -e 's/(.* numpy) .*/\1=${{ matrix.numpy-version }}/' -e '/not arm64/d' -e '/linux/d' scripts/requirements-test.yml ;
echo -e " - astra-toolbox=2.2.0\n - llvm-openmp" >> scripts/requirements-test.yml ;;
esac
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
Expand All @@ -87,182 +54,3 @@ jobs:
cmake --build ./build --target install
- name: test
run: python -m unittest discover -v ./Wrappers/Python/test
conda-matrix:
runs-on: ubuntu-latest
outputs:
python-version: ${{ steps.matrix.outputs.python-version }}
numpy-version: ${{ steps.matrix.outputs.numpy-version }}
steps:
- id: matrix
run: |
if ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags') }}; then
echo "python-version=['3.10', 3.11]" >> $GITHUB_OUTPUT
echo "numpy-version=[1.23, 1.24, 1.25, 1.26]" >> $GITHUB_OUTPUT
else
echo "python-version=['3.10']" >> $GITHUB_OUTPUT
echo "numpy-version=[1.23]" >> $GITHUB_OUTPUT
fi
conda:
defaults: {run: {shell: 'bash -el {0}'}}
runs-on: ubuntu-latest
needs: conda-matrix
strategy:
matrix:
python-version: ${{ fromJson(needs.conda-matrix.outputs.python-version) }}
numpy-version: ${{ fromJson(needs.conda-matrix.outputs.numpy-version) }}
include:
- python-version: 3.12
numpy-version: 1.26
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
ref: ${{ github.event.pull_request.head.sha || github.ref }} # fix SHA
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
mamba-version: "1.5"
channels: conda-forge
- name: conda build & test
working-directory: recipe
run: |
conda install boa
conda mambabuild . -c conda-forge -c https://tomography.stfc.ac.uk/conda --override-channels --python=${{ matrix.python-version }} --numpy=${{ matrix.numpy-version }} --output-folder .
- uses: actions/upload-artifact@v4
with:
name: cil-package-py${{ matrix.python-version }}-np${{ matrix.numpy-version }}
path: recipe/linux-64/cil*
- name: anaconda upload -c ccpi
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
run: |
conda install anaconda-client
anaconda -v -t ${{ secrets.CCPI_CONDA_TOKEN }} upload --force --label ${{ startsWith(github.ref, 'refs/tags') && 'main' || 'dev' }} recipe/linux-64/cil*
- name: conda upload -c tomography.stfc.ac.uk/conda
if: startsWith(github.ref, 'refs/tags')
run: |
echo '${{ secrets.STFC_SSH_KEY }}' > ./key
chmod 600 ./key
rsync -e 'ssh -o StrictHostKeyChecking=no -i ./key' -P recipe/linux-64/cil* \
'${{ secrets.STFC_SSH_HOST }}:${{ secrets.STFC_SSH_CONDA_DIR }}/linux-64/'
conda-reindex:
if: startsWith(github.ref, 'refs/tags')
needs: conda
runs-on: ubuntu-latest
steps:
- name: conda index tomography.stfc.ac.uk/conda
run: |
echo '${{ secrets.STFC_SSH_KEY }}' > ./key
chmod 600 ./key
ssh -o StrictHostKeyChecking=no -i ./key ${{ secrets.STFC_SSH_HOST }} \
'bash -lic "conda index --bz2 --zst --run-exports --channeldata --rss -n ccpi ${{ secrets.STFC_SSH_CONDA_DIR }}"'
docs:
defaults: {run: {shell: 'bash -el {0}', working-directory: docs}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
ref: ${{ github.event.pull_request.head.sha || github.ref }} # fix SHA
- uses: conda-incubator/setup-miniconda@v3
with: {python-version: 3.11}
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
cache-version: 0
- name: install dependencies
run: |
conda install -c conda-forge -yq conda-merge
conda-merge ../scripts/requirements-test.yml docs_environment.yml > environment.yml
conda env update -n test
conda list
- name: build cil
working-directory: .
run: |
cmake -S . -B ./build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONDA_BUILD=ON -DCMAKE_INSTALL_PREFIX="$CONDA_PREFIX"
cmake --build ./build --target install
- name: checkout docs
uses: actions/checkout@v4
with:
path: docs/build
ref: gh-pages
- id: pages
uses: actions/configure-pages@v5
- name: update web pages (jekyll)
run: make JEKYLLOPTS="--baseurl ${{ steps.pages.outputs.base_path }}" web-deps web
env: {JEKYLL_ENV: production}
- name: update docs pages (sphinx)
run: |
docs_dir="${{ github.ref_name }}"
docs_dir="${docs_dir//\//_}"
if test "$docs_dir" = master; then docs_dir=nightly; fi
make BUILDSUBDIR="$docs_dir" dirhtml
- uses: actions/upload-artifact@v4
with:
name: DocumentationHTML
path: docs/build
- name: Push changes
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
uses: casperdcl/push-dir@v1
with:
message: Update documentation
branch: gh-pages
dir: docs/build
nojekyll: true
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
ref: ${{ github.event.pull_request.head.sha || github.ref }} # fix SHA
- uses: jlumbroso/[email protected]
with:
docker-images: false
large-packages: false
- uses: docker/setup-buildx-action@v3
- uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
labels: |
org.opencontainers.image.licenses=Apache-2.0 AND BSD-3-Clause AND GPL-3.0
- uses: docker/login-action@v3
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
load: true
tags: tomographicimaging/cil:test
- name: test
run: >
docker run --rm -v .:/CIL tomographicimaging/cil:test /bin/bash -c
'python -m unittest discover -v /CIL/Wrappers/Python/test'
- uses: docker/build-push-action@v6
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
push: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
pass:
needs: [test-cuda, test, conda, docs, docker]
runs-on: ubuntu-latest
steps: [{run: echo success}]
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ LABEL org.opencontainers.image.source=https://github.com/TomographicImaging/CIL
LABEL org.opencontainers.image.licenses="Apache-2.0 AND BSD-3-Clause AND GPL-3.0"

# CUDA-specific packages
ARG CIL_EXCLUDE_PACKAGES="cuda"
ARG CIL_EXTRA_PACKAGES="tigre=2.6 astra-toolbox=2.1.0=cuda*"
# build & runtime dependencies
# TODO: sync scripts/create_local_env_for_cil_development.sh, scripts/requirements-test.yml, recipe/meta.yaml (e.g. missing libstdcxx-ng _openmp_mutex pip)?
# vis. https://github.com/TomographicImaging/CIL/pull/1590
COPY --chown="${NB_USER}" scripts/requirements-test.yml environment.yml
# channel_priority: https://stackoverflow.com/q/58555389
RUN sed -ri '/tigre|astra-toolbox| python /d' environment.yml \
RUN sed -ri "/$CIL_EXCLUDE_PACKAGES| python /d" environment.yml \
&& for pkg in 'jupyter-server-proxy>4.1.0' $CIL_EXTRA_PACKAGES; do echo " - $pkg" >> environment.yml; done \
&& conda config --env --set channel_priority strict \
&& for ch in defaults nvidia ccpi https://software.repos.intel.com/python/conda conda-forge; do conda config --env --add channels $ch; done \
Expand Down
5 changes: 2 additions & 3 deletions Wrappers/Python/test/test_DataContainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,13 +1037,12 @@ def test_sapyb_datacontainer_f(self):
# equals to 1 + -1 = 0
out = d1.sapyb(a,d2,b)
res = np.zeros_like(d1.as_array())
np.testing.assert_array_equal(res, out.as_array())
np.testing.assert_array_almost_equal(res, out.as_array(), decimal=7)

out.fill(0)
d1.sapyb(a,d2,b, out)
res = np.zeros_like(d1.as_array())
np.testing.assert_array_equal(res, out.as_array())

np.testing.assert_array_almost_equal(res, out.as_array(), decimal=7)

def test_sapyb_scalar_f(self):
# a,b scalar
Expand Down
Loading
Loading