Skip to content

Commit

Permalink
Merge branch 'dev/setup-jatic-cicd' into 'main'
Browse files Browse the repository at this point in the history
CI/CD Updates

See merge request jatic/kitware/xaitk-saliency!1
  • Loading branch information
Brandon RichardWebster committed Nov 21, 2024
2 parents 0a565ba + 6c32eeb commit e745997
Show file tree
Hide file tree
Showing 140 changed files with 3,526 additions and 4,163 deletions.
9 changes: 0 additions & 9 deletions .flake8

This file was deleted.

12 changes: 12 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
# :auto shared:
*.rst conflict-marker-size=79
**.pt filter=lfs diff=lfs merge=lfs -text
**.pth filter=lfs diff=lfs merge=lfs -text
**.pkl filter=lfs diff=lfs merge=lfs -text
**.png filter=lfs diff=lfs merge=lfs -text
**.jpg filter=lfs diff=lfs merge=lfs -text
**.jpeg filter=lfs diff=lfs merge=lfs -text
**.tiff filter=lfs diff=lfs merge=lfs -text
**.bin filter=lfs diff=lfs merge=lfs -text
**.tiff filter=lfs diff=lfs merge=lfs -text
**.npy filter=lfs diff=lfs merge=lfs -text
# :auto shared:
32 changes: 32 additions & 0 deletions .github/actions/build-stage/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: "build-stage"
description: "Setup user python environment with poetry and enable caching."
runs:
using: "composite"
steps:
- name: Environment Variables
run: |
export PIP_CACHE_DIR="$GITHUB_WORKSPACE/.cache/pip"
export POETRY_CACHE_DIR="$GITHUB_WORKSPACE/.cache/poetry"
echo "${HOME}/.local/bin" >> $GITHUB_PATH
shell: bash
- name: Setup Poetry
run: |
pip install --root-user-action=ignore --upgrade pip -q
pip install --root-user-action=ignore --user -U poetry -q
shell: bash
- name: Configure Poetry
run: |
poetry config --local virtualenvs.in-project true
poetry config --local virtualenvs.prefer-active-python true
shell: bash
- name: Versions of things used here
run: |
python --version
poetry -q run python --version
pip --version
poetry --version
poetry check
shell: bash
- name: Install Environment
run: poetry install --sync --only main,linting,tests,docs
shell: bash
10 changes: 10 additions & 0 deletions .github/actions/quality-stage/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: "quality-stage"
description: "Setup user python environment with poetry and enable caching."
runs:
using: "composite"
steps:
- name: Setup Environment
uses: ./.github/actions/build-stage
- name: Synchronize Poetry Environment
run: poetry install --sync --only main,linting,tests
shell: bash
17 changes: 17 additions & 0 deletions .github/actions/test-stage/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "test-stage"
description: "Setup user python environment with poetry and enable caching."

inputs:
extras:
description: "Parameterize the 'extras' required for testing"
required: true
default: ""

runs:
using: "composite"
steps:
- name: Setup Environment
uses: ./.github/actions/build-stage
- name: Synchronize Poetry Environment
run: poetry install --sync --only main,linting,tests --extras "${{ inputs.extras }}"
shell: bash
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,30 @@ jobs:
# This should only be run for tags on the "official" repository org.
if: github.repository_owner == 'XAITK'
steps:
- name: Install Git LFS
run: |
apt-get -qq update
apt-get -qq install -y git-lfs
shell: bash
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
# Cache local python environment artifacts for the current python version
# and poetry lockfile hash.
- uses: actions/cache@v3
- uses: actions/cache@v4
id: env-cache
with:
# Confirmed that the `.local` directory doesn't exist until the
# `pip install --user` is invoked below, so we can be confident that
# only our python stuff is being captured in this cache (intentional).
path: |
~/.cache/pypoetry/virtualenvs/
~/.local
~/.cache
key: python-3.9-${{ hashFiles('poetry.lock') }}

- name: Setup Environment
# Using non-relative path for correct behavior when used as a remote
# workflow.
uses: Kitware/SMQTK-Core/.github/actions/python-poetry-setup@master
uses: ./.github/actions/build-stage

# Ensure there is alignment with the tag reference and the reported
# version of the package
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is a basic workflow to help you get started with Actions

name: CI Unittests
name: Quality Assurance

