From fc6c948764a3564408c943ee4e678049bf90b75f Mon Sep 17 00:00:00 2001 From: Iain Russell Date: Thu, 18 Apr 2024 15:07:16 +0100 Subject: [PATCH] ECC-1793: develop binary wheel - Linux --- .github/workflows/build-wheel-linux.yml | 58 +++++++++++++++++++++++++ scripts/select-python-linux.sh | 25 +++++++++++ scripts/test-linux.sh | 28 ++++++++++++ 3 files changed, 111 insertions(+) create mode 100755 scripts/select-python-linux.sh create mode 100755 scripts/test-linux.sh diff --git a/.github/workflows/build-wheel-linux.yml b/.github/workflows/build-wheel-linux.yml index d9cd398..afa2972 100644 --- a/.github/workflows/build-wheel-linux.yml +++ b/.github/workflows/build-wheel-linux.yml @@ -84,3 +84,61 @@ jobs: with: name: wheel-manylinux2014-3.12 path: wheelhouse/*.whl + + test: + + needs: build + + strategy: + fail-fast: false + matrix: # We don't test 3.6, as it is not supported anymore by github actions + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + + runs-on: [self-hosted, Linux] + + name: Test with ${{ matrix.python-version }} + + steps: + + - uses: actions/checkout@v2 + + - uses: actions/download-artifact@v2 + with: + name: wheel-manylinux2014-${{ matrix.python-version }} + + - run: ./scripts/test-linux.sh ${{ matrix.python-version }} + + + deploy: + + if: ${{ github.event_name == 'release' }} + + strategy: + fail-fast: false + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11"] + + needs: [test, build] + + name: Deploy wheel ${{ matrix.python-version }} + + runs-on: [self-hosted, Linux] + + + steps: + + - run: mkdir artifact-${{ matrix.python-version }} + + - uses: actions/download-artifact@v2 + with: + name: wheel-manylinux2014-${{ matrix.python-version }} + path: artifact-${{ matrix.python-version }} + + - run: | + source ./scripts/select-python-linux.sh ${{ matrix.python-version }} + pip3 install twine + ls -l artifact-${{ matrix.python-version }}/*.whl + twine upload --repository testpypi artifact-${{ matrix.python-version }}/*.whl + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_TEST_API_TOKEN }} \ No newline at end of file diff --git a/scripts/select-python-linux.sh b/scripts/select-python-linux.sh new file mode 100755 index 0000000..595fa85 --- /dev/null +++ b/scripts/select-python-linux.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# (C) Copyright 2024 ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# In applying this licence, ECMWF does not waive the privileges and immunities +# granted to it by virtue of its status as an intergovernmental organisation +# nor does it submit to any jurisdiction. + +set -xe +version=$1 + +source /opt/conda/etc/profile.d/conda.sh + +CONDA_PY_ENV_DIR=$RUNNER_TEMP/venv_$version + +if [ ! -d "${CONDA_PY_ENV_DIR}" ]; then + conda create -y -p $CONDA_PY_ENV_DIR +fi + +conda activate $CONDA_PY_ENV_DIR +conda install -y python=${{ inputs.version }} openldap + +which python3 +python3 --version diff --git a/scripts/test-linux.sh b/scripts/test-linux.sh new file mode 100755 index 0000000..03e361b --- /dev/null +++ b/scripts/test-linux.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# (C) Copyright 2024 ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# In applying this licence, ECMWF does not waive the privileges and immunities +# granted to it by virtue of its status as an intergovernmental organisation +# nor does it submit to any jurisdiction. + +set -eaux +python_version=$1 + +ls -l +source ./scripts/select-python-linux.sh ${python_version} + +echo $PATH +pwd +ls -l + +pip install *.whl +pip install pytest +pip install -r tests/requirements.txt +pip freeze + +cd tests +pytest -v -s + +rm -fr *.whl tests \ No newline at end of file