|
1 | | -name: ci |
| 1 | +name: CI |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: |
| 6 | + - main |
6 | 7 | - master |
7 | 8 | pull_request: |
8 | 9 | branches: |
| 10 | + - main |
9 | 11 | - master |
10 | 12 |
|
11 | | -defaults: |
12 | | - run: |
13 | | - shell: bash |
14 | | - |
15 | 13 | env: |
16 | 14 | LANG: "en_US.utf-8" |
17 | 15 | LC_ALL: "en_US.utf-8" |
18 | | - POETRY_VIRTUALENVS_IN_PROJECT: "true" |
19 | 16 | PYTHONIOENCODING: "UTF-8" |
20 | | - PROJECT: "docutools" |
21 | | - MC: "/home/runner/miniconda3" |
22 | | - PATH: "$(MC)/bin:/home/runner/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:" |
23 | | - conda_project_tools: "tmux poetry graphviz imagemagick" |
24 | | - versioning: calver # for git-changelog |
25 | 17 |
|
26 | 18 | jobs: |
27 | | - tests: |
28 | | - name: Tests (${{ matrix.python-version }}, ${{ matrix.os }}) |
29 | | - runs-on: ${{ matrix.os }} |
| 19 | + test: |
| 20 | + name: Tests (Python ${{ matrix.python-version }}) |
| 21 | + runs-on: ubuntu-latest |
30 | 22 | strategy: |
31 | 23 | fail-fast: false |
32 | | - max-parallel: 6 |
33 | 24 | matrix: |
34 | | - os: ["ubuntu-latest"] |
35 | | - python-version: ["3.7", "3.8"] |
| 25 | + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: Checkout code |
| 29 | + uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - name: Install system dependencies |
| 32 | + run: | |
| 33 | + sudo apt-get update |
| 34 | + sudo apt-get install -y graphviz imagemagick |
| 35 | +
|
| 36 | + - name: Set up Python ${{ matrix.python-version }} |
| 37 | + uses: actions/setup-python@v5 |
| 38 | + with: |
| 39 | + python-version: ${{ matrix.python-version }} |
| 40 | + |
| 41 | + - name: Install uv |
| 42 | + uses: astral-sh/setup-uv@v4 |
| 43 | + with: |
| 44 | + version: "latest" |
| 45 | + |
| 46 | + - name: Install just |
| 47 | + uses: extractions/setup-just@v2 |
| 48 | + with: |
| 49 | + just-version: "latest" |
| 50 | + |
| 51 | + - name: Install dependencies |
| 52 | + run: uv sync |
| 53 | + |
| 54 | + - name: Run tests with coverage |
| 55 | + run: | |
| 56 | + uv run coverage run --rcfile=config/coverage.pytest.ini -m pytest tests -c config/pytest.ini |
| 57 | + uv run coverage combine |
| 58 | + uv run coverage report --precision=2 |
| 59 | + uv run coverage xml |
| 60 | +
|
| 61 | + - name: Upload coverage to Codecov |
| 62 | + uses: codecov/codecov-action@v4 |
| 63 | + with: |
| 64 | + file: ./coverage.xml |
| 65 | + fail_ci_if_error: false |
| 66 | + |
| 67 | + docs: |
| 68 | + name: Build and Deploy Documentation |
| 69 | + runs-on: ubuntu-latest |
| 70 | + needs: test |
| 71 | + # Only run on main/master branch pushes |
| 72 | + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') |
36 | 73 |
|
37 | 74 | steps: |
38 | | - - uses: actions/checkout@v2 |
| 75 | + - name: Checkout code |
| 76 | + uses: actions/checkout@v4 |
| 77 | + with: |
| 78 | + fetch-depth: 0 # Fetch all history for git-changelog |
| 79 | + |
| 80 | + - name: Install system dependencies |
| 81 | + run: | |
| 82 | + sudo apt-get update |
| 83 | + sudo apt-get install -y graphviz imagemagick |
39 | 84 |
|
40 | | - - name: Set up the Miniconda Root Cache |
41 | | - uses: actions/cache@v2 |
42 | | - env: |
43 | | - cache_name: miniconda-root-2 |
| 85 | + - name: Set up Python |
| 86 | + uses: actions/setup-python@v5 |
44 | 87 | with: |
45 | | - path: ~/miniconda3 |
46 | | - key: ${{ runner.os }}-build-${{ env.cache_name }} |
47 | | - - name: Install Miniconda Root |
48 | | - shell: bash -l {0} |
49 | | - run: "source ./make && make ci-conda-root-env" |
50 | | - - name: Conda info |
51 | | - shell: bash -l {0} |
52 | | - run: conda info |
53 | | - |
54 | | - - name: Set up the Miniconda Envs Cache |
55 | | - # they delete unused ones after 7 days. |
56 | | - uses: actions/cache@v2 |
57 | | - env: |
58 | | - cache_name: miniconda-envs-3-${{ env.PROJECT }}_py${{ matrix.python-version }}_${{ hashFiles('pyproject.toml', 'scripts/**') }} |
| 88 | + python-version: "3.11" |
| 89 | + |
| 90 | + - name: Install uv |
| 91 | + uses: astral-sh/setup-uv@v4 |
| 92 | + with: |
| 93 | + version: "latest" |
| 94 | + |
| 95 | + - name: Install just |
| 96 | + uses: extractions/setup-just@v2 |
| 97 | + with: |
| 98 | + just-version: "latest" |
| 99 | + |
| 100 | + - name: Install dependencies |
| 101 | + run: uv sync |
| 102 | + |
| 103 | + - name: Build documentation |
| 104 | + run: just docs |
| 105 | + |
| 106 | + - name: Deploy to GitHub Pages |
| 107 | + uses: peaceiris/actions-gh-pages@v4 |
| 108 | + with: |
| 109 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 110 | + publish_dir: ./site |
| 111 | + cname: ${{ vars.DOCS_CNAME }} # Optional: set this in repository variables if you have a custom domain |
| 112 | + |
| 113 | + coverage-badge: |
| 114 | + name: Update Coverage Badge |
| 115 | + runs-on: ubuntu-latest |
| 116 | + needs: test |
| 117 | + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') |
| 118 | + |
| 119 | + steps: |
| 120 | + - name: Checkout code |
| 121 | + uses: actions/checkout@v4 |
| 122 | + |
| 123 | + - name: Install system dependencies |
| 124 | + run: | |
| 125 | + sudo apt-get update |
| 126 | + sudo apt-get install -y graphviz imagemagick |
| 127 | +
|
| 128 | + - name: Set up Python |
| 129 | + uses: actions/setup-python@v5 |
| 130 | + with: |
| 131 | + python-version: "3.11" |
| 132 | + |
| 133 | + - name: Install uv |
| 134 | + uses: astral-sh/setup-uv@v4 |
| 135 | + with: |
| 136 | + version: "latest" |
| 137 | + |
| 138 | + - name: Install just |
| 139 | + uses: extractions/setup-just@v2 |
| 140 | + with: |
| 141 | + just-version: "latest" |
| 142 | + |
| 143 | + - name: Install dependencies |
| 144 | + run: uv sync |
| 145 | + |
| 146 | + - name: Generate coverage report |
| 147 | + run: | |
| 148 | + uv run coverage run --rcfile=config/coverage.pytest.ini -m pytest tests -c config/pytest.ini |
| 149 | + uv run coverage combine |
| 150 | + uv run coverage report --precision=2 > coverage_report.txt |
| 151 | +
|
| 152 | + - name: Extract coverage percentage |
| 153 | + id: coverage |
| 154 | + run: | |
| 155 | + COVERAGE=$(grep "TOTAL" coverage_report.txt | awk '{print $4}' | sed 's/%//') |
| 156 | + echo "percentage=$COVERAGE" >> $GITHUB_OUTPUT |
| 157 | +
|
| 158 | + - name: Create coverage badge |
| 159 | + uses: schneegans/dynamic-badges-action@v1.7.0 |
59 | 160 | with: |
60 | | - path: ~/miniconda3/envs/${{ env.PROJECT }}_py${{ matrix.python-version }} |
61 | | - key: ${{ runner.os }}-build-${{ env.cache_name }} |
62 | | - - name: Install Miniconda PyEnv |
63 | | - shell: bash -l {0} |
64 | | - env: |
65 | | - pyver: "${{ matrix.python-version }}" |
66 | | - run: "source ./make && make && make ci-conda-py-env" |
67 | | - |
68 | | - - name: Run tests |
69 | | - shell: bash -l {0} |
70 | | - env: |
71 | | - pyver: "${{ matrix.python-version }}" |
72 | | - run: "source ./make -a && make tests" |
73 | | - |
74 | | - - name: Test Docs LiterateProgramming |
75 | | - shell: bash -l {0} |
76 | | - env: |
77 | | - pyver: "${{ matrix.python-version }}" |
78 | | - run: "source ./make -a && make docs" |
79 | | - - name: Deploy Docs |
80 | | - shell: bash -l {0} |
81 | | - env: |
82 | | - pyver: "${{ matrix.python-version }}" |
83 | | - run: "source ./make -a && ${{ env.pyver == '3.7' && 'mkdocs gh-deploy --force' || true }}" |
| 161 | + auth: ${{ secrets.GITHUB_TOKEN }} |
| 162 | + gistID: ${{ vars.COVERAGE_GIST_ID }} # Set this in repository variables |
| 163 | + filename: docutools-coverage.json |
| 164 | + label: Coverage |
| 165 | + message: ${{ steps.coverage.outputs.percentage }}% |
| 166 | + color: ${{ steps.coverage.outputs.percentage > 80 && 'green' || steps.coverage.outputs.percentage > 60 && 'yellow' || 'red' }} |
0 commit comments