Merge pull request #129 from globus/document-dependency-management #125
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "CI" | |
on: | |
pull_request: | |
push: | |
branches: | |
- "main" | |
- "production" | |
env: | |
PRE_COMMIT_HOME: ".tox/pre-commit-home" | |
jobs: | |
lint: | |
name: "Lint" | |
runs-on: "ubuntu-latest" | |
steps: | |
- name: "Checkout the repo" | |
uses: "actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11" # v4.1.1 | |
- name: "Setup Python" | |
id: "setup-python" | |
uses: "actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c" # v5.0.0 | |
with: | |
python-version: "3.12" | |
- name: "Detect Pythons" | |
uses: "kurtmckee/detect-pythons@38187a5464f266e93e5c1467699f7be2bf521d2e" # v1.1.0 | |
- name: "Restore the cache" | |
id: "restore-cache" | |
uses: "actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319" # v4.0.1 | |
with: | |
path: | | |
.mypy_cache/ | |
.tox/ | |
.venv/ | |
key: "lint-hash=${{ hashFiles('.github/workflows/ci.yaml', '.python-identifiers', 'pyproject.toml', 'tox.ini', 'requirements/*/*.txt') }}" | |
- name: "Create virtual environment" | |
if: "steps.restore-cache.outputs.cache-hit == false" | |
run: | | |
python -m venv .venv | |
.venv/bin/pip install --upgrade pip setuptools wheel | |
.venv/bin/pip install tox | |
- name: "Lint type annotations" | |
run: | | |
.venv/bin/tox -e mypy | |
- name: "Lint documentation" | |
run: | | |
.venv/bin/tox -e docs | |
build: | |
name: "Build a shared wheel" | |
runs-on: "ubuntu-latest" | |
outputs: | |
wheel-filename: "${{ steps.build-wheel.outputs.wheel-filename }}" | |
steps: | |
- name: "Checkout the repo" | |
uses: "actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11" # v4.1.1 | |
- name: "Identify the week number" | |
run: | | |
date +'%U' > week-number.txt | |
date +'week-number=%U' >> "$GITHUB_ENV" | |
- name: "Setup Python" | |
id: "setup-python" | |
uses: "actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c" # v5.0.0 | |
with: | |
python-version: "3.11" | |
cache: "pip" | |
cache-dependency-path: | | |
.github/workflows/ci.yaml | |
pyproject.toml | |
tox.ini | |
week-number.txt | |
- name: "Build the wheel" | |
id: "build-wheel" | |
run: | | |
pip wheel . | |
echo "wheel-filename=$(find globus_action_provider_tools-*.whl | head -n 1)" >> "$GITHUB_OUTPUT" | |
- name: "Upload the artifact" | |
uses: "actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3" # v4.3.1 | |
with: | |
name: "globus_action_provider_tools-${{ github.sha }}.whl" | |
path: "${{ steps.build-wheel.outputs.wheel-filename }}" | |
retention-days: 1 | |
test: | |
name: "Test ${{ matrix.python-version }}${{ matrix.tox-extras }} on ${{ matrix.os.name }}" | |
needs: ["build"] | |
runs-on: "${{ matrix.os.value }}" | |
strategy: | |
matrix: | |
# Broadly test supported Python versions on Linux. | |
os: | |
- name: "Linux" | |
value: "ubuntu-latest" | |
python-version: | |
- "3.8" | |
- "3.9" | |
- "3.10" | |
- "3.11" | |
- "3.12" | |
tox-extras: [""] | |
include: | |
# Test Windows. | |
- os: | |
name: "Windows" | |
value: "windows-latest" | |
python-version: "3.12" | |
tox-extras: "" | |
# Test Mac. | |
- os: | |
name: "Mac" | |
value: "macos-latest" | |
python-version: "3.12" | |
tox-extras: "" | |
# Test minimum dependencies. | |
- os: | |
name: "Linux" | |
value: "ubuntu-latest" | |
python-version: "3.8" | |
tox-extras: "-minimum_flask" | |
- os: | |
name: "Linux" | |
value: "ubuntu-latest" | |
python-version: "3.12" | |
tox-extras: "-minimum_flask" | |
steps: | |
- name: "Checkout the repo" | |
uses: "actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11" # v4.1.1 | |
- name: "Identify the week number" | |
shell: "bash" | |
run: | | |
date +'%U' > week-number.txt | |
date +'week-number=%U' >> "$GITHUB_ENV" | |
- name: "Setup Python" | |
id: "setup-python" | |
uses: "actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c" # v5.0.0 | |
with: | |
python-version: "${{ matrix.python-version }}" | |
cache: "pip" | |
cache-dependency-path: | | |
.github/workflows/ci.yaml | |
pyproject.toml | |
tox.ini | |
week-number.txt | |
- name: "Restore cache" | |
id: "restore-cache" | |
uses: "actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319" # v4.0.1 | |
with: | |
path: | | |
.tox/ | |
.venv/ | |
key: > | |
test | |
week=${{ env.week-number }} | |
os=${{ matrix.os.value }} | |
python=${{ steps.setup-python.outputs.python-version }} | |
hash=${{ hashFiles('.github/workflows/ci.yaml', 'pyproject.toml', 'tox.ini') }} | |
- name: "Identify virtual environment path" | |
shell: "bash" | |
run: | | |
echo 'venv-path=${{ runner.os == 'Windows' && '.venv/Scripts' || '.venv/bin' }}' >> "$GITHUB_ENV" | |
- name: "Install tox" | |
if: "steps.restore-cache.outputs.cache-hit == false" | |
run: | | |
python -m venv .venv | |
${{ env.venv-path }}/pip install --upgrade pip setuptools wheel | |
${{ env.venv-path }}/pip install tox | |
- name: "Download the artifact" | |
uses: "actions/download-artifact@87c55149d96e628cc2ef7e6fc2aab372015aec85" # v4.1.3 | |
with: | |
name: "globus_action_provider_tools-${{ github.sha }}.whl" | |
- name: "Test" | |
run: > | |
${{ env.venv-path }}/tox run | |
--installpkg="${{ needs.build.outputs.wheel-filename }}" | |
-e py${{ matrix.python-version}}${{ matrix.tox-extras }} |