-
Notifications
You must be signed in to change notification settings - Fork 19
136 lines (121 loc) · 5.16 KB
/
test-source-dist.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# 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 refering to it as ${{ matrix.python-version }}.
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.8"]
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@v3
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@v3
with:
repository: NCAS-CMS/cfdm
path: cfdm
# Prepare to test the source dist using the given Python version
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# 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@v2
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
# 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=2.2.25
conda install -c conda-forge mpich esmpy
conda install scipy matplotlib dask
pip install pycodestyle
# 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 ${{ github.workspace }}/cfdm
pip install -e .
cd ${{ github.workspace }}/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}
run: |
cd ${{ github.workspace }}/main/cf/test
python create_test_files.py
python setup_create_field.py
ls -la
- name: Create the source distribution and store the version as an env var
shell: bash -l {0}
run: |
cd ${{ github.workspace }}/main
python setup.py sdist
# 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).
echo "CF_VERSION=$(python setup.py --version 2> /dev/null)" >> $GITHUB_ENV
- name: Test the source distribution
shell: bash -l {0}
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.