Skip to content

Commit

Permalink
resolving merge
Browse files Browse the repository at this point in the history
  • Loading branch information
K20shores committed Aug 15, 2024
2 parents 5505e81 + d457bbd commit b76b26d
Show file tree
Hide file tree
Showing 39 changed files with 840 additions and 385 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/CI_Tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: CI Tests

on: [push, workflow_dispatch]
on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
build:
Expand Down
132 changes: 132 additions & 0 deletions .github/workflows/gh_pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Build and deploy documentation to GitHub Pages
name: GitHub Pages

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

env:
DEFAULT_BRANCH: "release"

jobs:
build-and-deploy:
name: Build and deploy to gh-pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true

- name: Debugging information
run: |
echo "github.ref:" ${{github.ref}}
echo "github.event_name:" ${{github.event_name}}
echo "github.head_ref:" ${{github.head_ref}}
echo "github.base_ref:" ${{github.base_ref}}
set -x
git rev-parse --abbrev-ref HEAD
git branch
git branch -a
git remote -v
python -V
pip list --not-required
pip list
# Clone and set up the old gh-pages branch
- name: Clone old gh-pages
if: ${{ github.event_name == 'push' }}
run: |
set -x
git fetch
( git branch gh-pages remotes/origin/gh-pages && git clone . --branch=gh-pages _gh-pages/ ) || mkdir _gh-pages
rm -rf _gh-pages/.git/
mkdir -p _gh-pages/branch/
# If a push and default branch, copy build to _gh-pages/ as the "main"
# deployment.
- name: Build and copy documentation (default branch)
if: |
contains(github.event_name, 'push') &&
contains(github.ref, env.DEFAULT_BRANCH)
run: |
set -x
mkdir -p _build/html/versions
# create two copies of the documentation
# 1. the frozen version, represented as vX.X in the version switcher
docker build -t music_box -f docker/Dockerfile.docs .
id=$(docker create music_box)
docker cp $id:/build/docs/build/html tmpdocs
docker rm -v $id
version=$(sed -nr "s/^release = f'v(.+)\{suffix\}'.*$/\1/p" docs/source/conf.py)
mv tmpdocs _build/html/versions/${version}
# 2. stable, represented as vX.X (stable) in the version switcher
# edit conf.py to produce a version string that looks like vX.X (stable)
docker build -t music_box -f docker/Dockerfile.docs --build-arg SUFFIX=" (stable)" .
id=$(docker create music_box)
docker cp $id:/build/docs/build/html tmpdocs
docker rm -v $id
mv tmpdocs _build/html/versions/stable
# Delete everything under _gh-pages/ that is from the
# primary branch deployment. Excludes the other branches
# _gh-pages/branch-* paths, and not including
# _gh-pages itself.
find _gh-pages/ -mindepth 1 ! -path '_gh-pages/branch*' ! -path '_gh-pages/versions*' -delete
rsync -a _build/html/versions/stable/* _gh-pages/
mkdir -p _gh-pages/versions
rsync -a _build/html/versions/* _gh-pages/versions
# mv docs/switcher.json _gh-pages
# If a push and not on default branch, then copy the build to
# _gh-pages/branch/$brname (transforming '/' into '--')
- name: Build and copy documentation (branch)
if: |
contains(github.event_name, 'push') &&
!contains(github.ref, env.DEFAULT_BRANCH)
run: |
set -x
docker build -t music_box -f docker/Dockerfile.docs .
id=$(docker create music_box)
docker cp $id:/music-box/docs/build/html tmpdocs
docker rm -v $id
brname="${{github.ref}}"
brname="${brname##refs/heads/}"
brdir=${brname//\//--} # replace '/' with '--'
rm -rf _gh-pages/branch/${brdir}
rsync -a tmpdocs/ _gh-pages/branch/${brdir}
# Go through each branch in _gh-pages/branch/, if it's not a
# ref, then delete it.
- name: Delete old feature branches
if: ${{ github.event_name == 'push' }}
run: |
set -x
for brdir in `ls _gh-pages/branch/` ; do
brname=${brdir//--/\/} # replace '--' with '/'
if ! git show-ref remotes/origin/$brname ; then
echo "Removing $brdir"
rm -r _gh-pages/branch/$brdir/
fi
done
# Add the .nojekyll file
- name: nojekyll
if: ${{ github.event_name == 'push' }}
run: |
touch _gh-pages/.nojekyll
# Deploy
# https://github.com/peaceiris/actions-gh-pages
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.event_name == 'push' }}
with:
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _gh-pages/
force_orphan: true
24 changes: 24 additions & 0 deletions docker/Dockerfile.docs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM fedora:37

RUN dnf -y update \
&& dnf -y install \
git \
make \
python3 \
python3-pip \
&& dnf clean all

COPY . /music-box/

WORKDIR /music-box

RUN pip3 install -e .

ARG SUFFIX=""
ENV SWITCHER_SUFFIX=$SUFFIX

RUN echo "The suffix is '$SWITCHER_SUFFIX'"

RUN cd docs \
&& pip install -r requirements.txt \
&& make html
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 6 additions & 3 deletions doc/source/conf.py → docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

release = acom_music_box.__version__
project = f'Music Box ({release})'
version = acom_music_box.__version__
project = f'Music Box ({version})'
copyright = f'2024-{datetime.datetime.now().year}, NCAR/UCAR'
author = 'NCAR/UCAR'

suffix = os.getenv("SWITCHER_SUFFIX", "")
release = f'{version}{suffix}'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

Expand Down Expand Up @@ -49,4 +52,4 @@
]

html_favicon = '_static/favicon.png'
html_logo = "_static/MusicBox.svg"
html_logo = "_static/MusicBox.svg"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
musica==0.7.3
pandas
pipx
pytest
Expand Down
3 changes: 1 addition & 2 deletions src/acom_music_box/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
This is the music_box package.
This package contains modules for handling various aspects of a music box,
This package contains modules for handling various aspects of a music box,
including species, products, reactants, reactions, and more.
"""
__version__ = "2.1.5"
Expand All @@ -19,4 +19,3 @@

from .evolving_conditions import EvolvingConditions
from .music_box import MusicBox

Loading

0 comments on commit b76b26d

Please sign in to comment.