|
| 1 | +name: Continuous Integration |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + unix-build: |
| 7 | + name: Unix Build |
| 8 | + strategy: |
| 9 | + matrix: |
| 10 | + os: [ubuntu-18.04, macOS-10.14] |
| 11 | + python-version: [2.7, 3.6, 3.7] |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v1 |
| 15 | + with: |
| 16 | + submodules: true |
| 17 | + - name: Environment Variables |
| 18 | + run: | |
| 19 | + CI_PYTHON_VERSION=${{ matrix.python-version }} |
| 20 | + CI_PACKAGE=colour_hdri |
| 21 | + CI_SHA=${{ github.sha }} |
| 22 | + CI_SLACK_WEBHOOK=${{ secrets.SLACK_WEBHOOK }} |
| 23 | + CI_SLACK_SUCCESS_NOTIFICATION="payload={\"attachments\": [{\"color\": \"#4CAF50\", \"author_name\": \"Python ${{ matrix.python-version }} build on ${{ matrix.os }}\", \"text\": \"Build for commit *${CI_SHA:0:7}* succeeded!\", \"title\": \"${{ github.repository }}@${{ github.ref }}\", \"title_link\": \"https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks\", \"footer\": \"Triggered by ${{ github.actor }}\"}], \"username\":\"Github Actions @ ${{ github.repository }}\", \"channel\":\"#continuous-integration\", \"icon_url\":\"https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png\"}" |
| 24 | + CI_SLACK_FAILURE_NOTIFICATION="${CI_SLACK_SUCCESS_NOTIFICATION/4CAF50/F44336}" |
| 25 | + CI_SLACK_FAILURE_NOTIFICATION="${CI_SLACK_FAILURE_NOTIFICATION/succeeded/failed}" |
| 26 | + COVERALLS_REPO_TOKEN=${{ secrets.COVERALLS_REPO_TOKEN }} |
| 27 | + echo ::set-env name=CI_PYTHON_VERSION::$CI_PYTHON_VERSION |
| 28 | + echo ::set-env name=CI_PACKAGE::$CI_PACKAGE |
| 29 | + echo ::set-env name=CI_SHA::$CI_SHA |
| 30 | + echo ::set-env name=CI_SLACK_WEBHOOK::$CI_SLACK_WEBHOOK |
| 31 | + echo ::set-env name=CI_SLACK_SUCCESS_NOTIFICATION::$CI_SLACK_SUCCESS_NOTIFICATION |
| 32 | + echo ::set-env name=CI_SLACK_FAILURE_NOTIFICATION::$CI_SLACK_FAILURE_NOTIFICATION |
| 33 | + echo ::set-env name=COVERALLS_REPO_TOKEN::$COVERALLS_REPO_TOKEN |
| 34 | + - name: Set up Python ${{ matrix.python-version }} |
| 35 | + uses: actions/setup-python@v1 |
| 36 | + with: |
| 37 | + python-version: ${{ matrix.python-version }} |
| 38 | + - name: Ubuntu - Update OS & Install APT Dependencies |
| 39 | + if: matrix.os == 'ubuntu-18.04' |
| 40 | + run: | |
| 41 | + sudo apt-get update |
| 42 | + sudo apt-get --yes install dcraw libimage-exiftool-perl |
| 43 | + - name: macOS - Install Homebrew Dependencies |
| 44 | + if: matrix.os == 'macOS-10.14' |
| 45 | + run: | |
| 46 | + brew install dcraw exiftool |
| 47 | + brew cask install adobe-dng-converter |
| 48 | + - name: Ubuntu - Set up Matplotlib Backend |
| 49 | + if: matrix.os == 'ubuntu-18.04' |
| 50 | + run: | |
| 51 | + mkdir -p ~/.config/matplotlib |
| 52 | + echo "backend: Agg" > ~/.config/matplotlib/matplotlibrc |
| 53 | + - name: macOS - Set up Matplotlib Backend |
| 54 | + if: matrix.os == 'macOS-10.14' |
| 55 | + run: | |
| 56 | + mkdir -p ~/.matplotlib |
| 57 | + echo "backend: Agg" > ~/.matplotlib/matplotlibrc |
| 58 | + - name: Install Poetry |
| 59 | + run: | |
| 60 | + curl -L https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py -o get-poetry.py |
| 61 | + python get-poetry.py --preview |
| 62 | + PATH=$HOME/.poetry/bin:$PATH |
| 63 | + echo ::set-env name=PATH::$PATH |
| 64 | + # - "rawpy" raises a "UnicodeEncodeError" exception on Python 2.7 during installation thus skipping the "optional" packages. |
| 65 | + # - "pathlib" is missing from "Imageio". |
| 66 | + - name: Python 2.7 - Install Package Dependencies |
| 67 | + if: matrix.python-version == '2.7' |
| 68 | + run: | |
| 69 | + poetry install --extras "plotting" |
| 70 | + poetry env use $CI_PYTHON_VERSION |
| 71 | + source $(poetry env info -p)/bin/activate |
| 72 | + pip install pathlib |
| 73 | + python -c "import imageio;imageio.plugins.freeimage.download()" |
| 74 | + - name: Python 3.x - Install Package Dependencies |
| 75 | + if: matrix.python-version != '2.7' |
| 76 | + run: | |
| 77 | + poetry install --extras "optional plotting" |
| 78 | + poetry env use $CI_PYTHON_VERSION |
| 79 | + source $(poetry env info -p)/bin/activate |
| 80 | + python -c "import imageio;imageio.plugins.freeimage.download()" |
| 81 | + - name: Lint with flake8 |
| 82 | + run: | |
| 83 | + source $(poetry env info -p)/bin/activate |
| 84 | + flake8 $CI_PACKAGE --count --show-source --statistics |
| 85 | + - name: Test with nosetests |
| 86 | + run: | |
| 87 | + source $(poetry env info -p)/bin/activate |
| 88 | + python -W ignore -m nose --nocapture --with-doctest --doctest-options=+ELLIPSIS --with-coverage --cover-package=$CI_PACKAGE $CI_PACKAGE |
| 89 | + - name: Upload Coverage to coveralls.io |
| 90 | + if: matrix.python-version == '3.6' || matrix.python-version == '3.7' |
| 91 | + run: | |
| 92 | + source $(poetry env info -p)/bin/activate |
| 93 | + if [ -z "$COVERALLS_REPO_TOKEN" ]; then echo \"COVERALLS_REPO_TOKEN\" secret is undefined!; else coveralls; fi |
| 94 | + - name: Notify Slack |
| 95 | + if: always() |
| 96 | + run: | |
| 97 | + if [ "${{ job.status }}" == "Success" ]; then CI_SLACK_NOTIFICATION="$CI_SLACK_SUCCESS_NOTIFICATION"; else CI_SLACK_NOTIFICATION="$CI_SLACK_FAILURE_NOTIFICATION"; fi |
| 98 | + if [ -z "$CI_SLACK_WEBHOOK" ]; then echo \"SLACK_WEBHOOK\" secret is undefined!; else curl -k -d "$CI_SLACK_NOTIFICATION" -X POST $CI_SLACK_WEBHOOK; fi |
| 99 | + windows-build: |
| 100 | + name: Windows Build |
| 101 | + strategy: |
| 102 | + matrix: |
| 103 | + os: [windows-2019] |
| 104 | + python-version: [2.7, 3.6, 3.7] |
| 105 | + runs-on: ${{ matrix.os }} |
| 106 | + steps: |
| 107 | + - uses: actions/checkout@v1 |
| 108 | + with: |
| 109 | + submodules: true |
| 110 | + - name: Environment Variables |
| 111 | + run: | |
| 112 | + set CI_PYTHON_VERSION=${{ matrix.python-version }} |
| 113 | + set CI_PACKAGE=colour_hdri |
| 114 | + set CI_SHA=${{ github.sha }} |
| 115 | + set CI_SLACK_WEBHOOK=${{ secrets.SLACK_WEBHOOK }} |
| 116 | + set CI_SLACK_SUCCESS_NOTIFICATION="payload={\"attachments\": [{\"color\": \"#4CAF50\", \"author_name\": \"Python ${{ matrix.python-version }} build on ${{ matrix.os }}\", \"text\": \"Build for commit *"%CI_SHA:~0,7%"* succeeded!\", \"title\": \"${{ github.repository }}@${{ github.ref }}\", \"title_link\": \"https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks\", \"footer\": \"Triggered by ${{ github.actor }}\"}], \"username\":\"Github Actions @ ${{ github.repository }}\", \"channel\":\"#continuous-integration\", \"icon_url\":\"https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png\"}" |
| 117 | + set CI_SLACK_FAILURE_NOTIFICATION=%CI_SLACK_SUCCESS_NOTIFICATION:4CAF50=F44336% |
| 118 | + set CI_SLACK_FAILURE_NOTIFICATION=%CI_SLACK_FAILURE_NOTIFICATION:succeeded=failed% |
| 119 | + set COVERALLS_REPO_TOKEN=${{ secrets.COVERALLS_REPO_TOKEN }} |
| 120 | + echo ::set-env name=CI_PYTHON_VERSION::%CI_PYTHON_VERSION% |
| 121 | + echo ::set-env name=CI_PACKAGE::%CI_PACKAGE% |
| 122 | + echo ::set-env name=CI_SHA::%CI_SHA% |
| 123 | + echo ::set-env name=CI_SLACK_WEBHOOK::%CI_SLACK_WEBHOOK% |
| 124 | + echo ::set-env name=CI_SLACK_SUCCESS_NOTIFICATION::%CI_SLACK_SUCCESS_NOTIFICATION% |
| 125 | + echo ::set-env name=CI_SLACK_FAILURE_NOTIFICATION::%CI_SLACK_FAILURE_NOTIFICATION% |
| 126 | + echo ::set-env name=COVERALLS_REPO_TOKEN::%COVERALLS_REPO_TOKEN% |
| 127 | + shell: cmd |
| 128 | + - name: Set up Python ${{ matrix.python-version }} |
| 129 | + uses: actions/setup-python@v1 |
| 130 | + with: |
| 131 | + python-version: ${{ matrix.python-version }} |
| 132 | + - name: Install Command Line Dependencies |
| 133 | + run: | |
| 134 | + curl -L https://sourceforge.net/projects/exiftool/files/exiftool-11.73.zip/download -o exiftool-11.73.zip |
| 135 | + powershell -nologo -noprofile -command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('exiftool-11.73.zip', 'exiftool'); }" |
| 136 | + copy %CD%\exiftool\"exiftool(-k).exe" %CD%\exiftool\exiftool.exe |
| 137 | + dir %CD%\exiftool\ |
| 138 | + curl -L https://cdn.fastpictureviewer.com/bin/dcraw.zip?v=201605100 -o dcraw.zip |
| 139 | + powershell -nologo -noprofile -command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('dcraw.zip', 'dcraw'); }" |
| 140 | + curl -L https://download.adobe.com/pub/adobe/dng/win/DNGConverter_11_4.exe -o DNGConverter_11_4.exe |
| 141 | + DNGConverter_11_4.exe /S |
| 142 | + set PATH=%CD%\exiftool;%CD%\dcraw;"C:\Program Files\Adobe\Adobe DNG Converter";%PATH% |
| 143 | + echo ::set-env name=PATH::%PATH% |
| 144 | + shell: cmd |
| 145 | + - name: Install Poetry |
| 146 | + run: | |
| 147 | + curl -L https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py -o get-poetry.py |
| 148 | + python get-poetry.py --preview |
| 149 | + set PATH=%USERPROFILE%\.poetry\bin;%PATH% |
| 150 | + echo ::set-env name=PATH::%PATH% |
| 151 | + shell: cmd |
| 152 | + # - "pathlib" is missing from "Imageio". |
| 153 | + - name: Python 2.7 - Install Package Dependencies |
| 154 | + if: matrix.python-version == '2.7' |
| 155 | + run: | |
| 156 | + call poetry install --extras "optional plotting" |
| 157 | + FOR /F %%a IN ('poetry env info -p') DO SET CI_VIRTUAL_ENVIRONMENT=%%a |
| 158 | + echo ::set-env name=CI_VIRTUAL_ENVIRONMENT::%CI_VIRTUAL_ENVIRONMENT% |
| 159 | + call %CI_VIRTUAL_ENVIRONMENT%\scripts\activate |
| 160 | + pip install pathlib |
| 161 | + python -c "import imageio;imageio.plugins.freeimage.download()" |
| 162 | + shell: cmd |
| 163 | + - name: Python 3.x - Install Package Dependencies |
| 164 | + if: matrix.python-version != '2.7' |
| 165 | + run: | |
| 166 | + call poetry install --extras "optional plotting" |
| 167 | + FOR /F %%a IN ('poetry env info -p') DO SET CI_VIRTUAL_ENVIRONMENT=%%a |
| 168 | + echo ::set-env name=CI_VIRTUAL_ENVIRONMENT::%CI_VIRTUAL_ENVIRONMENT% |
| 169 | + call %CI_VIRTUAL_ENVIRONMENT%\scripts\activate |
| 170 | + python -c "import imageio;imageio.plugins.freeimage.download()" |
| 171 | + shell: cmd |
| 172 | + - name: Lint with flake8 |
| 173 | + run: | |
| 174 | + call %CI_VIRTUAL_ENVIRONMENT%\scripts\activate |
| 175 | + flake8 %CI_PACKAGE% --count --show-source --statistics |
| 176 | + shell: cmd |
| 177 | + - name: Test with nosetests |
| 178 | + run: | |
| 179 | + call %CI_VIRTUAL_ENVIRONMENT%\scripts\activate |
| 180 | + python -W ignore -m nose --nocapture --with-doctest --doctest-options=+ELLIPSIS --with-coverage --cover-package=%CI_PACKAGE% %CI_PACKAGE% |
| 181 | + shell: cmd |
| 182 | + - name: Upload Coverage to coveralls.io |
| 183 | + if: matrix.python-version == '3.6' || matrix.python-version == '3.7' |
| 184 | + run: | |
| 185 | + call %CI_VIRTUAL_ENVIRONMENT%\scripts\activate |
| 186 | + IF "%COVERALLS_REPO_TOKEN%"=="" (echo "COVERALLS_REPO_TOKEN" secret is undefined!) ELSE (coveralls) |
| 187 | + shell: cmd |
| 188 | + - name: Notify Slack |
| 189 | + if: always() |
| 190 | + run: | |
| 191 | + IF "${{ job.status }}"=="Success" (set CI_SLACK_NOTIFICATION=%CI_SLACK_SUCCESS_NOTIFICATION%) ELSE (set CI_SLACK_NOTIFICATION=%CI_SLACK_FAILURE_NOTIFICATION%) |
| 192 | + IF "%CI_SLACK_WEBHOOK%"=="" (echo "SLACK_WEBHOOK" secret is undefined!) ELSE (curl -k -d %CI_SLACK_NOTIFICATION% -X POST %CI_SLACK_WEBHOOK%) |
| 193 | + shell: cmd |
0 commit comments