|
| 1 | +name: pyjanitor tests |
| 2 | + |
| 3 | +on: [pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build-environment: |
| 7 | + name: Build environment |
| 8 | + runs-on: ubuntu-latest |
| 9 | + |
| 10 | + steps: |
| 11 | + - name: Checkout repository |
| 12 | + uses: actions/checkout@v2 |
| 13 | + |
| 14 | + # See: https://github.com/marketplace/actions/setup-conda |
| 15 | + - name: Setup anaconda |
| 16 | + uses: s-weigand/setup-conda@v1 |
| 17 | + with: |
| 18 | + conda-channels: "conda-forge" |
| 19 | + |
| 20 | + # Build cache of environment |
| 21 | + - name: Cache conda environment |
| 22 | + id: cache-environment |
| 23 | + uses: actions/cache@v2 |
| 24 | + # Conda environment build step depends on two files, |
| 25 | + # so we ensure that the hash key contains both their hashes. |
| 26 | + with: |
| 27 | + path: | |
| 28 | + pyjanitor-dev.tar.gz |
| 29 | + key: ${{ runner.os }}-env.${{ hashFiles('environment-dev.yml') }} |
| 30 | + |
| 31 | + - name: Build environment |
| 32 | + if: steps.cache-environment.outputs.cache-hit != 'true' |
| 33 | + run: | |
| 34 | + conda env create -f environment-dev.yml |
| 35 | + python -m pip install . |
| 36 | +
|
| 37 | + - name: Install conda-pack |
| 38 | + if: steps.cache-environment.outputs.cache-hit != 'true' |
| 39 | + run: conda install -c conda-forge conda-pack |
| 40 | + |
| 41 | + - name: Run conda-pack |
| 42 | + if: steps.cache-environment.outputs.cache-hit != 'true' |
| 43 | + run: conda pack -n pyjanitor-dev -o pyjanitor-dev.tar.gz |
| 44 | + |
| 45 | + # See: https://github.com/actions/upload-artifact |
| 46 | + - name: Upload environment |
| 47 | + uses: actions/upload-artifact@v2 |
| 48 | + with: |
| 49 | + name: pyjanitor-dev-tarball |
| 50 | + path: pyjanitor-dev.tar.gz |
| 51 | + |
| 52 | + unit-tests: |
| 53 | + name: Run unit tests |
| 54 | + runs-on: ubuntu-latest |
| 55 | + needs: build-environment |
| 56 | + |
| 57 | + steps: |
| 58 | + - name: Checkout repository |
| 59 | + uses: actions/checkout@v2 |
| 60 | + |
| 61 | + # https://github.com/actions/download-artifact |
| 62 | + - name: Download environment tarball |
| 63 | + uses: actions/download-artifact@v2 |
| 64 | + with: |
| 65 | + name: pyjanitor-dev-tarball |
| 66 | + |
| 67 | + - name: Unpack environment and activate it |
| 68 | + run: bash scripts/ci/unpack_environment.sh |
| 69 | + |
| 70 | + - name: Run tests |
| 71 | + run: | |
| 72 | + source /tmp/pyjanitor-dev_env/bin/activate |
| 73 | + python -m pip install -e . |
| 74 | + pytest |
| 75 | +
|
| 76 | + - name: Inspect coverage |
| 77 | + run: | |
| 78 | + cat coverage.xml |
| 79 | +
|
| 80 | + - name: Upload code coverage |
| 81 | + run: | |
| 82 | + source /tmp/pyjanitor-dev_env/bin/activate |
| 83 | + bash <(curl -s https://codecov.io/bash) |
| 84 | +
|
| 85 | + jupyter-notebook: |
| 86 | + name: Execute all Jupyter notebooks |
| 87 | + runs-on: ubuntu-latest |
| 88 | + needs: build-environment |
| 89 | + |
| 90 | + steps: |
| 91 | + - name: Checkout repository |
| 92 | + uses: actions/checkout@v2 |
| 93 | + |
| 94 | + # https://github.com/actions/download-artifact |
| 95 | + - name: Download environment tarball |
| 96 | + uses: actions/download-artifact@v2 |
| 97 | + with: |
| 98 | + name: pyjanitor-dev-tarball |
| 99 | + |
| 100 | + - name: Unpack environment and activate it |
| 101 | + run: bash scripts/ci/unpack_environment.sh |
| 102 | + |
| 103 | + - name: Execute Jupyter notebooks |
| 104 | + run: | |
| 105 | + source /tmp/pyjanitor-dev_env/bin/activate |
| 106 | + python -m pip install -e . |
| 107 | + python -m ipykernel install --user --name pyjanitor-dev |
| 108 | + jupyter nbconvert --to notebook --config nbconvert_config.py --execute --template full |
| 109 | +
|
| 110 | + docs: |
| 111 | + name: Build docs |
| 112 | + runs-on: ubuntu-latest |
| 113 | + needs: build-environment |
| 114 | + |
| 115 | + steps: |
| 116 | + - name: Checkout repository |
| 117 | + uses: actions/checkout@v2 |
| 118 | + |
| 119 | + # https://github.com/actions/download-artifact |
| 120 | + - name: Download environment tarball |
| 121 | + uses: actions/download-artifact@v2 |
| 122 | + with: |
| 123 | + name: pyjanitor-dev-tarball |
| 124 | + |
| 125 | + - name: Unpack environment and activate it |
| 126 | + run: bash scripts/ci/unpack_environment.sh |
| 127 | + |
| 128 | + |
| 129 | + - name: Build docs |
| 130 | + run: | |
| 131 | + source /tmp/pyjanitor-dev_env/bin/activate |
| 132 | + python -m pip install -e . |
| 133 | + cd docs && make html |
| 134 | +
|
| 135 | + - name: Netlify PR preview |
| 136 | + uses: netlify/actions/cli@master |
| 137 | + with: |
| 138 | + args: deploy --site ${{ secrets.NETLIFY_SITE_ID }} --auth ${{ secrets.NETLIFY_AUTH_TOKEN }} --dir=docs/_build/html/ |
0 commit comments