|
| 1 | +name: Unit Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches-ignore: |
| 6 | + - 'test_deploy' |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - '*' |
| 10 | + |
| 11 | +jobs: |
| 12 | + |
| 13 | + test_python: |
| 14 | + runs-on: ${{ matrix.config.os }} |
| 15 | + if: "!contains(github.event.head_commit.message, 'ci skip')" |
| 16 | + |
| 17 | + strategy: |
| 18 | + fail-fast: false |
| 19 | + matrix: |
| 20 | + config: |
| 21 | + - {name: '3.9', os: ubuntu-latest, python: '3.9' } |
| 22 | + - {name: '3.8', os: ubuntu-latest, python: '3.8' } |
| 23 | + - {name: '3.7', os: ubuntu-latest, python: '3.7' } |
| 24 | + - {name: '3.6', os: ubuntu-latest, python: '3.6' } |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Cancel Previous Runs |
| 28 | + uses: styfle/cancel-workflow-action@0.6.0 |
| 29 | + with: |
| 30 | + access_token: ${{ github.token }} |
| 31 | + |
| 32 | + - name: Check Ubuntu version |
| 33 | + run: | |
| 34 | + echo "UBUNTU_VERSION=`grep DISTRIB_RELEASE /etc/lsb-release | sed 's/.*=//g'`" >> $GITHUB_ENV |
| 35 | +
|
| 36 | + - uses: actions/checkout@v2 |
| 37 | + |
| 38 | + - name: Set up Python |
| 39 | + uses: actions/setup-python@v2 |
| 40 | + with: |
| 41 | + python-version: ${{ matrix.config.python }} |
| 42 | + |
| 43 | + - name: Cache Python packages |
| 44 | + uses: actions/cache@v2 |
| 45 | + with: |
| 46 | + path: ${{ env.pythonLocation }} |
| 47 | + key: ${{runner.os}}-pip-${{ env.pythonLocation }}-${{ hashFiles('python/setup.py') }} |
| 48 | + restore-keys: ${{runner.os}}-pip-${{ env.pythonLocation }}- |
| 49 | + |
| 50 | + - name: Install package & dependencies |
| 51 | + run: | |
| 52 | + python -m pip install --upgrade pip |
| 53 | + pip install -U wheel setuptools |
| 54 | + pip install -U ./python[test] |
| 55 | + python -c "import magic" |
| 56 | +
|
| 57 | + - name: Run Python tests |
| 58 | + run: | |
| 59 | + cd python |
| 60 | + nose2 -vvv |
| 61 | + cd .. |
| 62 | +
|
| 63 | + - name: Build docs |
| 64 | + run: | |
| 65 | + cd python |
| 66 | + pip install .[doc] |
| 67 | + cd doc |
| 68 | + make html |
| 69 | + cd ../.. |
| 70 | +
|
| 71 | + - name: Coveralls |
| 72 | + env: |
| 73 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + COVERALLS_SERVICE_NAME: github |
| 75 | + run: | |
| 76 | + coveralls |
| 77 | +
|
| 78 | + - name: Upload check results on fail |
| 79 | + if: failure() |
| 80 | + uses: actions/upload-artifact@master |
| 81 | + with: |
| 82 | + name: ${{ matrix.config.name }}_results |
| 83 | + path: check |
| 84 | + |
| 85 | + test_r: |
| 86 | + runs-on: ${{ matrix.config.os }} |
| 87 | + if: "!contains(github.event.head_commit.message, 'ci skip')" |
| 88 | + |
| 89 | + strategy: |
| 90 | + fail-fast: false |
| 91 | + matrix: |
| 92 | + config: |
| 93 | + - {name: 'devel', os: ubuntu-latest, r: 'devel' } |
| 94 | + - {name: 'release', os: ubuntu-latest, r: 'release' } |
| 95 | + |
| 96 | + steps: |
| 97 | + - name: Cancel Previous Runs |
| 98 | + uses: styfle/cancel-workflow-action@0.6.0 |
| 99 | + with: |
| 100 | + access_token: ${{ github.token }} |
| 101 | + |
| 102 | + - name: Set up environment |
| 103 | + run: | |
| 104 | + echo "UBUNTU_VERSION=`grep DISTRIB_RELEASE /etc/lsb-release | sed 's/.*=//g'`" >> $GITHUB_ENV |
| 105 | + mkdir -p .local/R/site-packages |
| 106 | + echo "R_LIBS_USER=`pwd`/.local/R/site-packages" >> $GITHUB_ENV |
| 107 | +
|
| 108 | + - uses: actions/checkout@v2 |
| 109 | + |
| 110 | + - name: Set up Python |
| 111 | + uses: actions/setup-python@v2 |
| 112 | + with: |
| 113 | + python-version: "3.8" |
| 114 | + |
| 115 | + - name: Install system dependencies |
| 116 | + if: runner.os == 'Linux' |
| 117 | + run: | |
| 118 | + sudo apt-get update -qq |
| 119 | + sudo apt-get install -y libcurl4-openssl-dev pandoc |
| 120 | +
|
| 121 | + - name: Cache Python packages |
| 122 | + uses: actions/cache@v2 |
| 123 | + with: |
| 124 | + path: ${{ env.pythonLocation }} |
| 125 | + key: ${{runner.os}}-pip-${{ env.pythonLocation }}-${{ hashFiles('python/setup.py') }} |
| 126 | + restore-keys: ${{runner.os}}-pip-${{ env.pythonLocation }}- |
| 127 | + |
| 128 | + - name: Install package & dependencies |
| 129 | + run: | |
| 130 | + python -m pip install --upgrade pip |
| 131 | + pip install -U wheel setuptools |
| 132 | + pip install -U ./python |
| 133 | + python -c "import magic" |
| 134 | +
|
| 135 | + - name: Set up R |
| 136 | + id: setup-r |
| 137 | + uses: r-lib/actions/setup-r@v1 |
| 138 | + with: |
| 139 | + r-version: ${{ matrix.config.r }} |
| 140 | + |
| 141 | + - name: Cache R packages |
| 142 | + uses: actions/cache@v2 |
| 143 | + if: startsWith(runner.os, 'Linux') |
| 144 | + with: |
| 145 | + path: ${{env.R_LIBS_USER}} |
| 146 | + key: test-${{env.UBUNTU_VERSION}}-renv-${{ steps.setup-r.outputs.installed-r-version }}-${{ hashFiles('Rmagic/DESCRIPTION') }}- |
| 147 | + restore-keys: | |
| 148 | + test-${{env.UBUNTU_VERSION}}-renv-${{ steps.setup-r.outputs.installed-r-version }}- |
| 149 | +
|
| 150 | + - name: Install R packages |
| 151 | + run: | |
| 152 | + if (!require("devtools")) install.packages("devtools", repos="http://cloud.r-project.org") |
| 153 | + devtools::install_dev_deps("./Rmagic", upgrade=TRUE) |
| 154 | + devtools::install("./Rmagic") |
| 155 | + shell: Rscript {0} |
| 156 | + |
| 157 | + - name: Install tinytex |
| 158 | + uses: r-lib/actions/setup-tinytex@v1 |
| 159 | + |
| 160 | + - name: Run R tests |
| 161 | + run: | |
| 162 | + cd Rmagic |
| 163 | + R CMD build . |
| 164 | + R CMD check --as-cran *.tar.gz |
| 165 | + cd .. |
| 166 | +
|
| 167 | + - name: Upload check results on fail |
| 168 | + if: failure() |
| 169 | + uses: actions/upload-artifact@master |
| 170 | + with: |
| 171 | + name: ${{ matrix.config.name }}_results |
| 172 | + path: check |
0 commit comments