Skip to content

add option to show reference #13

add option to show reference

add option to show reference #13

name: CI/CD Build Workflow
on:
push:
branches: [main]
pull_request:
branches: [main]
types: [review_requested, ready_for_review]
workflow_dispatch:
env:
CANCEL_OTHERS: true
PATHS_IGNORE: '["**/README.rst", "**/docs/**", "**/ISSUE_TEMPLATE/**", "**/pull_request_template.md", "**/.vscode/**"]'
jobs:
check-jobs-to-skip:
if: ${{ github.event.pull_request.draft != true }}
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
cancel_others: true
paths_ignore: '["**/README.md", "**/docs/**", "**/ISSUE_TEMPLATE/**", "**/pull_request_template.md", "**/.vscode/**"]'
pre-commit-hooks:
needs: check-jobs-to-skip
if: ${{ (needs.check-jobs-to-skip.outputs.should_skip != 'true' || github.event_name == 'push') && github.event.pull_request.draft != true }}
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout Code Repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install and Run Pre-commit
uses: pre-commit/[email protected]
build:
needs: check-jobs-to-skip
if: ${{ (needs.check-jobs-to-skip.outputs.should_skip != 'true' || github.event_name == 'push') && github.event.pull_request.draft != true }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- name: Set up Conda Environment
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: "ESMBenchmarkViz_ci"
miniforge-variant: Mambaforge
miniforge-version: latest
environment-file: conda-env/environment.yml
use-mamba: true
mamba-version: "*"
channel-priority: strict
auto-update-conda: true
# Used for refreshing the cache every 24 hours to avoid inconsistencies of package
# versions between the CI pipeline and local installations.
- name: Get Date
id: get-date
run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
shell: bash
- name: Cache Conda
uses: actions/cache@v3
with:
path: ${{ env.CONDA }}/envs
key:
conda-${{ runner.os }}--${{ runner.arch }}--${{
steps.get-date.outputs.today }}-${{
hashFiles('conda-env/environment.yml') }}-${{ env.CACHE_NUMBER}}
env:
# Increase this value to reset cache if conda/environment.yml has not changed in the workflow
CACHE_NUMBER: 0
- name: Install ESMBenchmarkViz
# Source: https://github.com/conda/conda-build/issues/4251#issuecomment-1053460542
run: |
python -m pip install --no-build-isolation --no-deps -e .
- name: Run Tests
run: |
pytest
- name: Run Unit Tests
run: pytest tests
publish-docs:
if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request') && github.event.pull_request.draft != true }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- name: Cache Conda
uses: actions/cache@v3
env:
# Increase this value to reset cache if conda-env/environment.yml has not changed in the workflow
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
hashFiles('conda-env/environment.yml') }}
- name: Set up Conda Environment
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: "ESMBenchmarkViz_dev"
miniforge-variant: Miniforge3
miniforge-version: latest
environment-file: conda-env/environment.yml
channel-priority: strict
auto-update-conda: true
- name: Install ESMBenchmarkViz
# Source: https://github.com/conda/conda-build/issues/4251#issuecomment-1053460542
run: |
python -m pip install --no-build-isolation --no-deps -e .
- name: Sphinx build
run: |
sphinx-build docs _build
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
with:
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _build/
force_orphan: true