# Controls when the action will run.
on:
Expand All @@ -26,14 +26,20 @@ defaults:
# NOTE: Github actions does not support anchors apparently. Forgive duplication of job
# steps.
jobs:
lint:
mypy:
runs-on: ubuntu-latest
container: python:3.9
steps:
- name: Install Git LFS
run: |
apt-get -qq update
apt-get -qq install -y git-lfs
shell: bash
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
# Cache local python environment artifacts for the current python version
# and poetry lockfile hash.
- uses: actions/cache@v4
Expand All @@ -42,24 +48,28 @@ jobs:
# Confirmed that the `.local` directory doesn't exist until the
# `pip install --user` is invoked below, so we can be confident that
# only our python stuff is being captured in this cache (intentional).
path: |
~/.cache/pypoetry/virtualenvs/
~/.local
path: ~/.cache
key: python-3.9-${{ hashFiles('poetry.lock') }}
- name: Setup Environment
# See: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-using-a-public-action-in-a-subdirectory
uses: Kitware/SMQTK-Core/.github/actions/python-poetry-setup@master
- name: Lint with Flake8
run: poetry run flake8
uses: ./.github/actions/quality-stage
- name: Typecheck with MyPy
run: poetry run mypy --config-file pyproject.toml src/ tests/
shell: bash

typecheck:
ruff-lint:
runs-on: ubuntu-latest
container: python:3.9
steps:
- name: Install Git LFS
run: |
apt-get -qq update
apt-get -qq install -y git-lfs
shell: bash
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
# Cache local python environment artifacts for the current python version
# and poetry lockfile hash.
- uses: actions/cache@v4
Expand All @@ -68,37 +78,28 @@ jobs:
# Confirmed that the `.local` directory doesn't exist until the
# `pip install --user` is invoked below, so we can be confident that
# only our python stuff is being captured in this cache (intentional).
path: |
~/.cache/pypoetry/virtualenvs/
~/.local
path: ~/.cache
key: python-3.9-${{ hashFiles('poetry.lock') }}
- name: Setup Environment
# See: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-using-a-public-action-in-a-subdirectory
uses: Kitware/SMQTK-Core/.github/actions/python-poetry-setup@master
- name: Typecheck with MyPy
run: poetry run mypy
uses: ./.github/actions/quality-stage
- name: Lint with Ruff
run: poetry run ruff check --config pyproject.toml
shell: bash

unittests:
ruff-format:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9","3.10","3.11","3.12"]
# Extras for included, optional plugin support (space-separated lists)
opt-extra: [
"", # no extras
"tools",
]
# We want all python versions tested even if one of them happens to fail
fail-fast: false

container: python:${{ matrix.python-version }}

# Steps represent a sequence of tasks that will be executed as part of the job
container: python:3.9
steps:
- name: Install Git LFS
run: |
apt-get -qq update
apt-get -qq install -y git-lfs
shell: bash
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
# Cache local python environment artifacts for the current python version
# and poetry lockfile hash.
- uses: actions/cache@v4
Expand All @@ -107,30 +108,40 @@ jobs:
# Confirmed that the `.local` directory doesn't exist until the
# `pip install --user` is invoked below, so we can be confident that
# only our python stuff is being captured in this cache (intentional).
path: |
~/.cache/pypoetry/virtualenvs/
~/.local
key: python-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}-${{ matrix.opt-extra }}
restore-keys: |
python-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
path: ~/.cache
key: python-3.9-${{ hashFiles('poetry.lock') }}
- name: Setup Environment
# See: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-using-a-public-action-in-a-subdirectory
uses: Kitware/SMQTK-Core/.github/actions/python-poetry-setup@master
- name: Optionally install additional requirements
env:
OPT_EXTRA: ${{ matrix.opt-extra }}
run: |
if [[ -n "$OPT_EXTRA" ]]
then
poetry install --extras "$OPT_EXTRA"
fi
- name: Run Unittests
run: poetry run pytest
uses: ./.github/actions/quality-stage
- name: Format check with Ruff
run: poetry run ruff format --config pyproject.toml --check
shell: bash

- name: CodeCov report submission
uses: codecov/codecov-action@v4
sphinx-lint:
runs-on: ubuntu-latest
container: python:3.9
steps:
- name: Install Git LFS
run: |
apt-get -qq update
apt-get -qq install -y git-lfs
shell: bash
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
files: coverage.xml
flags: unittests
fetch-depth: 0
lfs: true
# Cache local python environment artifacts for the current python version
# and poetry lockfile hash.
- uses: actions/cache@v4
id: env-cache
with:
# Confirmed that the `.local` directory doesn't exist until the
# `pip install --user` is invoked below, so we can be confident that
# only our python stuff is being captured in this cache (intentional).
path: ~/.cache
key: python-3.9-${{ hashFiles('poetry.lock') }}
- name: Setup Environment
uses: ./.github/actions/quality-stage
- name: Lint docs with Spinx-lint
run: poetry run sphinx-lint --enable all --disable leaked-markup --max-line-length 120 -i docs/_implementations docs
shell: bash
Loading

0 comments on commit e745997

Please sign in to comment.