Update installation instructions in README.md (#86) #342
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Cookiecutter CI | |
on: | |
push: | |
branches: | |
- "main" | |
pull_request: | |
branches: | |
- "main" | |
schedule: | |
# weekly tests | |
- cron: "0 0 * * 0" | |
defaults: | |
run: | |
shell: bash | |
env: | |
ARTIFACT_NAME: demo-mdakit-repos | |
OUTPUT_DIRECTORY: /home/runner/example_outputs | |
GH_USER: github-actions | |
GH_EMAIL: "[email protected]" | |
GH_REPOSITORY: "github.com/${{ github.repository }}.git" | |
jobs: | |
cookiecutter-main-tests: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macOS-latest, windows-latest] | |
# check last three versions of Python | |
last-n-minor-python-release: [2, 1, 0] | |
steps: | |
- uses: actions/checkout@v3 | |
- id: get-python-version | |
uses: MDAnalysis/get-latest-python-version@main | |
with: | |
last-n-minor-release: ${{ matrix.last-n-minor-python-release }} | |
- name: Environment information | |
run: | | |
uname -a | |
df -h | |
ulimit -a | |
echo "Using Python ${{ steps.get-python-version.outputs.python-version }}" | |
- name: Set up Python ${{ steps.get-python-version.outputs.python-version }} | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ steps.get-python-version.outputs.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install -U pytest pyyaml cookiecutter | |
- name: Run cookiecutter tests | |
run: | | |
# --keep-test-outputs also saves the generated repositories | |
if [[ ${{ matrix.os }} == "ubuntu-latest" ]] ; then | |
PYTEST_FLAGS="--keep-test-outputs $OUTPUT_DIRECTORY" | |
else | |
PYTEST_FLAGS="" | |
fi | |
echo "PYTEST_FLAGS=${PYTEST_FLAGS}" | |
pytest tests/ $PYTEST_FLAGS | |
- name: Run cookie CI | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
uses: ./.github/actions/run-cookie-ci | |
with: | |
source-directory: ${{ env.OUTPUT_DIRECTORY }}/TestMDAKit_with_condaforge-deps_and_ReadTheDocs/mdakit-cookie | |
- name: Upload artifact | |
if: ${{ matrix.os == 'ubuntu-latest' && matrix.last-n-minor-python-release == 0 }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
path: ${{ env.OUTPUT_DIRECTORY }} | |
retention-days: 3 | |
update-repo-examples: | |
if: github.event_name != 'pull_request' | |
needs: cookiecutter-main-tests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Make output directory | |
run: mkdir $OUTPUT_DIRECTORY | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
path: ${{ env.OUTPUT_DIRECTORY }} | |
- name: Push to cookie repo | |
uses: ./.github/actions/push-to-cookie | |
with: | |
source-directory: ${{ env.OUTPUT_DIRECTORY }} | |
target-ssh-deploy-key: ${{ secrets.MDAKIT_COOKIE_SSH_DEPLOY_KEY }} | |
- name: Push to remote | |
env: | |
GH_USER: github-actions | |
GH_EMAIL: "[email protected]" | |
GH_REPOSITORY: "github.com/${{ github.repository }}.git" | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# dynamic vars | |
BRANCH="${GITHUB_REF#refs/heads/}" | |
REV=$(git rev-parse --short HEAD) | |
cd $HOME | |
mkdir examples | |
cd examples | |
# set up git | |
git init | |
git config user.name $GH_USER | |
git config user.email $GH_EMAIL | |
git remote add upstream "https://${GH_USER}:${GH_TOKEN}@${GH_REPOSITORY}" | |
git fetch --depth 50 upstream $BRANCH examples | |
git reset upstream/examples | |
# update examples | |
for keep in README.md ; do | |
if [[ -e $keep ]] ; then | |
cp $keep ${{ env.OUTPUT_DIRECTORY }}/ | |
fi | |
done | |
rm -rf * | |
mv ${{ env.OUTPUT_DIRECTORY }}/* . | |
# push back to GitHub | |
git add . | |
git diff-index --quiet HEAD -- || git commit -m "rebuilt examples from branch ${BRANCH} with CI at ${REV}" | |
git push -q upstream HEAD:examples | |
build_docs: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install conda dependencies | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
environment-file: docs/requirements.yaml | |
add-pip-as-python-dependency: true | |
architecture: x64 | |
miniforge-variant: Mambaforge | |
use-mamba: true | |
channels: conda-forge, defaults | |
activate-environment: cookiecutter-mdakit-docs | |
auto-update-conda: true | |
show-channel-urls: true | |
- name: Build docs | |
shell: bash -l {0} | |
working-directory: docs | |
run: make html | |
- name: Deploy docs | |
if: github.event_name != 'pull_request' | |
working-directory: docs/_build/html | |
run: | | |
BRANCH="${GITHUB_REF#refs/heads/}" | |
REV=$(git rev-parse --short HEAD) | |
git init | |
git config user.name $GH_USER | |
git config user.email $GH_EMAIL | |
git remote add upstream "https://${GH_USER}:${{ secrets.GITHUB_TOKEN }}@${GH_REPOSITORY}" | |
git fetch --depth 50 upstream $BRANCH gh-pages | |
git reset upstream/gh-pages | |
touch . | |
touch .nojekyll | |
git add . | |
git diff-index --quiet HEAD -- || git commit -m "rebuilt html docs from branch ${BRANCH} with sphinx at ${REV}" | |
git push -q upstream HEAD:gh-pages |