| # This workflow will install Python dependencies, run tests and lint with a variety of Python versions |
| # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions |
| |
| name: continuous-integration |
| |
| on: |
| push: |
| branches: [master] |
| tags: |
| - "v[0-9]+.[0-9]+.[0-9]+*" |
| pull_request: |
| schedule: |
| - cron: '0 0 * * 0' # every week |
| |
| jobs: |
| |
| pre-commit: |
| |
| runs-on: ubuntu-latest |
| |
| steps: |
| - uses: actions/checkout@v4 |
| - name: Set up Python |
| uses: actions/setup-python@v5 |
| with: |
| python-version: '3.10' |
| - uses: pre-commit/action@v3.0.1 |
| |
| tests: |
| |
| runs-on: ubuntu-latest |
| strategy: |
| fail-fast: false |
| matrix: |
| python-version: ['pypy-3.10', '3.10', '3.11', '3.12', '3.13'] |
| |
| steps: |
| - uses: actions/checkout@v4 |
| - name: Set up Python ${{ matrix.python-version }} |
| uses: actions/setup-python@v5 |
| with: |
| python-version: ${{ matrix.python-version }} |
| allow-prereleases: true |
| - name: Install dependencies |
| run: | |
| python -m pip install --upgrade pip |
| pip install -e .[testing,linkify] |
| - name: Check spec file is up to date |
| run: | |
| python tests/test_cmark_spec/get_cmark_spec.py |
| - name: Run pytest |
| run: | |
| pytest tests/ --cov=markdown_it --cov-report=xml --cov-report=term-missing |
| - name: Upload to Codecov |
| if: matrix.python-version == '3.10' && github.repository == 'executablebooks/markdown-it-py' |
| uses: codecov/codecov-action@v5 |
| with: |
| name: markdown-it-py-pytests |
| flags: pytests |
| files: ./coverage.xml |
| fail_ci_if_error: true |
| token: ${{ secrets.CODECOV_TOKEN }} |
| |
| test-plugins: |
| |
| runs-on: ubuntu-latest |
| strategy: |
| matrix: |
| python-version: ['3.10'] |
| steps: |
| - uses: actions/checkout@v4 |
| - name: Set up Python ${{ matrix.python-version }} |
| uses: actions/setup-python@v5 |
| with: |
| python-version: ${{ matrix.python-version }} |
| - name: Install markdown-it-py |
| run: | |
| python -m pip install --upgrade pip |
| pip install .[testing] |
| - name: clone and install mdit-py-plugins |
| run: | |
| git clone https://github.com/executablebooks/mdit-py-plugins.git |
| pip install --no-deps -e mdit-py-plugins |
| - name: Run pytest for unit tests of mdit-py-plugins |
| run: cd mdit-py-plugins; pytest |
| |
| benchmark: |
| |
| runs-on: ubuntu-latest |
| steps: |
| - uses: actions/checkout@v4 |
| |
| - name: Set up Python |
| uses: actions/setup-python@v5 |
| with: |
| python-version: '3.10' |
| |
| - name: Install tox |
| run: | |
| python -m pip install --upgrade pip |
| pip install tox |
| |
| - name: Run benchmark |
| run: tox -e py310-bench-core -- --benchmark-json bench-core.json |
| |
| - name: Upload data |
| uses: actions/upload-artifact@v4 |
| with: |
| name: bench-core |
| path: bench-core.json |
| if-no-files-found: error |
| |
| publish: |
| |
| name: Publish to PyPI |
| needs: [pre-commit, tests] |
| if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') |
| runs-on: ubuntu-latest |
| permissions: |
| id-token: write |
| environment: |
| name: pypi |
| url: https://pypi.org/p/markdown-it-py |
| steps: |
| - uses: actions/checkout@v4 |
| - uses: actions/setup-python@v5 |
| with: |
| python-version: '3.10' |
| - run: pip install flit~=3.4 |
| - run: flit build |
| - uses: pypa/gh-action-pypi-publish@release/v1 |
| |
| allgood: |
| runs-on: ubuntu-latest |
| needs: |
| - pre-commit |
| - tests |
| steps: |
| - run: echo "Great success!" |