Skip to content

Proposed citation descriptor for hpcflow #1582

Proposed citation descriptor for hpcflow

Proposed citation descriptor for hpcflow #1582

Workflow file for this run

name: test
concurrency:
| # e.g. don't run simultaneously on the same branch (since we may commit to that branch)
ci-${{ format('{0}github.head_ref', 'refs/heads') || github.ref }}
env:
PYTHON_VERSION_PRE_COMMIT: "3.12"
POETRY_VERSION: "1.4"
on:
workflow_dispatch: # manual invocation
inputs:
pre_commit:
description: "Run pre-commit."
required: true
type: boolean
default: true
unit_tests:
description: "Run unit tests"
required: true
type: boolean
default: true
invocation_tests:
description: "Run invocation tests."
required: true
type: boolean
default: true
integration_tests:
description: "Run integration-like workflow submission tests."
required: true
type: boolean
default: true
unit_test_args:
description: "CLI args to pass verbatim to pytest (unit tests)."
required: false
type: string
default: ""
integration_test_args:
description: "CLI args to pass verbatim to pytest (integration tests)."
required: false
type: string
default: ""
pull_request:
types: [opened, edited, synchronize]
branches: [main, develop] # have to manually change these
jobs:
pre-commit:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || github.event.inputs.pre_commit == 'true'
steps:
- uses: actions/checkout@v4
with:
# PAT of user who has permission to bypass branch
# protection || or standard GITHUB_TOKEN if running on an external fork (won't
# be able to commit fixes):
token: ${{ secrets.HPCFLOW_ACTIONS_TOKEN || secrets.GITHUB_TOKEN }}
# checkout PR source branch (head_ref) if event is pull_request:
ref: ${{ github.head_ref || github.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- run: |
git config user.name hpcflow-actions
git config user.email hpcflow-actions@users.noreply.github.com
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION_PRE_COMMIT }}
- name: pre-commit
# avoid exit code 1 (which halts GH actions) from pre-commit run command by
# running twice:
run: |
pip install pre-commit
pre-commit install
export SKIP=no-commit-to-branch
pre-commit run --all-files || pre-commit run --all-files
- name: pre-commit push changes
run: |
if git diff --quiet; then
echo "No pre-commit changes"
else
git commit -am "pre-commit fixes [skip ci]"
git push
fi
test-units:
needs: pre-commit
if: github.event_name == 'pull_request' || github.event.inputs.unit_tests == 'true'
strategy:
fail-fast: false
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
os:
- ubuntu-latest
- macos-13
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install and configure poetry
run: |
python -m pip install poetry==${{ env.POETRY_VERSION }}
poetry config virtualenvs.in-project true
poetry config installer.modern-installation false
- name: Cache the virtualenv
uses: actions/cache@v4
with:
path: ./.venv
key: ${{ runner.os }}-test-${{ matrix.python-version }}-venv-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: |
poetry install --without dev,pyinstaller
- name: Run tests
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
poetry run python -m pytest ${{ github.event.inputs.unit_test_args }}
test-units-CentOS:
needs: pre-commit
runs-on: ubuntu-latest
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: "true"
ACTIONS_RUNNER_FORCE_ACTIONS_NODE_VERSION: node16
if: github.event_name == 'pull_request' || github.event.inputs.unit_tests == 'true'
container:
image: ghcr.io/hpcflow/centos7-poetry:latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- name: Set ownership
run: |
# see: https://github.com/actions/runner/issues/2033#issuecomment-1204205989
# this is to fix GIT not liking owner of the checkout dir
chown -R $(id -u):$(id -g) $PWD
- name: Configure poetry
run: |
poetry config virtualenvs.in-project true
poetry config installer.modern-installation false
- name: Cache the virtualenv
uses: actions/cache@v3
with:
path: ./.venv
key: venv-CentOS-test-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: poetry install --without dev,pyinstaller
- name: Run tests
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
poetry run python -m pytest ${{ github.event.inputs.unit_test_args }}
test-integration:
needs: pre-commit
if: github.event_name == 'pull_request' || github.event.inputs.integration_tests == 'true'
strategy:
fail-fast: false
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
os:
- ubuntu-latest
- macos-13
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install and configure poetry
run: |
python -m pip install poetry==${{ env.POETRY_VERSION }}
poetry config virtualenvs.in-project true
poetry config installer.modern-installation false
- name: Cache the virtualenv
uses: actions/cache@v4
with:
path: ./.venv
key: ${{ runner.os }}-test-${{ matrix.python-version }}-venv-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: |
poetry install --without dev,pyinstaller
- name: Run tests
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
poetry run hpcflow test --integration ${{ github.event.inputs.integration_test_args }}
test-integration-CentOS:
needs: pre-commit
runs-on: ubuntu-latest
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: "true"
ACTIONS_RUNNER_FORCE_ACTIONS_NODE_VERSION: node16
if: github.event_name == 'pull_request' || github.event.inputs.integration_tests == 'true'
container:
image: ghcr.io/hpcflow/centos7-poetry:latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- name: Set ownership
run: |
# see: https://github.com/actions/runner/issues/2033#issuecomment-1204205989
# this is to fix GIT not liking owner of the checkout dir
chown -R $(id -u):$(id -g) $PWD
- name: Configure poetry
run: |
poetry config virtualenvs.in-project true
poetry config installer.modern-installation false
- name: Cache the virtualenv
uses: actions/cache@v3
with:
path: ./.venv
key: venv-CentOS-test-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: poetry install --without dev,pyinstaller
- name: Run tests
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
poetry run hpcflow test --integration ${{ github.event.inputs.integration_test_args }}
test-invocation-ubuntu:
if: github.event_name == 'pull_request' || github.event.inputs.invocation_tests == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry and configure poetry
run: |
python -m pip install poetry==${{ env.POETRY_VERSION }}
poetry config virtualenvs.in-project true
poetry config installer.modern-installation false
- name: Cache the virtualenv
uses: actions/cache@v4
with:
path: ./.venv
key: venv-test-invocation-linux-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: |
poetry install --without dev,pyinstaller
poetry run pip install ipython
- name: Test invocation command with `python ./hpcflow/cli.py`
run: |
source $(poetry env info --path)/bin/activate
actual=`python ./hpcflow/cli.py internal get-invoc-cmd`
expected="('`command -v python`', '$GITHUB_WORKSPACE/hpcflow/cli.py')"
echo actual: $actual
echo expected: $expected
[ "$actual" = "$expected" ]
- name: Test invocation command with `python -m hpcflow.cli`
run: |
source $(poetry env info --path)/bin/activate
actual=`python -m hpcflow.cli internal get-invoc-cmd`
expected="('`command -v python`', '$GITHUB_WORKSPACE/hpcflow/cli.py')"
echo actual: $actual
echo expected: $expected
[ "$actual" = "$expected" ]
- name: Test invocation command with `hpcflow` entry point script
run: |
source $(poetry env info --path)/bin/activate
actual=`hpcflow internal get-invoc-cmd`
expected="('`command -v python`', '`command -v hpcflow`')"
echo actual: $actual
echo expected: $expected
[ "$actual" = "$expected" ]
- name: Test invocation command within a python script
run: |
source $(poetry env info --path)/bin/activate
actual=$(python ./.github/workflows/get_invoc_cmd.py hpcflow.app)
expected="('`command -v python`', '$GITHUB_WORKSPACE/hpcflow/cli.py')"
echo actual: $actual
echo expected: $expected
[ "$actual" = "$expected" ]
- name: Test invocation command with interactive python
run: |
source $(poetry env info --path)/bin/activate
actual=$(python ./.github/workflows/get_invoc_cmd_interactive.py python hpcflow.app)
expected="('`command -v python`', '$GITHUB_WORKSPACE/hpcflow/cli.py')"
echo actual: $actual
echo expected: $expected
[ "$actual" = "$expected" ]
- name: Test invocation command with interactive ipython
run: |
source $(poetry env info --path)/bin/activate
actual=$(python ./.github/workflows/get_invoc_cmd_interactive.py ipython hpcflow.app)
expected="('`command -v python`', '$GITHUB_WORKSPACE/hpcflow/cli.py')"
echo actual: $actual
echo expected: $expected
[ "$actual" = "$expected" ]
- name: Test direct workflow submission within a python script
run: |
source $(poetry env info --path)/bin/activate
python ./.github/workflows/test_direct_sub_python_script.py hpcflow.app
- name: Test direct workflow submission within a Jupyter notebook (via papermill)
run: |
source $(poetry env info --path)/bin/activate
python -m ipykernel install --user --name python3
papermill ./.github/workflows/test_direct_sub_jupyter_notebook.ipynb ./.github/workflows/test_direct_sub_jupyter_notebook_${{ matrix.python-version }}_${{ runner.os }}.ipynb -p app_import_str hpcflow.app
test-invocation-macos:
if: github.event_name == 'pull_request' || github.event.inputs.invocation_tests == 'true'
runs-on: macos-13
strategy:
fail-fast: false
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry and configure poetry
run: |
python -m pip install poetry==${{ env.POETRY_VERSION }}
poetry config virtualenvs.in-project true
poetry config installer.modern-installation false
- name: Cache the virtualenv
uses: actions/cache@v4
with:
path: ./.venv
key: venv-test-invocation-macos-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: |
poetry install --without dev,pyinstaller
poetry run pip install ipython
- name: Test invocation command with `python ./hpcflow/cli.py`
run: |
source $(poetry env info --path)/bin/activate
actual=`python ./hpcflow/cli.py internal get-invoc-cmd`
expected="('`command -v python`', '$GITHUB_WORKSPACE/hpcflow/cli.py')"
echo actual: $actual
echo expected: $expected
[ "$actual" = "$expected" ]
- name: Test invocation command with `python -m hpcflow.cli`
run: |
source $(poetry env info --path)/bin/activate
actual=`python -m hpcflow.cli internal get-invoc-cmd`
expected="('`command -v python`', '$GITHUB_WORKSPACE/hpcflow/cli.py')"
echo actual: $actual
echo expected: $expected
[ "$actual" = "$expected" ]
- name: Test invocation command with `hpcflow` entry point script
run: |
source $(poetry env info --path)/bin/activate
actual=`hpcflow internal get-invoc-cmd`
expected="('`command -v python`', '`command -v hpcflow`')"
echo actual: $actual
echo expected: $expected
[ "$actual" = "$expected" ]
- name: Test invocation command within a python script
run: |
source $(poetry env info --path)/bin/activate
actual=$(python ./.github/workflows/get_invoc_cmd.py hpcflow.app)
expected="('`command -v python`', '$GITHUB_WORKSPACE/hpcflow/cli.py')"
echo actual: $actual
echo expected: $expected
[ "$actual" = "$expected" ]
- name: Test invocation command with interactive python
run: |
source $(poetry env info --path)/bin/activate
actual=$(python ./.github/workflows/get_invoc_cmd_interactive.py python hpcflow.app)
expected="('`command -v python`', '$GITHUB_WORKSPACE/hpcflow/cli.py')"
echo actual: $actual
echo expected: $expected
[ "$actual" = "$expected" ]
- name: Test invocation command with interactive ipython
run: |
source $(poetry env info --path)/bin/activate
actual=$(python ./.github/workflows/get_invoc_cmd_interactive.py ipython hpcflow.app)
expected="('`command -v python`', '$GITHUB_WORKSPACE/hpcflow/cli.py')"
echo actual: $actual
echo expected: $expected
[ "$actual" = "$expected" ]
- name: Test direct workflow submission within a python script
run: |
source $(poetry env info --path)/bin/activate
python ./.github/workflows/test_direct_sub_python_script.py hpcflow.app
- name: Test direct workflow submission within a Jupyter notebook (via papermill)
run: |
source $(poetry env info --path)/bin/activate
python -m ipykernel install --user --name python3
papermill ./.github/workflows/test_direct_sub_jupyter_notebook.ipynb ./.github/workflows/test_direct_sub_jupyter_notebook_${{ matrix.python-version }}_${{ runner.os }}.ipynb -p app_import_str hpcflow.app
test-invocation-windows:
if: github.event_name == 'pull_request' || github.event.inputs.invocation_tests == 'true'
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry and configure poetry
run: |
python -m pip install poetry==${{ env.POETRY_VERSION }}
poetry config virtualenvs.in-project true
poetry config installer.modern-installation false
- name: Cache the virtualenv
uses: actions/cache@v4
with:
path: ./.venv
key: venv-test-invocation-windows-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: |
poetry install --without dev,pyinstaller
- name: Test invocation command with `python ./hpcflow/cli.py`
run: |
."$(poetry env info --path)\Scripts\activate.ps1"
$actual = $(python ./hpcflow/cli.py internal get-invoc-cmd)
$expected = "('" + ((Get-Command python).source | Resolve-Path).Path.Replace('\', '\\') + "', '" + "$env:GITHUB_WORKSPACE\hpcflow\cli.py".Replace('\', '\\') + "')"
Write-Host actual: $actual
Write-Host expected: $expected
if ($actual -ne $expected) {
exit 1
}
- name: Test invocation command with `python -m hpcflow.cli`
run: |
."$(poetry env info --path)\Scripts\activate.ps1"
$actual = $(python -m hpcflow.cli internal get-invoc-cmd)
$expected = "('" + ((Get-Command python).source | Resolve-Path).Path.Replace('\', '\\') + "', '" + "$env:GITHUB_WORKSPACE\hpcflow\cli.py".Replace('\', '\\') + "')"
Write-Host actual: $actual
Write-Host expected: $expected
if ($actual -ne $expected) {
exit 1
}
- name: Test invocation command with `hpcflow` entry point script
run: |
."$(poetry env info --path)\Scripts\activate.ps1"
$actual = $(hpcflow internal get-invoc-cmd)
$expected = "('" + ((Get-Command python).source | Resolve-Path).Path.Replace('\', '\\') + "', '" + ((Get-Command hpcflow).source | Resolve-Path).Path.Replace('\', '\\').Trim('.cmd') + "')"
Write-Host actual: $actual
Write-Host expected: $expected
if ($actual -ne $expected) {
exit 1
}
- name: Test invocation command within a python script
run: |
."$(poetry env info --path)\Scripts\activate.ps1"
$actual = $(python .\.github\workflows\get_invoc_cmd.py hpcflow.app)
$expected = "('" + ((Get-Command python).source | Resolve-Path).Path.Replace('\', '\\') + "', '" + "$env:GITHUB_WORKSPACE\hpcflow\cli.py".Replace('\', '\\') + "')"
Write-Host actual: $actual
Write-Host expected: $expected
if ($actual -ne $expected) {
exit 1
}
- name: Test direct workflow submission within a python script
run: |
."$(poetry env info --path)\Scripts\activate.ps1"
python .\.github\workflows\test_direct_sub_python_script.py hpcflow.app
- name: Test direct workflow submission within a Jupyter notebook (via papermill)
run: |
."$(poetry env info --path)\Scripts\activate.ps1"
python -m ipykernel install --user --name python3
papermill .\.github\workflows\test_direct_sub_jupyter_notebook.ipynb .\.github\workflows\test_direct_sub_jupyter_notebook_${{ matrix.python-version }}_${{ runner.os }}.ipynb -p app_import_str hpcflow.app