Skip to content

Test and build

Test and build #605

name: Test and build
on:
push:
pull_request:
branches:
- main
schedule:
- cron: "0 7 * * 1"
jobs:
style-checks:
name: Run style checks
runs-on: ubuntu-22.04
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: actions/checkout@v3
- run: |
python3 -m pip install -r requirements.txt
python3 -m pip install numpy
name: Install requirements
- run: python3 -m pip install flake8 mypy pydocstyle isort
name: Install linting tools
- run: |
python3 -m flake8 .
name: Flake8 checks
- run: |
python3 -m pydocstyle .
name: Pydocstyle checks
- run: |
python3 -m mypy --install-types --non-interactive .
python3 -m mypy .
name: mypy checks
- run: |
python3 -m isort --check .
name: isort checks
test-build-website:
name: Test building of defelement.com
runs-on: ubuntu-22.04
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: actions/checkout@v3
- name: Load Symfem cache
id: cache-restore
uses: actions/cache/restore@v3
with:
path: /home/runner/.cache/symfem
key: symfem-cache
- name: Clone Symfem
uses: actions/checkout@v3
with:
path: ./symfem
repository: mscroggs/symfem
ref: main
- name: Install Symfem
run: |
cd symfem
python3 -m pip install .[optional]
- name: Clone verification
uses: actions/checkout@v3
with:
path: ./verification
repository: DefElement/defelement.com
ref: verification
continue-on-error: true
- run: mkdir -p ~/.local/share/fonts
name: Make font folder
- name: Clone Varela Round
uses: actions/checkout@v3
with:
path: ./varela-r
repository: avrahamcornfeld/Varela-Round-Hebrew
ref: master
- run: cp varela-r/fonts/VarelaRound-Regular.otf ~/.local/share/fonts/
name: Install Varela Round
- name: Download and install Computer Modern
run: |
wget https://downloads.sourceforge.net/project/cm-unicode/cm-unicode/0.7.0/cm-unicode-0.7.0-otf.tar.xz
tar -xf cm-unicode-0.7.0-otf.tar.xz
cp cm-unicode-0.7.0/cmunti.otf ~/.local/share/fonts/
- run: python3 -m pip install -r requirements.txt
name: Install requirements
- run: python3 build.py _test_html --verification-json verification/verification.json --test auto --processes 4
name: Build website HTML
build-website:
name: Build defelement.com
runs-on: ubuntu-22.04
if: github.ref != 'refs/heads/main'
needs:
- test-build-website
- run-tests
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: actions/checkout@v3
- name: Load Symfem cache
id: cache-restore
uses: actions/cache/restore@v3
with:
path: /home/runner/.cache/symfem
key: symfem-cache
- name: Clone Symfem
uses: actions/checkout@v3
with:
path: ./symfem
repository: mscroggs/symfem
ref: main
- name: Install Symfem
run: |
cd symfem
python3 -m pip install .[optional]
- name: Clone verification
uses: actions/checkout@v3
with:
path: ./verification
repository: DefElement/defelement.com
ref: verification
continue-on-error: true
- run: mkdir -p ~/.local/share/fonts
name: Make font folder
- name: Clone Varela Round
uses: actions/checkout@v3
with:
path: ./varela-r
repository: avrahamcornfeld/Varela-Round-Hebrew
ref: master
- run: cp varela-r/fonts/VarelaRound-Regular.otf ~/.local/share/fonts/
name: Install Varela Round
- name: Download and install Computer Modern
run: |
wget https://downloads.sourceforge.net/project/cm-unicode/cm-unicode/0.7.0/cm-unicode-0.7.0-otf.tar.xz
tar -xf cm-unicode-0.7.0-otf.tar.xz
cp cm-unicode-0.7.0/cmunti.otf ~/.local/share/fonts/
- run: python3 -m pip install -r requirements.txt
name: Install requirements
- run: python3 build.py _html --verification-json verification/verification.json --github-token ${{ secrets.GITHUB_TOKEN }} --processes 4
name: Build website HTML
if: ${{ !github.event.pull_request.head.repo.fork }}
- run: python3 build.py _html --verification-json verification/verification.json --processes 4
name: Build website HTML
if: ${{ github.event.pull_request.head.repo.fork }}
verification:
name: Test verification
runs-on: ubuntu-22.04
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: actions/checkout@v3
- name: Load Symfem cache
id: cache-restore
uses: actions/cache/restore@v3
with:
path: /home/runner/.cache/symfem
key: symfem-cache
- name: Clone Symfem
uses: actions/checkout@v3
with:
path: ./symfem
repository: mscroggs/symfem
ref: main
- name: Install Symfem
run: |
cd symfem
python3 -m pip install .[optional]
- run: python3 -m pip install -r requirements.txt
name: Install requirements
- name: Install implementations
run: |
python3 -m pip install setuptools
python3 install_implementations.py --install-type verification
- run: python3 verify.py verification.json --test auto --processes 4 --skip-missing-libraries false
name: Run verification test
build-and-push-website:
name: Build and deploy defelement.com
runs-on: ubuntu-22.04
if: github.ref == 'refs/heads/main'
permissions:
contents: read
pages: write
id-token: write
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: actions/checkout@v3
- name: Load Symfem cache
id: cache-restore
uses: actions/cache/restore@v3
with:
path: /home/runner/.cache/symfem
key: symfem-cache
- name: Clone Symfem
uses: actions/checkout@v3
with:
path: ./symfem
repository: mscroggs/symfem
ref: main
- name: Install Symfem
run: |
cd symfem
python3 -m pip install .[optional]
- name: Clone verification
uses: actions/checkout@v3
with:
path: ./verification
repository: DefElement/defelement.com
ref: verification
- run: mkdir -p ~/.local/share/fonts
name: Make font folder
- name: Clone Varela Round
uses: actions/checkout@v3
with:
path: ./varela-r
repository: avrahamcornfeld/Varela-Round-Hebrew
ref: master
- run: cp varela-r/fonts/VarelaRound-Regular.otf ~/.local/share/fonts/
name: Install Varela Round
- name: Download and install Computer Modern
run: |
wget https://downloads.sourceforge.net/project/cm-unicode/cm-unicode/0.7.0/cm-unicode-0.7.0-otf.tar.xz
tar -xf cm-unicode-0.7.0-otf.tar.xz
cp cm-unicode-0.7.0/cmunti.otf ~/.local/share/fonts/
- run: python3 -m pip install -r requirements.txt
name: Install requirements
- run: python3 build.py _html --verification-json verification/verification.json --github-token ${{ secrets.GITHUB_TOKEN }} --processes 4
name: Build website HTML
# Push to GitHub Pages
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: '_html'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
- name: Save matrix cache
id: cache-save
uses: actions/cache/save@v3
with:
path: /home/runner/.cache/symfem
key: symfem-cache-${{ github.run_id }}
restore-keys: symfem-cache
run-tests:
name: Run tests
runs-on: ubuntu-22.04
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: actions/checkout@v3
- run: python3 -m pip install pytest-xdist
name: Install dependencies
- name: Load Symfem cache
id: cache-restore
uses: actions/cache/restore@v3
with:
path: /home/runner/.cache/symfem
key: symfem-cache
- name: Clone Symfem
uses: actions/checkout@v3
with:
path: ./symfem
repository: mscroggs/symfem
ref: main
- name: Install Symfem
run: |
cd symfem
python3 -m pip install .[optional]
- run: python3 -m pip install -r requirements.txt
name: Install requirements
- name: Install implementations
run: python3 install_implementations.py --install-type all
- name: Install LaTeΧ
run: |
sudo apt-get update
sudo apt-get install -y texlive-latex-base
- run: python3 -m pytest -n4 test
name: Run tests with pytest