Skip to content

Commit ca69c33

Browse files
committed
Merge branch 'main' into igrf
2 parents be26f1b + 10a58ce commit ca69c33

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1342
-365
lines changed

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ exclude =
2222
per-file-ignores =
2323
# disable unused-imports errors on __init__.py
2424
__init__.py: F401
25+
# ignore shadowing of builtin for harmonica/_io
26+
harmonica/_io/__init__.py: A005
2527

2628
# Configure flake8-rst-docstrings
2729
# -------------------------------

.github/workflows/actions.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Lint GitHub Actions for common security issues using zizmor.
2+
# Docs: https://woodruffw.github.io/zizmor
3+
4+
name: lint-actions
5+
6+
# Only run on PRs and the main branch.
7+
# Pushes to branches will only trigger a run when a PR is opened.
8+
on:
9+
pull_request:
10+
push:
11+
branches:
12+
- main
13+
14+
permissions: {}
15+
16+
jobs:
17+
lint:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
persist-credentials: false
24+
25+
- name: Setup Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: "3.12"
29+
30+
- name: Install requirements
31+
run: python -m pip install -r env/requirements-style.txt
32+
33+
- name: List installed packages
34+
run: python -m pip freeze
35+
36+
- name: Lint GitHub Actions
37+
run: make check-actions
38+
env:
39+
# Set GH_TOKEN to allow zizmor to check online vulnerabilities
40+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/docs.yml

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ on:
1818
types:
1919
- published
2020

21+
permissions: {}
22+
2123
# Use bash by default in all jobs
2224
defaults:
2325
run:
2426
# The -l {0} is necessary for conda environments to be activated
2527
# But this breaks on MacOS if using actions/setup-python:
2628
# https://github.com/actions/setup-python/issues/132
27-
shell: bash -l {0}
29+
# -e makes sure builds fail if any command fails
30+
shell: bash -e -o pipefail -l {0}
2831

2932
jobs:
3033
#############################################################################
@@ -33,7 +36,8 @@ jobs:
3336
runs-on: ubuntu-latest
3437
env:
3538
REQUIREMENTS: env/requirements-build.txt env/requirements-docs.txt
36-
PYTHON: "3.11"
39+
PYTHON: "3.12"
40+
ENSAIO_DATA_FROM_GITHUB: true
3741

3842
steps:
3943

@@ -58,10 +62,9 @@ jobs:
5862
uses: conda-incubator/setup-miniconda@v3
5963
with:
6064
python-version: ${{ env.PYTHON }}
61-
miniforge-variant: Mambaforge
62-
use-mamba: true
63-
channels: conda-forge,defaults
64-
# Allow mamba to use other than tar.bz2
65+
miniforge-version: latest
66+
channels: conda-forge
67+
# Allow conda to use other than tar.bz2
6568
# (otherwise it cannot find latest versions that
6669
# don't use tar-bz2 files, see
6770
# https://github.com/conda-incubator/setup-miniconda/issues/267)
@@ -70,7 +73,7 @@ jobs:
7073
- name: Collect requirements
7174
run: |
7275
echo "Install Dependente to capture dependencies:"
73-
mamba install dependente==0.3.0 -c conda-forge
76+
conda install dependente==0.3.0 -c conda-forge
7477
echo ""
7578
echo "Capturing run-time dependencies:"
7679
dependente --source install > requirements-full.txt
@@ -84,17 +87,25 @@ jobs:
8487
echo "Collected dependencies:"
8588
cat requirements-full.txt
8689
90+
- name: Rename conda-forge packages
91+
run: |
92+
echo "Rename conda-forge packages in requirements-full.txt"
93+
# Replace "build" for "python-build"
94+
sed -s --in-place 's/^build$/python-build/' requirements-full.txt
95+
echo "Renamed dependencies:"
96+
cat requirements-full.txt
97+
8798
- name: Setup caching for conda packages
8899
uses: actions/cache@v4
89100
with:
90101
path: ~/conda_pkgs_dir
91102
key: conda-${{ runner.os }}-${{ env.PYTHON }}-${{ hashFiles('requirements-full.txt') }}
92103

