|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - dev |
| 7 | + - github |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + release: |
| 12 | + types: [created] |
| 13 | + |
| 14 | +jobs: |
| 15 | + black: |
| 16 | + runs-on: ubuntu-22.04 |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + - name: Set up Python |
| 20 | + uses: actions/setup-python@v4 |
| 21 | + with: |
| 22 | + python-version: '3.9' |
| 23 | + - name: Install Black |
| 24 | + run: pip install black |
| 25 | + - name: Run Black |
| 26 | + run: black --check --verbose -- . |
| 27 | + |
| 28 | + # pylint: |
| 29 | + # runs-on: ubuntu-22.04 |
| 30 | + # needs: black |
| 31 | + # steps: |
| 32 | + # - uses: actions/checkout@v4 |
| 33 | + # - name: Set up Python |
| 34 | + # uses: actions/setup-python@v4 |
| 35 | + # with: |
| 36 | + # python-version: '3.9' |
| 37 | + # - name: Install Pylint |
| 38 | + # run: | |
| 39 | + # pip install pylint |
| 40 | + |
| 41 | + # - name: Run Pylint |
| 42 | + # run: find . -type f -name "*.py" | xargs pylint --disable=import-error,missing-module-docstring,invalid-name,not-callable,duplicate-code --load-plugins=pylint.extensions.docparams |
| 43 | + |
| 44 | + tests: |
| 45 | + runs-on: ubuntu-22.04 |
| 46 | + container: |
| 47 | + image: ghcr.io/bastien-mva/docker_image:latest |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v4 |
| 50 | + - name: Install package and run tests |
| 51 | + run: | |
| 52 | + pip install '.[tests]' |
| 53 | + pip install -e . |
| 54 | + jupyter nbconvert Getting_started.ipynb --to python --output tests/test_getting_started |
| 55 | + cd tests |
| 56 | + python _create_readme_getting_started_and_docstrings_tests.py |
| 57 | + rm test_getting_started.py |
| 58 | + pytest test_ar.py |
| 59 | +
|
| 60 | + build_package: |
| 61 | + runs-on: ubuntu-22.04 |
| 62 | + steps: |
| 63 | + - uses: actions/checkout@v4 |
| 64 | + - name: Set up Python |
| 65 | + uses: actions/setup-python@v4 |
| 66 | + with: |
| 67 | + python-version: '3.9' |
| 68 | + - name: Install build |
| 69 | + run: pip install build |
| 70 | + - name: Build package |
| 71 | + run: | |
| 72 | + rm -rf dist/ |
| 73 | + python -m build |
| 74 | + - name: Upload artifact |
| 75 | + uses: actions/upload-artifact@v4 |
| 76 | + with: |
| 77 | + name: dist |
| 78 | + path: dist/ |
| 79 | + |
| 80 | + publish_package: |
| 81 | + runs-on: ubuntu-22.04 |
| 82 | + needs: |
| 83 | + - build_package |
| 84 | + - tests |
| 85 | + # if: github.event_name == 'release' |
| 86 | + if: github.event_name == 'release' && github.ref == 'refs/heads/main' |
| 87 | + steps: |
| 88 | + - uses: actions/checkout@v4 |
| 89 | + - name: Set up Python |
| 90 | + uses: actions/setup-python@v4 |
| 91 | + with: |
| 92 | + python-version: '3.9' |
| 93 | + - name: Install Twine |
| 94 | + run: pip install twine |
| 95 | + - name: download artifacts and publish |
| 96 | + uses: actions/download-artifact@v4 |
| 97 | + with: |
| 98 | + name: dist |
| 99 | + path: dist/ |
| 100 | + - name: Publish package |
| 101 | + env: |
| 102 | + TWINE_USERNAME: __token__ |
| 103 | + TWINE_PASSWORD: ${{ secrets.PYPLN_TOKEN }} |
| 104 | + run: python -m twine upload dist/* |
| 105 | + |
| 106 | + pages: |
| 107 | + runs-on: ubuntu-22.04 |
| 108 | + needs: publish_package |
| 109 | + if: github.event_name == 'release' && github.ref == 'refs/heads/main' |
| 110 | + |
| 111 | + steps: |
| 112 | + - uses: actions/checkout@v4 |
| 113 | + - name: Set up Python |
| 114 | + uses: actions/setup-python@v4 |
| 115 | + with: |
| 116 | + python-version: '3.9' |
| 117 | + - name: Install dependencies |
| 118 | + run: pip install '.[build-doc]' |
| 119 | + - name: Install Pandoc |
| 120 | + run: | |
| 121 | + wget https://github.com/jgm/pandoc/releases/download/1.15.1/pandoc-1.15.1-1-amd64.deb |
| 122 | + sudo dpkg -i pandoc-1.15.1-1-amd64.deb |
| 123 | + - name: Convert README |
| 124 | + run: pandoc README.md --from markdown --to rst -s -o docs/source/readme.rst |
| 125 | + - name: Build docs |
| 126 | + run: | |
| 127 | + pip install . |
| 128 | + make -C docs html |
| 129 | + - name: Deploy to GitHub Pages |
| 130 | + uses: peaceiris/actions-gh-pages@v4 |
| 131 | + with: |
| 132 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 133 | + publish_dir: ./docs/build/html |
0 commit comments