Skip to content

Update actions/checkout action to v4 #115

Update actions/checkout action to v4

Update actions/checkout action to v4 #115

Workflow file for this run

name: Continuous integration
on:
- push
jobs:
build:
name: Lint, test, and compile documentation
if: "!contains(github.event.head_commit.message, '[skip ci]') && github.actor != 'allcontributors'"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
########## install package and its requirements
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Setup pip cache
uses: actions/cache@v2
with:
path: /opt/hostedtoolcache/Python
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements.optional.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install pip and setuptools
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools
# install package
- name: Install the package
run: python -m pip install .
########## lint, test, package, compile documentation
# lint
- name: Install flake8
run: python -m pip install flake8
- name: Lint the package
run: python -m flake8
# test and upload coverage report to Codecov
- name: Install pytest
run: python -m pip install pytest pytest-cov
- name: Install the requirements for the tests
run: python -m pip install .[tests]
- name: Run the tests
env:
ENTREZ_EMAIL: ${{ secrets.ENTREZ_EMAIL }}
GRB_WLSACCESSID: ${{ secrets.GRB_WLSACCESSID }}
GRB_WLSSECRET: ${{ secrets.GRB_WLSSECRET }}
GRB_LICENSEID: ${{ secrets.GRB_LICENSEID }}
run: python -m pytest tests/ --cov=./biosimulations_bigg --cov-report=xml
- name: Upload the coverage report to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
file: ./coverage.xml
# compile documentation
- name: Install the requirements for compiling the documentation
run: python -m pip install -r docs-src/requirements.txt
- name: Compile the documentation
run: |
sphinx-apidoc . setup.py --output-dir docs-src/source --force --module-first --no-toc
mkdir -p docs-src/_static
sphinx-build docs-src docs
release:
name: Release a new version
needs: [build]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
# checkout coe
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
ref: dev
# install Python and Pip
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Setup pip cache
uses: actions/cache@v2
with:
path: /opt/hostedtoolcache/Python
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements.optional.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install pip and setuptools
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools
# convert README.md to RST for PyPI
- name: Install pandoc
run: |
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends wget
wget https://github.com/jgm/pandoc/releases -O /tmp/pandocVersions.html
urlPart=`grep "\.deb" /tmp/pandocVersions.html | head -n 1 | cut -d'/' -f2-7 | cut -d'"' -f1`
wget "https://github.com/$urlPart" -O /tmp/pandoc.deb
sudo dpkg -i /tmp/pandoc.deb
rm /tmp/pandocVersions.html
rm /tmp/pandoc.deb
- name: Convert README to .rst format
run: pandoc --from=gfm --output=README.rst --to=rst README.md
# compile package
- name: Install twine
run: |
python -m pip install wheel twine
- name: Create packages to upload to PyPI
run: |
python setup.py sdist
python setup.py bdist_wheel
# compile documentation
- name: Install the requirements for compiling the documentation
run: python -m pip install -r docs-src/requirements.txt
- name: Compile the documentation
run: |
sphinx-apidoc . setup.py --output-dir docs-src/source --force --module-first --no-toc
mkdir -p docs-src/_static
sphinx-build docs-src docs
########## Release
# get version number
- id: get-version-number
name: Get version number
env:
TAG: ${{ github.ref }}
run: |
version="${TAG/refs\/tags\//}"
echo "::set-output name=version::$version"
# Push the compiled documentation
- id: commit-docs
name: Commit the compiled documentation
run: |
git config --local user.email "biosimulations.daemon@gmail.com"
git config --local user.name "biosimulationsdaemon"
git config pull.rebase false
git stash
git pull
set +e
git stash pop
git add docs
git commit -m "Updating compiled documentation"
if [[ $? = 0 ]]; then
docsChanged=1
else
docsChanged=0
fi
echo "::set-output name=docsChanged::$docsChanged"
- name: Push the compiled documentation
if: steps.commit-docs.outputs.docsChanged == '1'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: dev
# Create PyPI release
- name: Upload packages to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
twine upload dist/*
# Create GitHub release
- name: Create GitHub release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get-version-number.outputs.version }}
release_name: Release ${{ steps.get-version-number.outputs.version }}