93104
- name: Install requirements
94-
run: mamba install --quiet --file requirements-full.txt python=$PYTHON
105+
run: conda install --quiet --file requirements-full.txt python=$PYTHON
95106

96107
- name: List installed packages
97-
run: mamba list
108+
run: conda list
98109

99110
- name: Build source and wheel distributions
100111
run: |
@@ -133,11 +144,17 @@ jobs:
133144
publish:
134145
runs-on: ubuntu-latest
135146
needs: build
147+
permissions:
148+
contents: write
136149
if: github.event_name == 'release' || github.event_name == 'push'
137150

138151
steps:
139152
- name: Checkout
140153
uses: actions/checkout@v4
154+
with:
155+
# The GitHub token is preserved by default but this job doesn't need
156+
# to be able to push to GitHub.
157+
persist-credentials: false
141158

142159
# Fetch the built docs from the "build" job
143160
- name: Download HTML documentation artifact
@@ -154,33 +171,36 @@ jobs:
154171
path: deploy
155172
# Download the entire history
156173
fetch-depth: 0
174+
# We need to explicitly preserve the credentials for the GitHub token
175+
# on this branch so we can push to it.
176+
persist-credentials: true
157177

158178
- name: Push the built HTML to gh-pages
159179
run: |
160180
# Detect if this is a release or from the main branch
161181
if [[ "${{ github.event_name }}" == "release" ]]; then
162-
# Get the tag name without the "refs/tags/" part
163-
version="${GITHUB_REF#refs/*/}"
182+
# Get the tag name without the "refs/tags/" part
183+
version="${GITHUB_REF#refs/*/}"
164184
else
165-
version=dev
185+
version=dev
166186
fi
167187
echo "Deploying version: $version"
168188
# Make the new commit message. Needs to happen before cd into deploy
169189
# to get the right commit hash.
170190
message="Deploy $version from $(git rev-parse --short HEAD)"
171-
cd deploy
191+
cd deploy || exit 1
172192
# Need to have this file so that Github doesn't try to run Jekyll
173193
touch .nojekyll
174194
# Delete all the files and replace with our new set
175195
echo -e "\nRemoving old files from previous builds of ${version}:"
176-
rm -rvf ${version}
196+
rm -rvf "${version}"
177197
echo -e "\nCopying HTML files to ${version}:"
178-
cp -Rvf ../doc/_build/html/ ${version}/
198+
cp -Rvf ../doc/_build/html/ "${version}/"
179199
# If this is a new release, update the link from /latest to it
180200
if [[ "${version}" != "dev" ]]; then
181-
echo -e "\nSetup link from ${version} to 'latest'."
182-
rm -f latest
183-
ln -sf ${version} latest
201+
echo -e "\nSetup link from ${version} to 'latest'."
202+
rm -f latest
203+
ln -sf "${version}" latest
184204
fi
185205
# Stage the commit
186206
git add -A .
@@ -192,15 +212,15 @@ jobs:
192212
# If this is a dev build and the last commit was from a dev build
193213
# (detect if "dev" was in the previous commit message), reuse the
194214
# same commit
195-
if [[ "${version}" == "dev" && `git log -1 --format='%s'` == *"dev"* ]]; then
196-
echo -e "\nAmending last commit:"
197-
git commit --amend --reset-author -m "$message"
215+
if [[ "${version}" == "dev" && $(git log -1 --format='%s') == *"dev"* ]]; then
216+
echo -e "\nAmending last commit:"
217+
git commit --amend --reset-author -m "$message"
198218
else
199-
echo -e "\nMaking a new commit:"
200-
git commit -m "$message"
219+
echo -e "\nMaking a new commit:"
220+
git commit -m "$message"
201221
fi
202222
# Make the push quiet just in case there is anything that could leak
203223
# sensitive information.
204224
echo -e "\nPushing changes to gh-pages."
205-
git push -fq origin gh-pages 2>&1 >/dev/null
225+
{ git push -fq origin gh-pages >/dev/null; } 2>&1
206226
echo -e "\nFinished uploading generated files."

