add random walk abstract class #32
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: Code Formatting | |
on: | |
push: # ci work when pushing main branch | |
branches: | |
- main | |
pull_request: # ci work when creating a PR to main branch | |
branches: | |
- main | |
jobs: | |
linting: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ['3.9'] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set commit range (push to the main branch, e.g. merge) | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
run: echo "COMMIT_RANGE=${{ github.event.before }}.." >> $GITHUB_ENV | |
- name: Set commit range (pull request) | |
if: github.event_name == 'pull_request' | |
run: | | |
git fetch origin main | |
echo "COMMIT_RANGE=origin/main..." >> $GITHUB_ENV | |
- name: Cache pip packages for Linux | |
if: runner.os == 'Linux' | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/**') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Create env.yml | |
shell: bash | |
run: | | |
python -m pip install --upgrade pip; | |
pip install conda-merge; | |
cd requirements | |
conda-merge env_base.yml env_test.yml > env.yml | |
cd .. | |
cp requirements/env.yml env.yml | |
- name: Install all dependencies using micromamba | |
uses: mamba-org/setup-micromamba@main | |
with: | |
environment-file: env.yml | |
environment-name: qtsit | |
create-args: python=${{ matrix.python-version }} | |
- name: Install qtsit | |
id: install | |
shell: bash -l {0} | |
run: python -m pip install -e . | |
- name: Show files modified | |
run: | | |
CHANGED_FILES=`git diff --name-only $COMMIT_RANGE || true` | |
echo "changed files are $CHANGED_FILES" | |
- name: Yapf (version 0.40.0) | |
id: yapf | |
shell: bash -l {0} | |
run: | | |
CHANGED_FILES=`git diff --name-only $COMMIT_RANGE | grep .py$ || true` | |
if [ -n "$CHANGED_FILES" ]; then | |
yapf -d $CHANGED_FILES | |
fi | |
- name: Flake8 | |
if: ${{ (success() || failure()) && (steps.install.outcome == 'failure' || steps.install.outcome == 'success') }} | |
shell: bash -l {0} | |
run: source scripts/flake8_for_ci.sh | |
- name: Mypy | |
if: ${{ (success() || failure()) && (steps.install.outcome == 'failure' || steps.install.outcome == 'success') }} | |
shell: bash -l {0} | |
run: | | |
mypy -p qtsit |