Skip to content

Merge pull request #62 from ucl-cssb/create_bayes_mcmc_class #117

Merge pull request #62 from ucl-cssb/create_bayes_mcmc_class

Merge pull request #62 from ucl-cssb/create_bayes_mcmc_class #117

name: Python package CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
permissions:
contents: write
jobs:
update-requirements:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Set up Git
run: |
if [ "${{ github.event_name }}" = "pull_request" ]
then
BRANCH_NAME=${{ github.head_ref }}
else
BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})
fi
git checkout $BRANCH_NAME
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install autopep8
run: python -m pip install autopep8
- name: Format code with autopep8
run: autopep8 --in-place --aggressive --aggressive --recursive mimic/
- name: Install pip-tools
run: python -m pip install pip-tools
- name: Compile requirements.txt
run: pip-compile --output-file requirements.txt requirements.in
- name: Commit changes
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git add .
git commit -m "Update requirements.txt and format code" || true
git push origin HEAD
continue-on-error: true # In case there are no changes
- name: Upload updated requirements.txt
uses: actions/upload-artifact@v3
with:
name: requirements
path: requirements.txt
build:
needs: update-requirements
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.10"]
steps:
- uses: actions/checkout@v2
- name: Download updated requirements.txt
uses: actions/download-artifact@v3
with:
name: requirements
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache Python dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
python -m pip install flake8 mypy pytest
if [ -f requirements.txt ]; then
python -m pip install -r requirements.txt
else
echo "No requirements.txt found"
fi