Skip to content

Correctly search in simulations for location without Lev component #315

Correctly search in simulations for location without Lev component

Correctly search in simulations for location without Lev component #315

Workflow file for this run

name: tests
on:
push:
branches:
- main
tags: ['*']
pull_request:
concurrency:
group: test-${{ github.head_ref }}
cancel-in-progress: true
env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"
jobs:
build:
name: Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
runs-on: ${{ matrix.os }}
if: >-
!contains(github.event.head_commit.message, '[skip ci]')
&& !contains(github.event.head_commit.message, '[skip tests]')
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.8', '3.12']
steps:
- name: Skip replicates on main branch
env:
skip_replicates: ${{ github.ref == 'refs/heads/main' && (matrix.os != 'ubuntu-latest' || matrix.python-version != '3.12') }}
shell: bash
run: |
echo "skipping_build_and_test_replicate=${skip_replicates}" >> $GITHUB_ENV
- name: Cache sxs file storage
if: ${{ env.skipping_build_and_test_replicate != 'true' }}
uses: actions/cache@v4
with:
key: sxs-${{ runner.os }}-python${{ matrix.python-version }}
path: |
~/.sxs
restore-keys: |
sxs-${{ runner.os }}-
sxs-
- name: Set up Julia
if: ${{ env.skipping_build_and_test_replicate != 'true' }}
uses: julia-actions/setup-julia@v2
- name: Cache Julia
if: ${{ env.skipping_build_and_test_replicate != 'true' }}
uses: julia-actions/cache@v2
- name: Check out code
if: ${{ env.skipping_build_and_test_replicate != 'true' }}
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
if: ${{ env.skipping_build_and_test_replicate != 'true' }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Hatch
if: ${{ env.skipping_build_and_test_replicate != 'true' }}
run: python -m pip install --disable-pip-version-check --upgrade hatch
- name: Run tests
if: ${{ env.skipping_build_and_test_replicate != 'true' }}
run: hatch run test
- name: Upload coverage
if: "matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest'"
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
release:
name: Create release and send to PyPI
needs: build
runs-on: ubuntu-latest
if: >-
github.ref == 'refs/heads/main'
&& github.repository_owner == 'sxs-collaboration'
&& !contains(github.event.head_commit.message, '[no release]')
&& (success() || contains(github.event.head_commit.message, '[skip tests]'))
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Hatch
run: python -m pip install --disable-pip-version-check --upgrade hatch
- name: Bump version
shell: bash
env:
github_event_head_commit_message: ${{ github.event.head_commit.message }}
run: |
# Note: The following line reads the HEAD commit message to look for an indication of how
# to bump the version number. Specifically, if `#patch`, `#minor`, or `#major` is present
# in the commit message, it bumps the corresponding version number. Those can also be
# prepended as `#premajor`, etc., to add/bump the prerelease modifier. If none of those
# are present, `#patch` is assumed — that is, the lowest-significance number is
# incremented. See the documentation of the `hatch version` command for details.
export version_bump_rule=$(python .github/scripts/parse_bump_rule.py)
echo "version_bump_rule: '${version_bump_rule}'"
hatch version "${version_bump_rule}"
export new_version=$(TERM="unknown" hatch version)
echo "new_version: '${new_version}'"
echo "new_version=${new_version}" >> $GITHUB_ENV # Save env variable for later steps
- name: Update CITATION.cff
shell: bash
env:
timestamp: ${{ github.event.head_commit.timestamp }}
run: |
new_date=${timestamp:0:10}
sed -i -- "s/^version:.*/version: ${new_version}/" CITATION.cff
sed -i -- "s/^date-released:.*/date-released: ${new_date}/" CITATION.cff
echo "Updated CITATION.cff with version ${new_version} and date ${new_date}"
- name: Tag and push new version
shell: bash
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add CITATION.cff sxs/__version__.py
git commit -m "Bump version to v${new_version}"
git tag -a "v${new_version}" -m "Version ${new_version}"
git status
git push --follow-tags # Will not trigger new workflow because it uses GITHUB_TOKEN
- name: Create release
if: "!contains(github.event.head_commit.message, '[no release]')"
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.new_version }}
name: Release v${{ env.new_version }}
draft: false
prerelease: false
- name: Publish to PyPI
if: "!contains(github.event.head_commit.message, '[no pypi]')"
env:
# 1) Get key from https://pypi.org/manage/account/token/
# 2) Copy it to Github > repo > Settings > Secrets
HATCH_INDEX_USER: __token__
HATCH_INDEX_AUTH: ${{ secrets.PYPI_TOKEN }}
shell: bash
run: |
hatch build
hatch publish
binder:
name: Trigger a binder rebuild
needs: release
runs-on: ubuntu-latest
if: >-
github.ref == 'refs/heads/main'
&& !contains(github.event.head_commit.message, '[no release]')
&& (success() || contains(github.event.head_commit.message, '[skip tests]'))
steps:
- name: Trigger other repository
# I created a new personal access token via github profile > settings > developer settings >
# personal access tokens. I clicked the "repo" checkbox, created the token, and copied it.
# Then, I went to this repo's settings > secrets, and created a new secret named
# "MOBLE_TOKEN" with a value of "moble:<token>", where <token> is the copied token. This
# command sends a POST to the other repo, which is set up to build on `workflow_dispatch`.
run: |
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-u ${{ secrets.MOBLE_TOKEN }} \
https://api.github.com/repos/moble/sxs_notebooks/actions/workflows/binder.yml/dispatches \
-d '{"ref":"refs/heads/master"}'