.github/workflows/pypi.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ on:
1717
types:
1818
- published
1919

20+
permissions: {}
21+
2022
# Use bash by default in all jobs
2123
defaults:
2224
run:
@@ -49,7 +51,7 @@ jobs:
4951
- name: Setup Python
5052
uses: actions/setup-python@v5
5153
with:
52-
python-version: "3.10"
54+
python-version: "3.12"
5355

5456
- name: Install requirements
5557
run: python -m pip install -r env/requirements-build.txt
@@ -113,7 +115,7 @@ jobs:
113115
- name: Publish to Test PyPI
114116
# Only publish to TestPyPI when a PR is merged (pushed to main)
115117
if: success() && github.event_name == 'push'
116-
uses: pypa/gh-action-pypi-publish@v1.8.14
118+
uses: pypa/gh-action-pypi-publish@v1.12.4
117119
with:
118120
repository_url: https://test.pypi.org/legacy/
119121
# Allow existing releases on test PyPI without errors.
@@ -123,4 +125,4 @@ jobs:
123125
- name: Publish to PyPI
124126
# Only publish to PyPI when a release triggers the build
125127
if: success() && github.event_name == 'release'
126-
uses: pypa/gh-action-pypi-publish@v1.8.14
128+
uses: pypa/gh-action-pypi-publish@v1.12.4

.github/workflows/style.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ on:
1414
branches:
1515
- main
1616

17+
permissions: {}
18+
1719
###############################################################################
1820
jobs:
1921
format:
@@ -27,7 +29,7 @@ jobs:
2729
- name: Setup Python
2830
uses: actions/setup-python@v5
2931
with:
30-
python-version: "3.11"
32+
python-version: "3.12"
3133

3234
- name: Install requirements
3335
run: pip install -r env/requirements-style.txt
@@ -49,7 +51,7 @@ jobs:
4951
- name: Setup Python
5052
uses: actions/setup-python@v5
5153
with:
52-
python-version: "3.11"
54+
python-version: "3.12"
5355

5456
- name: Install requirements
5557
run: pip install -r env/requirements-style.txt

.github/workflows/test.yml

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ on:
1818
types:
1919
- published
2020

21+
permissions: {}
22+
2123
# Use bash by default in all jobs
2224
defaults:
2325
run:
2426
shell: bash
2527

2628
jobs:
2729
#############################################################################
28-
# Run tests and upload to codecov
30+
# Run tests
2931
test:
3032
name: ${{ matrix.os }} python=${{ matrix.python }} dependencies=${{ matrix.dependencies }}
3133
runs-on: ${{ matrix.os }}
@@ -44,26 +46,22 @@ jobs:
4446
- optional
4547
include:
4648
- dependencies: oldest
47-
python: "3.8"
49+
python: "3.9"
4850
- dependencies: latest
49-
python: "3.11"
51+
python: "3.12"
5052
- dependencies: optional
51-
python: "3.11"
53+
python: "3.12"
5254
# test on macos-13 (x86) using oldest dependencies and python 3.8
5355
- os: macos-13
5456
dependencies: oldest
55-
python: "3.8"
57+
python: "3.9"
5658
exclude:
5759
# don't test on macos-latest (arm64) with oldest dependencies
5860
- os: macos-latest
5961
dependencies: oldest
6062

6163
env:
6264
REQUIREMENTS: env/requirements-build.txt env/requirements-tests.txt
63-
# Used to tag codecov submissions
64-
OS: ${{ matrix.os }}
65-
PYTHON: ${{ matrix.python }}
66-
DEPENDENCIES: ${{ matrix.dependencies }}
6765

