Skip to content

Commit

Permalink
refactor actions (#477)
Browse files Browse the repository at this point in the history
  • Loading branch information
d-chambers authored Jan 3, 2025
1 parent 084f21f commit de58374
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 218 deletions.
20 changes: 20 additions & 0 deletions .github/actions/build-docs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Build DASCore Docs"
description: "Builds DASCore's Documentation."

runs:
using: "composite"
steps:
- name: Install quarto
uses: quarto-dev/quarto-actions/setup@v2
with:
version: 1.3.450
tinytex: true

- name: print quarto version
run: |
quarto --version
- name: render API docs
shell: bash -l {0}
run: |
python scripts/build_api_docs.py
90 changes: 90 additions & 0 deletions .github/actions/mamba-install-dascore/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: "Mamba Install"
description: "Sets up mamba before installing DASCore's environment.yml file."
inputs:
python-version:
description: "The python string of the version to install"
required: true

environment-file:
description: "The path to the environment file to use."
required: false
default: "environment.yml"

install-group-str:
description: "The string to use for specifying install groups"
default: "[dev]"
required: false

install-package:
description: "If true, install dascore"
default: true
required: false
type: boolean

cache-number:
description: "Cache number. Use != 1 to reset data cache"
required: false
default: 1

runs:
using: "composite"
steps:
- name: Set up environment variable with date
shell: bash -l {0}
run: echo "CURRENT_DATE=$(date '+%Y-%m-%d')" >> $GITHUB_ENV

- uses: mamba-org/setup-micromamba@v2
with:
micromamba-version: '2.0.5-0' # versions: https://github.com/mamba-org/micromamba-releases
environment-file: ${{ inputs.environment-file }}
init-shell: >-
bash
powershell
cache-environment: true
cache-environment-key: environment-${{ env.CURRENT_DATE }}-${{ inputs.environment-file }}
post-cleanup: 'all'
create-args: >-
python=${{ inputs.python-version }}
# Not sure why this is needed but it appears to be the case
- name: fix env
shell: bash -l {0}
run: |
micromamba shell init --shell bash --root-prefix=~/micromamba
eval "$(micromamba shell hook --shell bash)"
micromamba activate dascore
- name: print python version
shell: bash -el {0}
run: |
python --version
- name: get tags for correct versioning
shell: bash -el {0}
run: |
git fetch --tags --force
- name: install dascore
if: "${{ inputs.install-package == 'true' }}"
shell: bash -l {0}
run: |
pip install -e .${{ inputs.install-group-str }}
- name: set data cache path
shell: bash -el {0}
run: |
echo "DATA_CACHE_PATH=$(python -c "import pooch; print(pooch.os_cache('dascore'))")" >> $GITHUB_ENV
- name: cache test data
uses: actions/cache@v3
with:
enableCrossOsArchive: true
path: ${{ env.DATA_CACHE_PATH }}
key: DATA_${{ inputs.cache-number }}

# Print out the package info for current environment
- name: print package info
shell: bash -el {0}
run: |
micromamba info
micromamba list
7 changes: 7 additions & 0 deletions .github/min_deps_environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: dascore
channels:
- conda-forge
dependencies:
- pytables
- h5py
- pooch
46 changes: 5 additions & 41 deletions .github/workflows/build_deploy_master_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,50 +34,14 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: "true"

- name: "get tags"
run: |
git fetch --tags --force # Retrieve annotated tags.
- uses: mamba-org/setup-micromamba@v1
- uses: ./.github/actions/mamba-install-dascore
with:
micromamba-version: '1.5.8-0' # versions: https://github.com/mamba-org/micromamba-releases
environment-file: ./.github/doc_environment.yml
init-shell: >-
bash
powershell
cache-environment: true
post-cleanup: 'all'

# Not sure why this is needed but it appears to be the case
- name: fix env
shell: bash -l {0}
run: |
micromamba shell init --shell bash --root-prefix=~/micromamba
eval "$(micromamba shell hook --shell bash)"
micromamba activate dascore
- name: install dascore with docbuild reqs
shell: bash -l {0}
run: |
conda install -c conda-forge pandoc
python -m pip install -e .[docs,all]
python-version: "3.12"
environment-file: '././github/doc_environment.yml'

- name: Install quarto
uses: quarto-dev/quarto-actions/setup@v2
with:
version: 1.3.450
tinytex: true

- name: print quarto version
run: |
quarto --version
- name: render API docs
shell: bash -l {0}
run: |
python scripts/build_api_docs.py
- uses: ./.github/actions/build-docs

- name: publish docs to netlify
shell: bash -l {0}
Expand Down
51 changes: 5 additions & 46 deletions .github/workflows/build_deploy_stable_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,55 +32,14 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: "true"

- name: "get tags"
run: |
git fetch --tags --force # Retrieve annotated tags.
- name: Get tags
run: git fetch --tags origin

- uses: mamba-org/setup-micromamba@v2
- uses: ./.github/actions/mamba-install-dascore
with:
micromamba-version: '2.0.2-1' # versions: https://github.com/mamba-org/micromamba-releases
environment-file: ./.github/doc_environment.yml
init-shell: >-
bash
powershell
cache-environment: true
post-cleanup: 'all'
cache-environment-key: environment-${{ steps.date.outputs.date }}

# Not sure why this is needed but it appears to be the case
- name: fix env
shell: bash -l {0}
run: |
micromamba shell init --shell bash --root-prefix=~/micromamba
eval "$(micromamba shell hook --shell bash)"
micromamba activate dascore
- name: install dascore with docbuild reqs
shell: bash -l {0}
run: |
conda install -c conda-forge pandoc
python -m pip install -e .[docs,all]
- name: Install quarto
uses: quarto-dev/quarto-actions/setup@v2
with:
version: 1.3.450
tinytex: true

- name: print quarto version
run: |
quarto --version
python-version: "3.12"
environment-file: '././github/doc_environment.yml'

- name: Render Quarto Project
shell: bash -l {0}
run: |
python scripts/build_api_docs.py
quarto render docs
- uses: ./.github/actions/build-docs

- name: Setup Pages
uses: actions/configure-pages@v2
Expand Down
27 changes: 2 additions & 25 deletions .github/workflows/get_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,9 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: "get tags"
run: |
git fetch --tags --force # Retrieve annotated tags.
- uses: mamba-org/setup-micromamba@v1
- uses: ./.github/actions/min-deps-install-dascore
with:
micromamba-version: '1.5.8-0' # versions: https://github.com/mamba-org/micromamba-releases
environment-file: environment.yml
init-shell: >-
bash
powershell
cache-environment: true
post-cleanup: 'all'

# Not sure why this is needed but it appears to be the case
- name: fix env
shell: bash -l {0}
run: |
micromamba shell init --shell bash --root-prefix=~/micromamba
eval "$(micromamba shell hook --shell bash)"
micromamba activate dascore
- name: install dascore
shell: bash -l {0}
run: |
python -m pip install -e .[test]
python-version: ${{ matrix.python-version }}

- name: run test suite
shell: bash -l {0}
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ jobs:

steps:
- uses: actions/checkout@v4

- name: "get tags"
run: |
git fetch --tags --force # Retrieve annotated tags.
with:
fetch-tags: 'true'

- name: Install uv
uses: astral-sh/setup-uv@v3
Expand Down
56 changes: 5 additions & 51 deletions .github/workflows/run_min_dep_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ on:
- '**.py'
- '.github/workflows/run_min_dep_tests.yml'

env:
# used to manually trigger cache reset. Just increment if needed.
CACHE_NUMBER: 1

# Cancel previous runs when this one starts.
concurrency:
group: TestCodeMinDeps-${{ github.event.pull_request.number || github.run_id }}
Expand All @@ -35,63 +31,21 @@ jobs:
# only run if CI isn't turned off
if: github.event_name == 'push' || !contains(github.event.pull_request.labels.*.name, 'no_ci')

env:
# set conda environment file with dependencies
env_file: "environment.yml"

steps:
- uses: actions/checkout@v4
with:
depth: 0

- name: "get tags"
run: |
git fetch --tags --force # Retrieve annotated tags.
fetch-tags: 'true'

- uses: mamba-org/setup-micromamba@v2
- uses: ./.github/actions/mamba-install-dascore
with:
micromamba-version: '2.0.2-1' # versions: https://github.com/mamba-org/micromamba-releases
environment-file: environment.yml
init-shell: >-
bash
powershell
cache-environment: true
cache-environment-key: environment-${{ steps.date.outputs.date }}
post-cleanup: 'all'
create-args: >-
python=${{ matrix.python-version }}
# Not sure why this is needed but it appears to be the case.
# Also installs pytables so hdf5 gets installed on windows
- name: fix env
shell: bash -l {0}
run: |
micromamba shell init --shell bash --root-prefix=~/micromamba
eval "$(micromamba shell hook --shell bash)"
micromamba activate dascore
- name: install hdf5
shell: bash -l {0}
run: |
micromamba install pytables
python-version: ${{ matrix.python-version }}
install-package: false
environment-file: './.github/min_deps_environment.yml'

# Then switch over to uv. We can use this exclusively once we drop pytables.
- name: Install uv
uses: astral-sh/setup-uv@v3

- name: set data cache path
shell: bash -l {0}
run: |
export PATH="$pythonLocation:$PATH"
echo "DATA_CACHE_PATH=$(uv run --extra test python -c "import pooch; print(pooch.os_cache('dascore'))")" >> $GITHUB_ENV
- name: cache test data
uses: actions/cache@v3
with:
enableCrossOsArchive: true
path: ${{ env.DATA_CACHE_PATH }}
key: DATA_${{ env.CACHE_NUMBER }}

- name: run test suite
shell: bash -l {0}
run: uv run --extra test --python ${{ matrix.python-version }} pytest -s --cov dascore --cov-append --cov-report=xml
Expand Down
Loading

0 comments on commit de58374

Please sign in to comment.