Skip to content

Commit bc5410f

Browse files
committed
DEV: Simplify Workflows (iqtree#112)
* 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
1 parent 5693605 commit bc5410f

File tree

5 files changed

+96
-73
lines changed

5 files changed

+96
-73
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Fetch or Build IQ-TREE 2 Static Library
2+
description: "Checks if the IQ-TREE 2 static library exists, if not then building it."
3+
inputs:
4+
os:
5+
description: "Runner OS Name."
6+
required: true
7+
outputs:
8+
iqtree2-sha:
9+
description: "SHA for commit of IQ-TREE 2 static library."
10+
value: ${{ steps.iqtree2-sha.outputs.iqtree2-sha }}
11+
runs:
12+
using: "composite"
13+
steps:
14+
- id: iqtree2-sha
15+
name: Get IQ-TREE 2 SHA
16+
shell: bash
17+
run: |
18+
cd iqtree2
19+
IQ_TREE_2_SHA=$(git rev-parse HEAD)
20+
echo "iqtree2-sha=${IQ_TREE_2_SHA}" >> "$GITHUB_OUTPUT"
21+
22+
- uses: actions/cache@v4
23+
id: cache
24+
with:
25+
key: libiqtree-${{ inputs.os }}-${{ steps.iqtree2-sha.outputs.iqtree2-sha }}
26+
path: src/piqtree2/_libiqtree/libiqtree2.a
27+
lookup-only: true
28+
29+
- name: Build IQ-TREE
30+
shell: bash
31+
if: steps.cache.outputs.cache-hit != 'true'
32+
run: |
33+
if [[ "${{ inputs.os }}" == "ubuntu-latest" ]]; then
34+
sudo ./build_tools/before_all_linux.sh
35+
else
36+
./build_tools/before_all_mac.sh
37+
fi
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Setup piqtree
2+
description: "Setup Python and Fetch Static Library."
3+
inputs:
4+
python-version:
5+
description: "Python version."
6+
required: true
7+
cache-key:
8+
description: "Key for static library cache."
9+
required: true
10+
runs:
11+
using: "composite"
12+
steps:
13+
- uses: "actions/setup-python@v5"
14+
with:
15+
python-version: ${{ inputs.python-version }}
16+
17+
- uses: actions/cache/restore@v4
18+
with:
19+
key: ${{ inputs.cache-key }}
20+
path: src/piqtree2/_libiqtree/libiqtree2.a
21+
fail-on-cache-miss: true

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ updates:
1616
schedule:
1717
interval: "weekly"
1818
open-pull-requests-limit: 10
19+
- package-ecosystem: "github-actions"
20+
directory: "/.github/actions/build-iqtree/"
21+
schedule:
22+
interval: "weekly"
23+
open-pull-requests-limit: 10
24+
- package-ecosystem: "github-actions"
25+
directory: "/.github/actions/setup-piqtree/"
26+
schedule:
27+
interval: "weekly"
28+
open-pull-requests-limit: 10
1929

2030
- package-ecosystem: "gitsubmodule"
2131
directory: "/"

.github/workflows/build_docs.yml

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build docs
1+
name: Build Docs
22

33
on: [workflow_dispatch]
44

@@ -12,23 +12,13 @@ jobs:
1212
fetch-depth: 0
1313
submodules: recursive
1414

15-
- name: Get IQ-TREE 2 SHA
16-
run: |
17-
cd iqtree2
18-
IQ_TREE_2_SHA=$(git rev-parse HEAD)
19-
echo "IQ_TREE_2_SHA=${IQ_TREE_2_SHA}" >> $GITHUB_ENV
20-
21-
- uses: actions/cache@v4
22-
id: cache
15+
- id: build
16+
uses: ./.github/actions/build-iqtree
2317
with:
24-
key: libiqtree-${{ matrix.os }}-${{ env.IQ_TREE_2_SHA }}
25-
path: src/piqtree2/_libiqtree/libiqtree2.a
26-
lookup-only: true
27-
28-
- name: Build IQ-TREE
29-
if: steps.cache.outputs.cache-hit != 'true'
30-
run: |
31-
sudo ./build_tools/before_all_linux.sh
18+
os: ubuntu-latest
19+
20+
outputs:
21+
iqtree2-sha: ${{steps.build.outputs.iqtree2-sha}}
3222

3323
build-docs:
3424
runs-on: ubuntu-latest
@@ -40,16 +30,10 @@ jobs:
4030
fetch-depth: 0
4131
submodules: recursive
4232

43-
- uses: actions/cache/restore@v4
44-
with:
45-
key: libiqtree-ubuntu-latest-${{ env.IQ_TREE_2_SHA }}
46-
path: src/piqtree2/_libiqtree/libiqtree2.a
47-
fail-on-cache-miss: true
48-
49-
- name: Set up Python
50-
uses: actions/setup-python@v5
33+
- uses: ./.github/actions/setup-piqtree
5134
with:
5235
python-version: "3.12"
36+
cache-key: libiqtree-ubuntu-latest-${{ needs.build-iqtree.outputs.iqtree2-sha }}
5337

5438
- name: Install Docs Dependencies
5539
run: |

.github/workflows/ci.yml

Lines changed: 19 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,13 @@ jobs:
2121
fetch-depth: 0
2222
submodules: recursive
2323

24-
- name: Get IQ-TREE 2 SHA
25-
run: |
26-
cd iqtree2
27-
IQ_TREE_2_SHA=$(git rev-parse HEAD)
28-
echo "IQ_TREE_2_SHA=${IQ_TREE_2_SHA}" >> $GITHUB_ENV
29-
30-
- uses: actions/cache@v4
31-
id: cache
24+
- id: build
25+
uses: ./.github/actions/build-iqtree
3226
with:
33-
key: libiqtree-${{ matrix.os }}-${{ env.IQ_TREE_2_SHA }}
34-
path: src/piqtree2/_libiqtree/libiqtree2.a
35-
lookup-only: true
36-
37-
- name: Build IQ-TREE
38-
if: steps.cache.outputs.cache-hit != 'true'
39-
run: |
40-
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
41-
sudo ./build_tools/before_all_linux.sh
42-
else
43-
./build_tools/before_all_mac.sh
44-
fi
27+
os: ${{ matrix.os }}
28+
29+
outputs:
30+
iqtree2-sha: ${{steps.build.outputs.iqtree2-sha}}
4531

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

60-
- uses: "actions/setup-python@v5"
61-
with:
62-
python-version: "${{ matrix.python-version }}"
63-
64-
- uses: actions/cache/restore@v4
46+
- uses: ./.github/actions/setup-piqtree
6547
with:
66-
key: libiqtree-${{ matrix.os }}-${{ env.IQ_TREE_2_SHA }}
67-
path: src/piqtree2/_libiqtree/libiqtree2.a
68-
fail-on-cache-miss: true
48+
python-version: ${{ matrix.python-version }}
49+
cache-key: libiqtree-${{ matrix.os }}-${{ needs.build-iqtree.outputs.iqtree2-sha }}
6950

7051
- name: Run Nox Testing
7152
run: |
@@ -107,20 +88,15 @@ jobs:
10788
with:
10889
fetch-depth: 0
10990

110-
- uses: "actions/setup-python@v5"
91+
- uses: ./.github/actions/setup-piqtree
11192
with:
112-
python-version: "${{ matrix.python-version }}"
113-
114-
- uses: actions/cache/restore@v4
115-
with:
116-
key: libiqtree-${{ matrix.os }}-${{ env.IQ_TREE_2_SHA }}
117-
path: src/piqtree2/_libiqtree/libiqtree2.a
118-
fail-on-cache-miss: true
93+
python-version: ${{ matrix.python-version }}
94+
cache-key: libiqtree-${{ matrix.os }}-${{ needs.build-iqtree.outputs.iqtree2-sha }}
11995

12096
- name: "Run Type Checking for ${{ matrix.python-version }}"
12197
run: |
122-
pip install nox
123-
nox -s type_check-${{ matrix.python-version }}
98+
pip install nox
99+
nox -s type_check-${{ matrix.python-version }}
124100
125101
lint:
126102
name: "Linting"
@@ -137,17 +113,12 @@ jobs:
137113
with:
138114
fetch-depth: 0
139115

140-
- uses: "actions/setup-python@v5"
116+
- uses: ./.github/actions/setup-piqtree
141117
with:
142-
python-version: "${{ matrix.python-version }}"
143-
144-
- uses: actions/cache/restore@v4
145-
with:
146-
key: libiqtree-${{ matrix.os }}-${{ env.IQ_TREE_2_SHA }}
147-
path: src/piqtree2/_libiqtree/libiqtree2.a
148-
fail-on-cache-miss: true
118+
python-version: ${{ matrix.python-version }}
119+
cache-key: libiqtree-${{ matrix.os }}-${{ needs.build-iqtree.outputs.iqtree2-sha }}
149120

150121
- name: "Run Type Checking for ${{ matrix.python-version }}"
151122
run: |
152-
pip install nox
153-
nox -s ruff-${{ matrix.python-version }}
123+
pip install nox
124+
nox -s ruff-${{ matrix.python-version }}

0 commit comments

Comments
 (0)