6866
steps:
6967

@@ -155,11 +153,38 @@ jobs:
155153
- name: Convert coverage report to XML for codecov
156154
run: coverage xml
157155

158-
- name: Upload coverage to Codecov
159-
uses: codecov/codecov-action@v4
156+
- name: Upload coverage report as an artifact
157+
uses: actions/upload-artifact@v4
158+
with:
159+
name: coverage_${{ matrix.os }}_${{ matrix.dependencies }}
160+
path: ./coverage.xml
161+
162+
163+
#############################################################################
164+
# Upload coverage report to codecov
165+
codecov-upload:
166+
runs-on: ubuntu-latest
167+
needs: test
168+
169+
steps:
170+
171+
- name: Download coverage report artifacts
172+
# Download coverage reports from every runner.
173+
# Maximum coverage is achieved by combining reports from every runner.
174+
# Each coverage file will live in its own folder with the same name as
175+
# the artifact.
176+
uses: actions/download-artifact@v4
177+
with:
178+
pattern: coverage_*
179+
180+
- name: List all downloaded artifacts
181+
run: ls -l -R .
182+
183+
- name: Upload coverage reports to Codecov
184+
uses: codecov/codecov-action@v5
160185
with:
161-
file: ./coverage.xml
162-
env_vars: OS,PYTHON,DEPENDENCIES
186+
# Upload all coverage report files
187+
files: ./coverage_*/coverage.xml
163188
# Fail the job so we know coverage isn't being updated. Otherwise it
164189
# can silently drop and we won't know.
165190
fail_ci_if_error: true

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ order by last name) and are considered "The Harmonica Developers":
1010
* [Agustina Pesce](https://github.com/aguspesce) - Universidad Nacional de San Juan, Argentina (ORCID: 0000-0002-5538-8845)
1111
* [Nicholas Shea](https://github.com/nshea3) - MINES ParisTech (ORCID: 0000-0001-6007-5686)
1212
* [Santiago Soler](https://github.com/santisoler) - Department of Earth, Ocean and Atmospheric Sciences, University of British Columbia (ORCID: 0000-0001-9202-5317)
13+
* [Gelson Ferreira Souza-Junior](https://github.com/Souza-junior) - Universidade de São Paulo, Brazil (ORCID: 0000-0002-5695-4239)
1314
* [Matthew Tankersley](https://github.com/mdtanker) - Antarctic Research Centre, Victoria University of Wellington, New Zealand (ORCID: 0000-0003-4266-8554)
1415
* [Leonardo Uieda](https://github.com/leouieda) - Universidade de São Paulo, Brazil (ORCID: 0000-0001-6123-9515)
1516
* [India Uppal](https://github.com/indiauppal) - The University of Liverpool, UK (ORCID: 0000-0003-3531-2656)

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ TESTDIR=tmp-test-dir-with-unique-name
44
PYTEST_ARGS=--cov-config=../.coveragerc --cov-report=term-missing --cov=$(PROJECT) --doctest-modules --doctest-continue-on-failure -v --pyargs
55
NUMBATEST_ARGS=--doctest-modules -v --pyargs -m use_numba
66
STYLE_CHECK_FILES=$(PROJECT) examples doc
7+
GITHUB_ACTIONS=.github/workflows
8+
9+
.PHONY: build install test test_coverage test_numba format check check-format check-style check-actions clean
710

811
help:
912
@echo "Commands:"
@@ -54,6 +57,9 @@ check-format:
5457
check-style:
5558
flake8 $(STYLE_CHECK_FILES)
5659

60+
check-actions:
61+
zizmor $(GITHUB_ACTIONS)
62+
5763
clean:
5864
find . -name "*.pyc" -exec rm -v {} \;
5965
find . -name ".coverage.*" -exec rm -v {} \;

0 commit comments

Comments
 (0)