Skip to content

Commit

Permalink
DEV: Simplify Workflows (#112)
Browse files Browse the repository at this point in the history
* DEV: move iq-tree building into composite action

* DEV: correctly specify composite action

* DEV: specify shell to use

* DEV: merge python setup and libiqtree fetching into composite action

* DEV: ensure dependabot updates composite actions
  • Loading branch information
rmcar17 authored Nov 28, 2024
1 parent 2ccfc74 commit 6acff9f
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 73 deletions.
37 changes: 37 additions & 0 deletions .github/actions/build-iqtree/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Fetch or Build IQ-TREE 2 Static Library
description: "Checks if the IQ-TREE 2 static library exists, if not then building it."
inputs:
os:
description: "Runner OS Name."
required: true
outputs:
iqtree2-sha:
description: "SHA for commit of IQ-TREE 2 static library."
value: ${{ steps.iqtree2-sha.outputs.iqtree2-sha }}
runs:
using: "composite"
steps:
- id: iqtree2-sha
name: Get IQ-TREE 2 SHA
shell: bash
run: |
cd iqtree2
IQ_TREE_2_SHA=$(git rev-parse HEAD)
echo "iqtree2-sha=${IQ_TREE_2_SHA}" >> "$GITHUB_OUTPUT"
- uses: actions/cache@v4
id: cache
with:
key: libiqtree-${{ inputs.os }}-${{ steps.iqtree2-sha.outputs.iqtree2-sha }}
path: src/piqtree2/_libiqtree/libiqtree2.a
lookup-only: true

- name: Build IQ-TREE
shell: bash
if: steps.cache.outputs.cache-hit != 'true'
run: |
if [[ "${{ inputs.os }}" == "ubuntu-latest" ]]; then
sudo ./build_tools/before_all_linux.sh
else
./build_tools/before_all_mac.sh
fi
21 changes: 21 additions & 0 deletions .github/actions/setup-piqtree/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Setup piqtree
description: "Setup Python and Fetch Static Library."
inputs:
python-version:
description: "Python version."
required: true
cache-key:
description: "Key for static library cache."
required: true
runs:
using: "composite"
steps:
- uses: "actions/setup-python@v5"
with:
python-version: ${{ inputs.python-version }}

- uses: actions/cache/restore@v4
with:
key: ${{ inputs.cache-key }}
path: src/piqtree2/_libiqtree/libiqtree2.a
fail-on-cache-miss: true
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ updates:
schedule:
interval: "weekly"
open-pull-requests-limit: 10
- package-ecosystem: "github-actions"
directory: "/.github/actions/build-iqtree/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
- package-ecosystem: "github-actions"
directory: "/.github/actions/setup-piqtree/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10

- package-ecosystem: "gitsubmodule"
directory: "/"
Expand Down
34 changes: 9 additions & 25 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build docs
name: Build Docs

on: [workflow_dispatch]

Expand All @@ -12,23 +12,13 @@ jobs:
fetch-depth: 0
submodules: recursive

- name: Get IQ-TREE 2 SHA
run: |
cd iqtree2
IQ_TREE_2_SHA=$(git rev-parse HEAD)
echo "IQ_TREE_2_SHA=${IQ_TREE_2_SHA}" >> $GITHUB_ENV
- uses: actions/cache@v4
id: cache
- id: build
uses: ./.github/actions/build-iqtree
with:
key: libiqtree-${{ matrix.os }}-${{ env.IQ_TREE_2_SHA }}
path: src/piqtree2/_libiqtree/libiqtree2.a
lookup-only: true

- name: Build IQ-TREE
if: steps.cache.outputs.cache-hit != 'true'
run: |
sudo ./build_tools/before_all_linux.sh
os: ubuntu-latest

outputs:
iqtree2-sha: ${{steps.build.outputs.iqtree2-sha}}

build-docs:
runs-on: ubuntu-latest
Expand All @@ -40,16 +30,10 @@ jobs:
fetch-depth: 0
submodules: recursive

- uses: actions/cache/restore@v4
with:
key: libiqtree-ubuntu-latest-${{ env.IQ_TREE_2_SHA }}
path: src/piqtree2/_libiqtree/libiqtree2.a
fail-on-cache-miss: true

- name: Set up Python
uses: actions/setup-python@v5
- uses: ./.github/actions/setup-piqtree
with:
python-version: "3.12"
cache-key: libiqtree-ubuntu-latest-${{ needs.build-iqtree.outputs.iqtree2-sha }}

- name: Install Docs Dependencies
run: |
Expand Down
67 changes: 19 additions & 48 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,13 @@ jobs:
fetch-depth: 0
submodules: recursive

- name: Get IQ-TREE 2 SHA
run: |
cd iqtree2
IQ_TREE_2_SHA=$(git rev-parse HEAD)
echo "IQ_TREE_2_SHA=${IQ_TREE_2_SHA}" >> $GITHUB_ENV
- uses: actions/cache@v4
id: cache
- id: build
uses: ./.github/actions/build-iqtree
with:
key: libiqtree-${{ matrix.os }}-${{ env.IQ_TREE_2_SHA }}
path: src/piqtree2/_libiqtree/libiqtree2.a
lookup-only: true

- name: Build IQ-TREE
if: steps.cache.outputs.cache-hit != 'true'
run: |
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
sudo ./build_tools/before_all_linux.sh
else
./build_tools/before_all_mac.sh
fi
os: ${{ matrix.os }}

outputs:
iqtree2-sha: ${{steps.build.outputs.iqtree2-sha}}

tests:
name: Run Tests with Python ${{matrix.python-version}} on ${{matrix.os}}
Expand All @@ -57,15 +43,10 @@ jobs:
fetch-depth: 0
submodules: recursive

- uses: "actions/setup-python@v5"
with:
python-version: "${{ matrix.python-version }}"

- uses: actions/cache/restore@v4
- uses: ./.github/actions/setup-piqtree
with:
key: libiqtree-${{ matrix.os }}-${{ env.IQ_TREE_2_SHA }}
path: src/piqtree2/_libiqtree/libiqtree2.a
fail-on-cache-miss: true
python-version: ${{ matrix.python-version }}
cache-key: libiqtree-${{ matrix.os }}-${{ needs.build-iqtree.outputs.iqtree2-sha }}

- name: Run Nox Testing
run: |
Expand Down Expand Up @@ -107,20 +88,15 @@ jobs:
with:
fetch-depth: 0

- uses: "actions/setup-python@v5"
- uses: ./.github/actions/setup-piqtree
with:
python-version: "${{ matrix.python-version }}"

- uses: actions/cache/restore@v4
with:
key: libiqtree-${{ matrix.os }}-${{ env.IQ_TREE_2_SHA }}
path: src/piqtree2/_libiqtree/libiqtree2.a
fail-on-cache-miss: true
python-version: ${{ matrix.python-version }}
cache-key: libiqtree-${{ matrix.os }}-${{ needs.build-iqtree.outputs.iqtree2-sha }}

- name: "Run Type Checking for ${{ matrix.python-version }}"
run: |
pip install nox
nox -s type_check-${{ matrix.python-version }}
pip install nox
nox -s type_check-${{ matrix.python-version }}
lint:
name: "Linting"
Expand All @@ -137,17 +113,12 @@ jobs:
with:
fetch-depth: 0

- uses: "actions/setup-python@v5"
- uses: ./.github/actions/setup-piqtree
with:
python-version: "${{ matrix.python-version }}"

- uses: actions/cache/restore@v4
with:
key: libiqtree-${{ matrix.os }}-${{ env.IQ_TREE_2_SHA }}
path: src/piqtree2/_libiqtree/libiqtree2.a
fail-on-cache-miss: true
python-version: ${{ matrix.python-version }}
cache-key: libiqtree-${{ matrix.os }}-${{ needs.build-iqtree.outputs.iqtree2-sha }}

- name: "Run Type Checking for ${{ matrix.python-version }}"
run: |
pip install nox
nox -s ruff-${{ matrix.python-version }}
pip install nox
nox -s ruff-${{ matrix.python-version }}

0 comments on commit 6acff9f

Please sign in to comment.