From f10f09afac75a658b8e0923d5293a0fc2414123f Mon Sep 17 00:00:00 2001 From: Dev Null Date: Tue, 14 May 2024 09:23:50 +0800 Subject: [PATCH] v0.7.2 CI fix abandonded release action. Fixes #7 Merge example flow Release to crates.io --- .github/workflows/build.sh | 74 ---------- .github/workflows/coverage.yml | 2 +- .github/workflows/releases.yml | 226 +++++++++++++++++++---------- .github/workflows/run-examples.yml | 148 ------------------- .github/workflows/run-tests.yml | 156 ++++++++++++++++---- CHANGELOG.md | 4 + Cargo.lock | 2 +- Cargo.toml | 5 +- 8 files changed, 291 insertions(+), 326 deletions(-) delete mode 100755 .github/workflows/build.sh delete mode 100644 .github/workflows/run-examples.yml diff --git a/.github/workflows/build.sh b/.github/workflows/build.sh deleted file mode 100755 index 6c0f0c3..0000000 --- a/.github/workflows/build.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash - -# This script is assumed to be using the docker image quay.io/pypa/manylinux_2_28_x86_64 -# This should mean that glibc 2.28 is being used. More details at -# https://github.com/pypa/manylinux - -set -eux - -# Copy the release readme to the project root so it can neatly be put in the -# release tarballs. -cp .github/workflows/releases-readme.md README.md - -release=v$(grep version Cargo.toml -m1 | cut -d' ' -f3 | tr -d '"') - -if [[ "$OSTYPE" == "linux-gnu"* ]]; then - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain none - source "$HOME/.cargo/env" - rustup install $(grep rust-version Cargo.toml -m1 | cut -d' ' -f3 | tr -d '"') - - python3.11 -m venv venv - source ./venv/bin/activate - pip3 install maturin==0.14.13 - - # Build a release for each x86_64 microarchitecture level. v4 can't be - # compiled on GitHub for some reason. - for level in "x86-64" "x86-64-v2" "x86-64-v3"; do - export RUSTFLAGS="-C target-cpu=${level}" - - # Build python first - maturin build --release --features=python,all-static --strip -f - - # We don't care about PyPy, sorry. - rm target/wheels/*pypy* - - # Build C objects - cargo build --release --features all-static - - # Because we've compiled HDF5 and ERFA into hyperbeam products, we - # legally must distribute their licenses with the products. - curl https://raw.githubusercontent.com/HDFGroup/hdf5/develop/COPYING -o COPYING-hdf5 - curl https://raw.githubusercontent.com/liberfa/erfa/master/LICENSE -o LICENSE-erfa - - # Create new release asset tarballs - mv target/wheels/*.whl target/release/libmwa_hyperbeam.{a,so} include/mwa_hyperbeam.h . - tar -acvf mwa_hyperbeam-"${release}"-Linux-C-library-${level}.tar.gz \ - LICENSE COPYING-hdf5 LICENSE-erfa README.md \ - libmwa_hyperbeam.{a,so} mwa_hyperbeam.h - tar -acvf mwa_hyperbeam-"${release}"-Linux-Python-${level}.tar.gz \ - LICENSE COPYING-hdf5 LICENSE-erfa README.md \ - ./*.whl - done -elif [[ "$OSTYPE" == "darwin"* ]]; then - pip3 install maturin==0.14.13 - brew install automake - - # Build python first - maturin build --release --features=python,all-static --strip - - # Build C objects - cargo build --release --features all-static - - # Because we've compiled HDF5 and ERFA into hyperbeam products, we legally - # must distribute their licenses with the products. - curl https://raw.githubusercontent.com/HDFGroup/hdf5/develop/COPYING -o COPYING-hdf5 - curl https://raw.githubusercontent.com/liberfa/erfa/master/LICENSE -o LICENSE-erfa - - mv target/wheels/*.whl target/release/libmwa_hyperbeam.{a,dylib} include/mwa_hyperbeam.h . - tar -acvf mwa_hyperbeam-"${release}"-MacOSX-C-library.tar.gz \ - LICENSE COPYING-hdf5 LICENSE-erfa README.md \ - libmwa_hyperbeam.{a,dylib} mwa_hyperbeam.h - tar -acvf mwa_hyperbeam-"${release}"-MacOSX-Python.tar.gz \ - LICENSE COPYING-hdf5 LICENSE-erfa README.md \ - ./*.whl -fi diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index d197467..428a6a0 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -52,4 +52,4 @@ jobs: uses: codecov/codecov-action@v3 with: files: lcov.info - fail_ci_if_error: true + fail_ci_if_error: false diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index 9cf3734..d6a8a1e 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -12,9 +12,12 @@ env: CARGO_INCREMENTAL: 0 jobs: - build-linux-release: - name: Build release for Linux - runs-on: ubuntu-22.04 + build-release: + name: Build release for ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04, macos-13, macos-14] steps: - name: Checkout sources @@ -22,107 +25,180 @@ jobs: with: fetch-depth: 0 - # - name: Install CUDA - # run: | - # wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb - # sudo dpkg -i cuda-keyring_1.0-1_all.deb - # sudo apt -y update - # sudo apt -y install cuda --no-install-recommends - - # - name: Check semver - # uses: obi1kenobi/cargo-semver-checks-action@v2 - # env: - # NVCC: /usr/local/cuda/bin/nvcc - - - name: Build hyperbeam - uses: docker://quay.io/pypa/manylinux_2_28_x86_64:latest - with: - entrypoint: /bin/bash - args: .github/workflows/build.sh - - - name: Upload tarball - uses: actions/upload-artifact@v2 - with: - name: linux.tar.gz - path: "*.tar.gz" - if-no-files-found: error - - build-macos-release: - name: Build release for MacOS - runs-on: macos-latest - - steps: - - name: Checkout sources - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 + - name: (macos) install dependencies + if: ${{ startsWith(matrix.os, 'macos') }} + run: | + brew install automake autoconf pkg-config hdf5@1.10 + - name: (ubuntu) install dependencies + if: ${{ startsWith(matrix.os, 'ubuntu') }} + run: | + sudo apt -y update + sudo apt -y install libhdf5-dev gcc pkg-config python3 curl wget git jq + + - name: Install Rust, stable minimal toolchain + uses: dtolnay/rust-toolchain@v1 with: - profile: minimal toolchain: stable - override: true - - - name: Add Python 3.7 - uses: actions/setup-python@v2 - with: - python-version: "3.7" - architecture: "x64" - name: Add Python 3.8 - uses: actions/setup-python@v2 + if: ${{ matrix.os != 'macos-14' }} + uses: actions/setup-python@v5 + continue-on-error: true with: python-version: "3.8" - architecture: "x64" - name: Add Python 3.9 - uses: actions/setup-python@v2 + if: ${{ matrix.os != 'macos-14' }} + uses: actions/setup-python@v5 + continue-on-error: true with: python-version: "3.9" - architecture: "x64" - name: Add Python 3.10 - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 + continue-on-error: true with: python-version: "3.10" - architecture: "x64" - name: Add Python 3.11 - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 + continue-on-error: true with: python-version: "3.11" - architecture: "x64" - - name: Build hyperbeam - run: .github/workflows/build.sh + - name: Add Python 3.12 + uses: actions/setup-python@v5 + continue-on-error: true + with: + python-version: "3.12" + + - name: install maturin + run: | + python -m pip install --upgrade pip + python -m pip install maturin + + - name: build mwa_hyperbeam + run: | + # Copy the release readme to the project root so it can neatly be put in the + # release tarballs. + cp .github/workflows/releases-readme.md README.md + + # Because we've compiled HDF5 and ERFA into hyperbeam products, we + # legally must distribute their licenses with the products. + curl https://raw.githubusercontent.com/HDFGroup/hdf5/develop/COPYING -o COPYING-hdf5 + curl https://raw.githubusercontent.com/liberfa/erfa/master/LICENSE -o LICENSE-erfa + + export TAG="$(git describe --tags)" + export VER="v$(grep version Cargo.toml -m1 | cut -d' ' -f3 | tr -d '"')" + export REF="${{ github.ref_name }}" + echo "TAG=$TAG, VER=$VER, REF=$REF" + + # determine which target cpus for rustc to build for from machine type + export ARCH="$(uname -m)" + case $ARCH in + x86_64) + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + export TARGETS="x86-64 x86-64-v2 x86-64-v3" + else + export TARGETS="x86-64" + fi + ;; + arm64) export TARGETS="apple-m1" ;; + *) echo "unknown arch (uname -m) $ARCH"; exit 1 ;; + esac + + # determine which library file extensions to include in archive from kernel + export KERNEL="$(uname -s | tr '[:upper:]' '[:lower:]')" + case $KERNEL in + darwin*) export LIB_GLOB="{a,dylib}" ;; + linux*) export LIB_GLOB="{a,so}" ;; + *) echo "unknown kernel (uname -s) $KERNEL"; exit 1 ;; + esac + + # determine which python versions are available + export PYTHONS=$(maturin list-python 2>&1 | grep CPython | cut -d' ' -f 4 | tr $'\n' ' ') + + for TARGET in $TARGETS; do + echo "building target $TARGET" + export RUSTFLAGS="-C target-cpu=$TARGET" + # Build python first + maturin build --release --features python,all-static --strip -i $PYTHONS + # Build C objects + cargo build --release --features all-static + + # Create new release asset tarballs + eval mv target/wheels/*.whl target/release/libmwa_hyperbeam.${LIB_GLOB} include/mwa_hyperbeam.h . + eval tar -acvf mwa_hyperbeam-${TAG}-${KERNEL}-${TARGET}.tar.gz \ + LICENSE COPYING-hdf5 LICENSE-erfa README.md CHANGELOG.md \ + libmwa_hyperbeam.${LIB_GLOB} mwa_hyperbeam.h + eval tar -acvf mwa_hyperbeam-${TAG}-${KERNEL}-${TARGET}-python.tar.gz \ + LICENSE COPYING-hdf5 LICENSE-erfa README.md CHANGELOG.md \ + ./*.whl + done - name: Upload tarball - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: - name: macos.tar.gz + name: ${{ matrix.os }}.tar.gz path: "*.tar.gz" if-no-files-found: error - create-release: - name: Create a new release + create-rust-release: + name: Publish to crates.io runs-on: ubuntu-latest - needs: [build-linux-release, build-macos-release] + needs: [build-release] + environment: CI steps: - - name: Download Linux artifact - uses: actions/download-artifact@v2 + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Install stable, minimal toolchain + uses: dtolnay/rust-toolchain@v1 with: - name: linux.tar.gz + toolchain: stable + + - name: Build release on latest stable rust + run: | + sudo apt -y update + sudo apt -y install libhdf5-dev pkg-config + cargo build --release --features hdf5-static - - name: Download MacOS artifact - uses: actions/download-artifact@v2 + - uses: katyo/publish-crates@v2 with: - name: macos.tar.gz + registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} + args: --no-verify - - name: Provide new release asset - uses: "marvinpinto/action-automatic-releases@latest" + create-github-and-pypi-release: + name: Create a new github and pypi release + runs-on: ubuntu-latest + needs: [create-rust-release] + environment: CI + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + merge-multiple: true + + - name: Create GitHub release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref_name }} + shell: bash + run: | + gh release create "$tag" \ + --repo="$GITHUB_REPOSITORY" \ + --title="${GITHUB_REPOSITORY#*/} ${tag#v}" \ + --generate-notes *.tar.gz + + - name: Place all python wheels into dir for publish to pypi + run: | + mkdir for_pypi + tar xvf *-darwin-apple-m1-python.tar.gz -C for_pypi/ --wildcards "*.whl" + tar xvf *-darwin-x86-64-python.tar.gz -C for_pypi/ --wildcards "*.whl" + tar xvf *-linux-x86-64-python.tar.gz -C for_pypi/ --wildcards "*.whl" + + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" - prerelease: false - files: | - *.tar.gz + packages-dir: for_pypi/ + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/run-examples.yml b/.github/workflows/run-examples.yml deleted file mode 100644 index 5aef954..0000000 --- a/.github/workflows/run-examples.yml +++ /dev/null @@ -1,148 +0,0 @@ ---- -name: Cross-platform testing examples - -# Do this on every push that isn't tagged -on: - push: - tags-ignore: - - "**" - branches: - - "**" - pull_request: - -env: - CARGO_TERM_COLOR: always - CARGO_INCREMENTAL: 0 - DEBIAN_FRONTEND: noninteractive - MWA_BEAM_FILE: mwa_full_embedded_element_pattern.h5 - -jobs: - test: - name: Examples on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-20.04, macos-latest] - include: - - os: macos-latest - python-version: [3.7, 3.8, 3.9, 3.10, 3.11] - steps: - - name: Checkout sources - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install Dependencies - run: | - if [ "$RUNNER_OS" == "Linux" ]; then - sudo apt -y update - sudo apt -y install libhdf5-dev gcc pkg-config python3{,-pip,-venv} curl wget - elif [ "$RUNNER_OS" == "macOS" ]; then - brew install pkg-config - # 1.12 doesn't work? - brew install hdf5@1.10 - else - echo "$RUNNER_OS not supported" - exit 1 - fi - - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - override: true - - - name: Get the HDF5 file - run: curl http://ws.mwatelescope.org/static/mwa_full_embedded_element_pattern.h5 -o mwa_full_embedded_element_pattern.h5 - - - name: Run Rust example - run: cargo run --example fee 10 - - - name: Run C examples - run: | - cargo build - - echo "*** Compiling C examples ***" - # The macOS runner has clang symlinked as gcc, and attempting to alias - # gcc as /usr/local/bin/gcc doesn't work! Why??? - if [ "$RUNNER_OS" == "Linux" ]; then - gcc -O3 examples/fee.c -o fee -I ./include/ -L ./target/debug/ -l mwa_hyperbeam - gcc -O3 examples/fee_parallel.c -o fee_parallel -I ./include/ -L ./target/debug/ -l mwa_hyperbeam - gcc -O3 -fopenmp examples/fee_parallel_omp.c -o fee_parallel_omp -I ./include/ -L ./target/debug/ -l mwa_hyperbeam - gcc -O3 examples/fee_get_freqs.c -o fee_get_freqs -I ./include/ -L ./target/debug/ -l mwa_hyperbeam - gcc -O3 examples/analytic.c -o analytic -I ./include/ -L ./target/debug/ -l mwa_hyperbeam - gcc -O3 examples/analytic_parallel.c -o analytic_parallel -I ./include/ -L ./target/debug/ -l mwa_hyperbeam - else - /usr/local/bin/gcc-12 -O3 examples/fee.c -o fee -I ./include/ -L ./target/debug/ -l mwa_hyperbeam - /usr/local/bin/gcc-12 -O3 examples/fee_parallel.c -o fee_parallel -I ./include/ -L ./target/debug/ -l mwa_hyperbeam - /usr/local/bin/gcc-12 -O3 -fopenmp examples/fee_parallel_omp.c -o fee_parallel_omp -I ./include/ -L ./target/debug/ -l mwa_hyperbeam - /usr/local/bin/gcc-12 -O3 examples/fee_get_freqs.c -o fee_get_freqs -I ./include/ -L ./target/debug/ -l mwa_hyperbeam - /usr/local/bin/gcc-12 -O3 examples/analytic.c -o analytic -I ./include/ -L ./target/debug/ -l mwa_hyperbeam - /usr/local/bin/gcc-12 -O3 examples/analytic_parallel.c -o analytic_parallel -I ./include/ -L ./target/debug/ -l mwa_hyperbeam - fi - echo "*** Running C examples ***" - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./fee mwa_full_embedded_element_pattern.h5 - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./fee_parallel mwa_full_embedded_element_pattern.h5 - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./fee_parallel_omp mwa_full_embedded_element_pattern.h5 - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./fee_get_freqs mwa_full_embedded_element_pattern.h5 - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./analytic - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./analytic_parallel - - - name: Run Python example - run: | - python3 -m venv venv - . ./venv/bin/activate - pip install numpy maturin - echo "*** Compiling Python hyperbeam ***" - maturin develop -b pyo3 --features=python - echo "*** Running Python examples ***" - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./examples/fee.py mwa_full_embedded_element_pattern.h5 - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./examples/analytic.py - - - name: CUDA examples - if: runner.os == 'Linux' - run: | - wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb - sudo dpkg -i cuda-keyring_1.0-1_all.deb - sudo apt -y update - sudo apt -y install cuda --no-install-recommends - PATH+=:/usr/local/cuda/bin - - # Examples may fail because there's no GPU - cargo build --features=cuda --example fee_cuda - ./target/debug/examples/fee_cuda 10 || true - cargo build --features=cuda --example analytic_cuda - ./target/debug/examples/analytic_cuda 10 || true - cargo build --features=cuda,gpu-single --example fee_cuda - ./target/debug/examples/fee_cuda 10 || true - cargo build --features=cuda,gpu-single --example analytic_cuda - ./target/debug/examples/analytic_cuda 10 || true - - cargo build --release --features=cuda - gcc -O3 examples/fee_gpu.c -o fee_cuda -I ./include/ -L ./target/release/ -l mwa_hyperbeam - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./fee_cuda mwa_full_embedded_element_pattern.h5 || true - nvcc -O3 examples/fee_cuda_device.cu -o fee_cuda_device -I ./include/ -L ./target/release/ -l mwa_hyperbeam - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release ./fee_cuda_device mwa_full_embedded_element_pattern.h5 || true - gcc -O3 examples/analytic_gpu.c -o analytic_cuda -I ./include/ -L ./target/release/ -l mwa_hyperbeam - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./analytic_cuda || true - nvcc -O3 examples/analytic_cuda_device.cu -o analytic_cuda_device -I ./include/ -L ./target/release/ -l mwa_hyperbeam - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release ./analytic_cuda_device || true - - cargo build --release --features=cuda,gpu-single - gcc -O3 -D SINGLE examples/fee_gpu.c -o fee_cuda -I ./include/ -L ./target/release/ -l mwa_hyperbeam - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./fee_cuda mwa_full_embedded_element_pattern.h5 || true - nvcc -O3 -D SINGLE examples/fee_cuda_device.cu -o fee_cuda_device -I ./include/ -L ./target/release/ -l mwa_hyperbeam - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release ./fee_cuda_device mwa_full_embedded_element_pattern.h5 || true - gcc -O3 -D SINGLE examples/analytic_gpu.c -o analytic_cuda -I ./include/ -L ./target/release/ -l mwa_hyperbeam - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./analytic_cuda || true - nvcc -O3 -D SINGLE examples/analytic_cuda_device.cu -o analytic_cuda_device -I ./include/ -L ./target/release/ -l mwa_hyperbeam - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release ./analytic_cuda_device || true - - . ./venv/bin/activate - maturin develop -b pyo3 --features=python,cuda - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./examples/fee_gpu.py mwa_full_embedded_element_pattern.h5 || true - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./examples/analytic_gpu.py || true - maturin develop -b pyo3 --features=python,cuda,gpu-single - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./examples/fee_gpu.py mwa_full_embedded_element_pattern.h5 || true - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./examples/analytic_gpu.py || true diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 2fcf9b2..e5c28f4 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -18,40 +18,45 @@ env: jobs: test: - name: Test ${{matrix.os}} - Rust ${{matrix.rust}} + name: Test ${{matrix.os}} Rust ${{matrix.rust.ver}} ex ${{matrix.rust.examples}} runs-on: ${{matrix.os}} strategy: fail-fast: false matrix: - os: [ubuntu-20.04, macos-latest] - rust: [nightly, beta, stable, 1.64.0] # MSRV - include: - - os: macos-latest - python-version: [3.7, 3.8, 3.9, 3.10, 3.11] + os: + - ubuntu-22.04 + - macos-13 + - macos-14 + rust: + - ver: nightly + examples: false + - ver: beta + examples: false + - ver: stable + examples: true + - ver: "1.64.0" # MSRV + examples: false + steps: - name: Checkout sources uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Install Dependencies + - name: (macos) install dependencies + if: ${{ startsWith(matrix.os, 'macos') }} run: | - if [ "$RUNNER_OS" == "Linux" ]; then - sudo apt -y update - sudo apt -y install libhdf5-dev gcc pkg-config python3 curl wget git jq - elif [ "$RUNNER_OS" == "macOS" ]; then - brew install pkg-config - # 1.12 doesn't work? - brew install hdf5@1.10 - else - echo "$RUNNER_OS not supported" - exit 1 - fi + brew install automake autoconf pkg-config hdf5@1.10 + - name: (ubuntu) install dependencies + if: ${{ startsWith(matrix.os, 'ubuntu') }} + run: | + sudo apt -y update + sudo apt -y install libhdf5-dev gcc pkg-config python3{,-pip,-venv} curl wget git jq - name: Install stable toolchain uses: actions-rs/toolchain@v1 with: - toolchain: ${{matrix.rust}} + toolchain: ${{matrix.rust.ver}} profile: minimal override: true components: rustfmt, clippy @@ -72,23 +77,124 @@ jobs: # Taken from https://github.com/dtolnay/thiserror/blob/a2d1ed1ccfc2a5dbb2a8fb45d4f938175a28bc86/.github/workflows/ci.yml - name: Enable type layout randomization run: echo RUSTFLAGS=${RUSTFLAGS}\ -Zrandomize-layout >> $GITHUB_ENV - if: matrix.rust == 'nightly' + if: ${{ matrix.rust.ver == 'nightly' }} + + - name: Run tests (dynamic) + run: cargo test + + - name: Run tests (static) + run: cargo test --features=all-static + + - name: Setup example environment + if: ${{ matrix.rust.examples }} # only run examples on stable + run: | + echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${PWD}/target/debug/ >> $GITHUB_ENV + which gcc || true + which gcc-12 || true + which gcc-13 || true + if [ "$RUNNER_OS" == "Linux" ]; then + echo CC=gcc >> $GITHUB_ENV + else + echo CC=gcc-12 >> $GITHUB_ENV + fi + + - name: Run Rust example + if: ${{ matrix.rust.examples }} # only run examples on stable + run: cargo run --example fee 10 + + - name: Run C examples + if: ${{ matrix.rust.examples }} # only run examples on stable + run: | + cargo build + echo "*** Compiling C examples ***" + # The macOS runner has clang symlinked as gcc, and attempting to alias + # gcc as /usr/local/bin/gcc doesn't work! Why??? + $CC -O3 examples/fee.c -o fee -I ./include/ -L ./target/debug/ -l mwa_hyperbeam + $CC -O3 examples/fee_parallel.c -o fee_parallel -I ./include/ -L ./target/debug/ -l mwa_hyperbeam + $CC -O3 -fopenmp examples/fee_parallel_omp.c -o fee_parallel_omp -I ./include/ -L ./target/debug/ -l mwa_hyperbeam + $CC -O3 examples/fee_get_freqs.c -o fee_get_freqs -I ./include/ -L ./target/debug/ -l mwa_hyperbeam + $CC -O3 examples/analytic.c -o analytic -I ./include/ -L ./target/debug/ -l mwa_hyperbeam + $CC -O3 examples/analytic_parallel.c -o analytic_parallel -I ./include/ -L ./target/debug/ -l mwa_hyperbeam + echo "*** Running C examples ***" + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./fee mwa_full_embedded_element_pattern.h5 + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./fee_parallel mwa_full_embedded_element_pattern.h5 + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./fee_parallel_omp mwa_full_embedded_element_pattern.h5 + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./fee_get_freqs mwa_full_embedded_element_pattern.h5 + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./analytic + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./analytic_parallel + + - name: (ubuntu) Run Python tests + if: ${{ startsWith(matrix.os, 'ubuntu') }} + run: cargo test --features=python - - name: Run tests - run: cargo test --lib --bins + - name: Run Python example + if: ${{ matrix.rust.examples }} # only run examples on stable + run: | + python3 -m venv venv + . ./venv/bin/activate + pip install numpy maturin + echo "*** Compiling Python hyperbeam ***" + maturin develop -b pyo3 --features=python + echo "*** Running Python examples ***" + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./examples/fee.py mwa_full_embedded_element_pattern.h5 + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/debug/ ./examples/analytic.py - - name: CUDA tests - if: runner.os == 'Linux' + - name: (ubuntu) install CUDA + if: ${{ startsWith(matrix.os, 'ubuntu') }} run: | wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb sudo dpkg -i cuda-keyring_1.0-1_all.deb sudo apt -y update sudo apt -y install cuda --no-install-recommends - PATH+=:/usr/local/cuda/bin + echo PATH=${PATH}:/usr/local/cuda/bin >> $GITHUB_ENV + - name: (ubuntu) CUDA smoke tests + if: ${{ startsWith(matrix.os, 'ubuntu') }} + run: | # Can't run the tests; there's no GPU cargo test --all --no-run --features=cuda cargo test --all --no-run --features=cuda,gpu-single cargo test --all --no-run --features=python,cuda cargo test --all --no-run --features=python,cuda,gpu-single + + - name: (ubuntu) CUDA examples + if: ${{ startsWith(matrix.os, 'ubuntu') && matrix.rust.examples }} + run: | + # Examples may fail because there's no GPU + cargo build --features=cuda --example fee_cuda + ./target/debug/examples/fee_cuda 10 || true + cargo build --features=cuda --example analytic_cuda + ./target/debug/examples/analytic_cuda 10 || true + cargo build --features=cuda,gpu-single --example fee_cuda + ./target/debug/examples/fee_cuda 10 || true + cargo build --features=cuda,gpu-single --example analytic_cuda + ./target/debug/examples/analytic_cuda 10 || true + + cargo build --release --features=cuda + $CC -O3 examples/fee_gpu.c -o fee_cuda -I ./include/ -L ./target/release/ -l mwa_hyperbeam + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./fee_cuda mwa_full_embedded_element_pattern.h5 || true + nvcc -O3 examples/fee_cuda_device.cu -o fee_cuda_device -I ./include/ -L ./target/release/ -l mwa_hyperbeam + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release ./fee_cuda_device mwa_full_embedded_element_pattern.h5 || true + $CC -O3 examples/analytic_gpu.c -o analytic_cuda -I ./include/ -L ./target/release/ -l mwa_hyperbeam + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./analytic_cuda || true + nvcc -O3 examples/analytic_cuda_device.cu -o analytic_cuda_device -I ./include/ -L ./target/release/ -l mwa_hyperbeam + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release ./analytic_cuda_device || true + + cargo build --release --features=cuda,gpu-single + $CC -O3 -D SINGLE examples/fee_gpu.c -o fee_cuda -I ./include/ -L ./target/release/ -l mwa_hyperbeam + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./fee_cuda mwa_full_embedded_element_pattern.h5 || true + nvcc -O3 -D SINGLE examples/fee_cuda_device.cu -o fee_cuda_device -I ./include/ -L ./target/release/ -l mwa_hyperbeam + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release ./fee_cuda_device mwa_full_embedded_element_pattern.h5 || true + $CC -O3 -D SINGLE examples/analytic_gpu.c -o analytic_cuda -I ./include/ -L ./target/release/ -l mwa_hyperbeam + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./analytic_cuda || true + nvcc -O3 -D SINGLE examples/analytic_cuda_device.cu -o analytic_cuda_device -I ./include/ -L ./target/release/ -l mwa_hyperbeam + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release ./analytic_cuda_device || true + + . ./venv/bin/activate + maturin develop -b pyo3 --features=python,cuda + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./examples/fee_gpu.py mwa_full_embedded_element_pattern.h5 || true + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./examples/analytic_gpu.py || true + maturin develop -b pyo3 --features=python,cuda,gpu-single + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./examples/fee_gpu.py mwa_full_embedded_element_pattern.h5 || true + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./target/release/ ./examples/analytic_gpu.py || true diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bf6dd8..a0dbe8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.7.2] - 2024-05-14 +### Fixed +- CI (no code changes). + ## [0.7.1] - 2024-01-19 ### Fixed - A (seemingly rare) race condition in FEE GPU code. diff --git a/Cargo.lock b/Cargo.lock index 2d1880d..16de4a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -786,7 +786,7 @@ dependencies = [ [[package]] name = "mwa_hyperbeam" -version = "0.7.1" +version = "0.7.2" dependencies = [ "approx", "cbindgen", diff --git a/Cargo.toml b/Cargo.toml index eca58fe..ae7ce8f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,11 @@ [package] name = "mwa_hyperbeam" -version = "0.7.1" +version = "0.7.2" authors = [ "Christopher H. Jordan ", "Jack L. B. Line ", "Marcin Sokolowski ", + "Dev Null