Skip to content

Testing macos.

Testing macos. #189

Workflow file for this run

name: testing
on:
push:
branches:
- develop
pull_request:
jobs:
test-ps:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Create long user
run: |
LONGUSER="averyverylongusernamethatislong"
echo "Creating user: $LONGUSER on OS: $(uname)"
if [[ "$RUNNER_OS" == "Linux" ]]; then
# Ubuntu user creation
sudo useradd -m "$LONGUSER"
echo "$LONGUSER:pass123" | sudo chpasswd
else
# macOS user creation
sudo sysadminctl -addUser "$LONGUSER" -password "pass123"
sudo createhomedir -c -u "$LONGUSER" > /dev/null
fi
- name: Start background job
run: |
LONGUSER="averyverylongusernamethatislong"
echo "Starting a sleep process for user: $LONGUSER"
# Run sleep as the long user and record its PID
if [[ "$RUNNER_OS" == "Linux" ]]; then
sudo -u "$LONGUSER" bash -c "sleep 60 & echo \$! > /tmp/testpid"
else
sudo -u "$LONGUSER" bash -c "sleep 60 & echo \$! > /tmp/testpid"
fi
echo "Started background job"
- name: Inspect ps output
run: |
PID=$(cat /tmp/testpid)
echo "PID is: $PID"
run_and_capture() {
CMD="$1"
echo
echo "### Running: $CMD"
# Create temp files for capturing output
OUT=$(mktemp)
ERR=$(mktemp)
# Run the command ONCE, capturing both stdout and stderr
bash -c "$CMD" >"$OUT" 2>"$ERR"
RET=$?
echo "--- STDOUT ---"
cat "$OUT"
echo "--- STDERR ---"
cat "$ERR"
echo "--- EXIT CODE: $RET ---"
rm "$OUT" "$ERR"
}
# Use function for each command
run_and_capture "ps -eo pid,user,uid,etime,state,comm | grep \" $PID\""
run_and_capture "ps -o pid,user,uid,etime,state,comm -p $PID"
run_and_capture "ps -o pid,user:32,uid,etime,state,comm -p $PID"
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: pip
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[strict,tests,dev]
- name: Lint
run: pre-commit run --all-files --show-diff-on-failure
test:
# runs-on: ubuntu-latest
strategy:
matrix:
# python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
config:
- { os: macos-latest, python: "3.9", resolution: lowest-direct }
- { os: ubuntu-latest, python: "3.9", resolution: lowest-direct }
- { os: ubuntu-latest, python: "3.9", resolution: highest }
- { os: ubuntu-latest, python: "3.10", resolution: highest }
- { os: ubuntu-latest, python: "3.11", resolution: highest }
- { os: ubuntu-latest, python: "3.12", resolution: highest }
- { os: ubuntu-latest, python: "3.13", resolution: highest }
- { os: ubuntu-latest, python: "3.14", resolution: lowest-direct }
- { os: ubuntu-latest, python: "3.14", resolution: highest }
runs-on: ${{ matrix.config.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.config.python }}
cache: pip
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[strict,tests,docs]
# - name: Test (macos - reduced test suite)
# if: matrix.config.os == 'ubuntu-latest'
# run: pytest --cov=qtoolkit --cov-report=xml
- name: Test
# if: matrix.config.os == 'ubuntu-latest'
run: pytest --cov=qtoolkit --cov-report=xml
- name: Upload coverage to Codecov
if: matrix.config.python == '3.11'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: matgenix/qtoolkit
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: pip
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: |
# Required to generate rst files from markdown
sudo apt install pandoc
python -m pip install --upgrade pip
pip install .[docs]
- name: Build Sphinx docs
working-directory: doc
run: |
# cannot use sphinx build directly as the makefile handles generation
# of some rst files
make html