add GitHub actions #2
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: "PyOhm CI Tests" | |
on: [push] | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.11" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -e .[test,dev] | |
- name: Lint | |
run: | | |
pre-commit install | |
pre-commit run --all-files | |
- name: Test with pytest | |
run: | | |
python -m pytest -s tests --cov=heizer --cov-report=xml --junit-xml=report.xml | |
build_and_upload_doc: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.11" | |
- name: Build Docs | |
run: | | |
sudo apt-get install -y zip gzip tar | |
python -m pip install --upgrade pip | |
pip install -e .[doc] | |
mkdocs build -d doc/ | |
zip -r doc.zip doc/ | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: doc_zip | |
path: doc.zip | |
retention-days: 5 | |
- name: deploy | |
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.SERVER_IP }} | |
username: "root" | |
password: ${{ secrets.SERVER_PASS }} | |
source: "doc/" | |
target: "/var/www/html/pyohm/" | |
strip_components: 1 | |
overwrite: true |