diff --git a/.github/actions/build-iqtree/action.yml b/.github/actions/build-iqtree/action.yml new file mode 100644 index 0000000..022badc --- /dev/null +++ b/.github/actions/build-iqtree/action.yml @@ -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 diff --git a/.github/actions/setup-piqtree/action.yml b/.github/actions/setup-piqtree/action.yml new file mode 100644 index 0000000..9a23a94 --- /dev/null +++ b/.github/actions/setup-piqtree/action.yml @@ -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 \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml index a5b9f93..78a34af 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -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: "/" diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index 11c2f53..d4c0ec3 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -1,4 +1,4 @@ -name: Build docs +name: Build Docs on: [workflow_dispatch] @@ -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 @@ -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: | diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 603aa41..3eef2b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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}} @@ -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: | @@ -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" @@ -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 }}