Skip to content

Commit 2a12199

Browse files
authored
Merge pull request #1019 from altheaden/transition-to-actions
Transition CI from Azure Pipelines to GitHub Actions
2 parents 682becd + 06437ad commit 2a12199

File tree

4 files changed

+189
-190
lines changed

4 files changed

+189
-190
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: CI/CD Build Workflow
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
9+
pull_request:
10+
branches:
11+
- main
12+
- develop
13+
14+
workflow_dispatch:
15+
16+
env:
17+
CANCEL_OTHERS: false
18+
PATHS_IGNORE: '["**/README.md", "**/docs/**"]'
19+
20+
jobs:
21+
build:
22+
name: test mpas_analysis - python ${{ matrix.python-version }}
23+
runs-on: ubuntu-latest
24+
timeout-minutes: 20
25+
defaults:
26+
run:
27+
shell: bash -l {0}
28+
strategy:
29+
matrix:
30+
python-version: ["3.10", "3.11", "3.12"]
31+
steps:
32+
- id: skip_check
33+
uses: fkirc/skip-duplicate-actions@master
34+
with:
35+
cancel_others: ${{ env.CANCEL_OTHERS }}
36+
paths_ignore: ${{ env.PATHS_IGNORE }}
37+
38+
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
39+
uses: actions/checkout@v4
40+
41+
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
42+
name: Cache Conda
43+
uses: actions/cache@v4
44+
env:
45+
# Increase this value to reset cache if conda-dev-spec.template has not changed in the workflow
46+
CACHE_NUMBER: 0
47+
with:
48+
path: ~/conda_pkgs_dir
49+
key:
50+
${{ runner.os }}-${{ matrix.python-version }}-conda-${{ env.CACHE_NUMBER }}-${{
51+
hashFiles('dev-spec.txt,setup.py') }}
52+
53+
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
54+
name: Set up Conda Environment
55+
uses: conda-incubator/setup-miniconda@v3
56+
with:
57+
activate-environment: "mpas_analysis_ci"
58+
miniforge-version: latest
59+
channels: conda-forge
60+
channel-priority: strict
61+
auto-update-conda: true
62+
python-version: ${{ matrix.python-version }}
63+
64+
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
65+
name: Install mpas_analysis
66+
run: |
67+
conda create -n mpas_analysis_dev --file dev-spec.txt \
68+
python=${{ matrix.python-version }}
69+
conda activate mpas_analysis_dev
70+
python -m pip install --no-deps --no-build-isolation -vv -e .
71+
72+
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
73+
name: Run Tests
74+
env:
75+
CHECK_IMAGES: False
76+
run: |
77+
set -e
78+
conda activate mpas_analysis_dev
79+
pip check
80+
pytest --pyargs mpas_analysis
81+
mpas_analysis --help
82+
download_analysis_data --help
83+
84+
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
85+
name: Build Sphinx Docs
86+
run: |
87+
conda activate mpas_analysis_dev
88+
# sphinx-multiversion expects at least a "main" branch
89+
git branch main || echo "branch main already exists."
90+
cd docs
91+
sphinx-multiversion . _build/html
92+
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: CI/CD Release Workflow
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
9+
release:
10+
types: [published]
11+
12+
jobs:
13+
publish-docs:
14+
runs-on: ubuntu-latest
15+
defaults:
16+
run:
17+
shell: bash -l {0}
18+
timeout-minutes: 20
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
persist-credentials: false
23+
fetch-depth: 0
24+
25+
- name: Cache Conda
26+
uses: actions/cache@v4
27+
env:
28+
# Increase this value to reset cache if deploy/conda-dev-spec.template has not changed in the workflow
29+
CACHE_NUMBER: 0
30+
with:
31+
path: ~/conda_pkgs_dir
32+
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
33+
hashFiles('dev-spec.txt') }}
34+
35+
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
36+
name: Set up Conda Environment
37+
uses: conda-incubator/setup-miniconda@v3
38+
with:
39+
activate-environment: "mpas_analysis_ci"
40+
miniforge-version: latest
41+
channels: conda-forge
42+
channel-priority: strict
43+
auto-update-conda: true
44+
python-version: ${{ matrix.python-version }}
45+
46+
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
47+
name: Install mpas_analysis
48+
run: |
49+
git config --global url."https://github.com/".insteadOf "[email protected]:"
50+
conda create -n mpas_analysis_dev --file dev-spec.txt \
51+
python=${{ matrix.python-version }}
52+
conda activate mpas_analysis_dev
53+
python -m pip install -vv --no-deps --no-build-isolation -e .
54+
55+
- name: Build Sphinx Docs
56+
run: |
57+
set -e
58+
conda activate mpas_analysis_dev
59+
pip check
60+
mpas_analysis sync diags --help
61+
cd docs
62+
sphinx-multiversion . _build/html
63+
- name: Copy Docs and Commit
64+
run: |
65+
set -e
66+
conda activate mpas_analysis_dev
67+
pip check
68+
mpas_analysis sync diags --help
69+
cd docs
70+
# gh-pages branch must already exist
71+
git clone https://github.com/MPAS-Dev/MPAS-Analysis.git --branch gh-pages --single-branch gh-pages
72+
# Make sure we're in the gh-pages directory.
73+
cd gh-pages
74+
# Create `.nojekyll` (if it doesn't already exist) for proper GH Pages configuration.
75+
touch .nojekyll
76+
# Add `index.html` to point to the `develop` branch automatically.
77+
printf '<meta http-equiv="refresh" content="0; url=./develop/index.html" />' > index.html
78+
# Only replace docs in a directory with the destination branch name with latest changes. Docs for
79+
# releases should be untouched.
80+
rm -rf ${{ github.head_ref || github.ref_name }}
81+
# don't clobber existing release versions (in case we retroactively fixed them)
82+
cp -r -n ../_build/html/* .
83+
# Configure git using GitHub Actions credentials.
84+
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
85+
git config --local user.name "github-actions[bot]"
86+
# The second command will fail if no changes were present, so we ignore it
87+
git add .
88+
git commit -m "Update documentation" -a || true
89+
- name: Push Changes
90+
uses: ad-m/github-push-action@master
91+
with:
92+
branch: gh-pages
93+
directory: docs/gh-pages
94+
github_token: ${{ secrets.GITHUB_TOKEN }}
95+
force: true
96+

azure-pipelines.yml

Lines changed: 0 additions & 190 deletions
This file was deleted.

dev-spec.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,5 @@ m2r2>=0.3.3
4444
mistune<2
4545
sphinx
4646
sphinx_rtd_theme
47+
sphinx-multiversion
4748
tabulate

0 commit comments

Comments
 (0)