Skip to content

Commit

Permalink
Add caching to workflow. (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewHambley authored Jun 20, 2024
1 parent 04a65a7 commit 647e7da
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 68 deletions.
81 changes: 44 additions & 37 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,53 @@ on: [push, pull_request]
jobs:
build:

runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
max-parallel: 4
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Setup Compiler
run: |
sudo apt-get -y install gcc gfortran
- name: Setup LibClang
run: |
sudo apt-get -y install libclang-dev python-clang
SP=~/.local/lib/python${{ matrix.python-version }}/site-packages
mkdir -p $SP
cp -vr /usr/lib/python3/dist-packages/clang $SP/
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
- name: Type check with mypy
run: |
pip install -e .[dev]
pip install pytest
python -m mypy source tests
- name: Code style check with flake8
run: |
pip install -e .[dev]
flake8 . --count --show-source --statistics
- name: Unit tests with Pytest
run: |
pip install .[tests]
python -m pytest --cov=fab tests/unit_tests
- name: System tests with Pytest
run: |
pip install .[tests]
python -m pytest --cov=fab tests/system_tests
# Should this step use a cache?
#
- name: Setup Compiler
run: |
sudo apt-get -y install llvm clang libclang-dev gcc gfortran
- uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip

# The clang binding version has to match the version in the Ubuntu being used.
- name: Install Python libraries
run: |
python -m pip install --upgrade pip
pip install -e .
pip install clang==14.0
- name: Type check with mypy
run: |
pip install -e .[dev]
pip install pytest
python -m mypy source tests
- name: Code style check with flake8
run: |
pip install -e .[dev]
flake8 . --count --show-source --statistics
- name: Unit tests with Pytest
run: |
pip install .[tests]
python -m pytest --cov=fab tests/unit_tests
- name: System tests with Pytest
run: |
pip install .[tests]
python -m pytest --cov=fab tests/system_tests
73 changes: 43 additions & 30 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,48 @@ on: workflow_dispatch
jobs:
build-docs:

runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- name: set git user
run: |
git config --global user.email "metomi@metoffice.gov.uk"
git config --global user.name "SciFab Developers"
- uses: actions/checkout@v3
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: install fab
run: pip install .[docs]
- name: build docs
run: |
cd docs
rm -rf build
sphinx-apidoc --separate --module-first -d 5 -f -o source/apidoc ../source/fab
make html
- name: move built docs to docs root
run: |
mv docs/build/html/* docs/
- name: git add built docs
run: |
git add docs/*
- name: commit
run: |
git commit -m "docs build"
- name: push to gh_pages branch
run: |
echo "pushing from $GITHUB_REF_NAME to gh_pages"
git push --force origin $GITHUB_REF_NAME:gh_pages
- name: set git user
run: |
git config --global user.email "metomi@metoffice.gov.uk"
git config --global user.name "SciFab Developers"
- name: Checkout Fab project files
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: pip

- name: Install Python libraries
run: |
python -m pip install --upgrade pip
pip install -e .[docs]
- name: build docs
run: |
cd docs
rm -rf build
sphinx-apidoc --separate --module-first -d 5 -f -o source/apidoc ../source/fab
make html
- name: move built docs to docs root
run: |
mv docs/build/html/* docs/
- name: git add built docs
run: |
git add docs/*
- name: commit
run: |
git commit -m "docs build"
- name: push to gh_pages branch
run: |
echo "pushing from $GITHUB_REF_NAME to gh_pages"
git push --force origin $GITHUB_REF_NAME:gh_pages
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ classifiers = [
]

[project.optional-dependencies]
c-language = ['python-clang']
c-language = ['clang']
plots = ['matplotlib']
tests = ['pytest', 'pytest-cov', 'pytest-mock']
checks = ['flake8>=5.0.4', 'mypy']
Expand Down

0 comments on commit 647e7da

Please sign in to comment.