Skip to content

Update CI workflows including cutting Python v3.10 support #326

Update CI workflows including cutting Python v3.10 support

Update CI workflows including cutting Python v3.10 support #326

# A GitHub Action to test a source distribution created from the repo state.
name: Test source distribution
# Triggers the workflow on PR events for the main branch (only)
on:
pull_request:
# 'reopened' enables manual retrigger via close & re-open. Disable for all
# edits to manage limited resource (PRs often change before merge-ready).
types: [opened, reopened, ready_for_review]
branches:
- main
jobs:
source-dist-test:
# Set-up the build matrix.
# Note: only use one Python version, but it is easier to update in future
# by setting it here and referring to it as ${{ matrix.python-version }}.
strategy:
matrix:
os: [ubuntu-latest, macos-15-intel]
python-version: ["3.14"]
runs-on: ${{ matrix.os }}
# The sequence of tasks that will be executed as part of this job:
steps:
# Need to checkout the repo in order to build the source dist from it,
# but don't install codebase directly in this case, only test the sdist.
- name: Checkout cf-python
uses: actions/checkout@v7
with:
path: main
# Provide a notification message
- name: Notify about setup
run: echo Now setting up the environment for cf-python...
- name: Checkout the current cfdm main to use as the dependency
uses: actions/checkout@v7
with:
repository: NCAS-CMS/cfdm
path: cfdm
# Setup conda, which is the simplest way to access all dependencies,
# especially as some are C-based so otherwise difficult to setup.
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v4
with:
auto-update-conda: true
miniconda-version: "latest"
activate-environment: cf-latest
python-version: ${{ matrix.python-version }}
channels: ncas, conda-forge
# Ensure shell is configured with conda and pip correctly activated.
- name: Check conda and pip config
shell: bash -l {0}
run: |
echo "*Conda report:*"
conda info
conda list
conda config --show-sources
conda config --show
echo "*Pip report:*"
pip --version
pip list
# Ensure release optional dependencies are installed. We can skip 'twine'
# which is only needed for uploading the final source tarball to PyPI
# which we don't want to do in testing. But do need 'build'.
- name: Install dependencies required for release processes
shell: bash -l {0}
run: |
# Not available for 3.12+ on conda at least at present so use pip
pip install build
# Install cf-python dependencies, excluding cfunits and cfdm, pre-testing
# We do so with conda (and pip) which was setup in a previous step.
- name: Install dependencies excluding the NCAS CF Data Tools libraries
shell: bash -l {0}
run: |
conda install -c ncas -c conda-forge cf-plot udunits2
conda install -c conda-forge mpich esmpy
conda install scipy matplotlib dask
# Avoid pip unless cannot get from conda
pip install PyActiveStorage healpix pytest pycodestyle coverage
# Install cfunits and cfdm (from development main branch) separately,
# since it is most robust to test a no-dependency installation of cf, then
# finally install the cf-python development version, but only in order
# to generate the test_file.nc file for testing, not as the cf to test.
- name: Install cfunits then development versions of cfdm and cf-python
shell: bash -l {0}
run: |
pip install cfunits
cd cfdm
pip install -e .
cd ../main
# This next (very meta) command is needed to install requirements.txt
# spec (next) in the conda env rather than globally to the PYTHONPATH:
conda install pip
pip install -r requirements.txt
# Installing cf now but only to be able to run setup_create_field.py
# next, in order to generate the test_file.nc required to test on
pip install --no-deps -e .
# Provide another notification message
- name: Notify about starting the sdist test
run: echo Setup complete. Now creating and testing the source dist...
# Create netCDF files needed for testing. A separate step is required
# for this so the files can be registered and recognised first; locally
# they are created and used on-the-fly by 'run_tests_and_coverage'.
- name: Create netCDF test files, e.g. test_file.nc
shell: bash -l {0}
working-directory: ${{ github.workspace }}/main/cf/test
run: |
# Exit code 5 means no tests were found, which is expected for
# create_test_files.py. Allow that code but fail the workflow
# for any other non-zero exit code, to avoid hiding other failures.
python create_test_files.py || test $? -eq 5
python setup_create_field.py
ls -la
- name: Create the source distribution and store the version as an env var
shell: bash -l {0}
working-directory: ${{ github.workspace }}/main
run: |
# Previously 'python setup.py sdist', but this is now deprecated
python -m build
# Get the cf-python version and put it in an environment variable for
# the next step (only available in steps subsequent to one set in)
# Use backticks here to avoid nested double quotes which break some
# syntax highlighting. More robust to query package metadata than
# the __version__ attribute.
CF_VERSION=`python -c 'from importlib.metadata import version; print(version("cf-python"))'`
echo "CF_VERSION=${CF_VERSION}" >> $GITHUB_ENV
- name: Test the source distribution
shell: bash -l {0}
working-directory: ${{ github.workspace }}/main
run: |
cd ${{ github.workspace }}/main
./test_release $CF_VERSION
# End with a message indicating the sdist test has completed its run
- name: Notify about a completed run
run: |
echo The test of the latest cf-python source distribution has now
echo completed and you may inspect the results.