Add coverage in CI #535
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
# This is a basic workflow to help you get started with Actions | |
name: CI-Ubuntu | |
# Controls when the action will run. Triggers the workflow on push or pull request | |
# events but only for the master branch | |
on: | |
push: | |
branches: [ '*' ] | |
paths-ignore: # Don't trigger on files that are updated by the CI | |
- README.md | |
pull_request: | |
branches: [ '*' ] | |
schedule: | |
# * is a special character in YAML so you have to quote this string | |
# run at 02:01 on every 15th day-of-month. | |
- cron: '1 2 */15 * *' | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.8, 3.9, '3.10', '3.11', '3.12', '3.13'] | |
# unsupported version on ubuntu-latest 3.5, 3.6 | |
# see https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@main | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@main | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install the dependences | |
run: | | |
python -m pip install --upgrade pip | |
# install ubuntu package | |
sudo apt-get update | |
# need to add ghostscript explicitly (only 'recommanded' by imagemagick package) | |
# but 'libmagickwand-dev' is installed | |
sudo apt-get install ghostscript imagemagick | |
# move policy file | |
sudo mv /etc/ImageMagick-6/policy.xml /etc/ImageMagick-6/policy.xml.off | |
# texlive-fonts-recommended (bophook in texlive-latex-extra) required by moodle2amc test | |
sudo apt-get install texlive-latex-recommended texlive-pictures texlive-fonts-recommended texlive-latex-extra | |
# add libtext-unidecode-perl to fix bug in deb package : https://github.com/brucemiller/LaTeXML/issues/1022 | |
sudo apt-get install libtext-unidecode-perl | |
sudo apt-get install latexml | |
sudo apt-get install xmlindent | |
- name: Test latexml | |
run: | | |
# add --strict flag to be more strict in error catching | |
latexml --noparse --nocomment --strict --path=./amc2moodle/amc2moodle --dest=./out.xml ./amc2moodle/tests/payload_test_amc2moodle/QCM.tex | |
- name: Install amc2moodle (and hatch for coverage) | |
run: | | |
# add -e to have write access for test. TODO : change with temp file | |
pip install hatch | |
pip install -e .[test] | |
- name: Test amc2moodle | |
run: | | |
pytest --pyargs amc2moodle.tests.test_amc2moodle | |
- name: Test moodle2amc | |
run: | | |
# add automultiplechoice.sty local copy to LaTeX PATH (for this step) | |
# export TEXINPUTS=.:./tests/payload_test_amc2moodle/:$TEXINPUTS (during tests, automultiplechoice.sty is copied in the temproary test folder ) | |
pytest --pyargs amc2moodle.tests.test_moodle2amc | |
- name: Test text parser | |
run: | | |
pytest --pyargs amc2moodle.tests.test_utils_text | |
- name: Test calculated questions parsers | |
run: | | |
pytest --pyargs amc2moodle.tests.test_utils_calculatedParser | |
- name: Generate coverage report | |
if: ${{ matrix.python-version == '3.13' }} | |
run: | | |
hatch test --cover | |
hatch run coverage xml | |
- name: Creating coverage folder | |
if: ${{ matrix.python-version == '3.13' }} | |
run: | | |
mkdir -p coverage | |
- name: Coverage Bagdge | |
if: ${{ matrix.python-version == '3.13' }} | |
uses: tj-actions/coverage-badge-py@v2 | |
with: | |
output: coverage/coverage.svg | |
- name: Publish coverage report to coverage-badge branch | |
if: ${{ matrix.python-version == '3.13' }} | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
branch: coverage-badge | |
folder: coverage | |
# Store output files | |
# amc2moodle | |
- name: Archive XML test output of amc2moodle (without tikz) | |
if: ${{ always() }} | |
uses: actions/upload-artifact@main | |
with: | |
name: test_notikz_${{ matrix.python-version }} | |
path: output_tests/test_notikz.xml | |
- name: Archive XML test output of amc2moodle (with tikz) | |
if: ${{ always() }} | |
uses: actions/upload-artifact@main | |
with: | |
name: test_tikz_${{ matrix.python-version }} | |
path: output_tests/test_tikz.xml | |
# moodle2amc | |
- name: Move latex output | |
if: ${{ always() }} | |
run: | | |
mkdir moodle-bank-exemple-output | |
mv output_tests/test_moodle-bank-exemple.* moodle-bank-exemple-output/ | |
- name: Archive LaTeX test output (moodle2amc) | |
if: ${{ always() }} | |
uses: actions/upload-artifact@main | |
with: | |
name: test_moodle-bank-exemple_${{ matrix.python-version }} | |
path: moodle-bank-exemple-output | |
# - name: Archive . | |
# if: ${{ always() }} | |
# uses: actions/upload-artifact@v1 | |
# with: | |
# name: all_${{ matrix.python-version }} | |
# path: . | |