jobs:
  include:
    - name: "Linux x64 (CentOS 7, glibc 2.17) - Node.js 10"
      os: linux
      dist: bionic
      language: shell
      before_install:
        - sudo docker run -dit --name sharp --env CI --env PREBUILD_TOKEN --volume "${PWD}:/mnt/sharp" --workdir /mnt/sharp centos:7
        - sudo docker exec sharp bash -c "curl -sL https://rpm.nodesource.com/setup_10.x | bash -"
        - sudo docker exec sharp yum install -y gcc-c++ make git nodejs
      install: sudo docker exec sharp bash -c "npm install --unsafe-perm"
      script: sudo docker exec sharp bash -c "npm test"

    - name: "Linux x64 (CentOS 7, glibc 2.17) - Node.js 12"
      os: linux
      dist: bionic
      language: shell
      before_install:
        - sudo docker run -dit --name sharp --env CI --env PREBUILD_TOKEN --volume "${PWD}:/mnt/sharp" --workdir /mnt/sharp centos:7
        - sudo docker exec sharp bash -c "curl -sL https://rpm.nodesource.com/setup_12.x | bash -"
        - sudo docker exec sharp yum install -y gcc-c++ make git nodejs
      install: sudo docker exec sharp bash -c "npm install --unsafe-perm"
      script: sudo docker exec sharp bash -c "npm test"

    - name: "Linux x64 (CentOS 7, glibc 2.17) - Node.js 13"
      os: linux
      dist: bionic
      language: shell
      before_install:
        - sudo docker run -dit --name sharp --env CI --env PREBUILD_TOKEN --volume "${PWD}:/mnt/sharp" --workdir /mnt/sharp centos:7
        - sudo docker exec sharp bash -c "curl -sL https://rpm.nodesource.com/setup_13.x | bash -"
        - sudo docker exec sharp yum install -y gcc-c++ make git nodejs
      install: sudo docker exec sharp bash -c "npm install --unsafe-perm"
      script: sudo docker exec sharp bash -c "npm test"

    - name: "Linux x64 (CentOS 7, glibc 2.17) - Node.js 14"
      os: linux
      dist: bionic
      language: shell
      before_install:
        - sudo docker run -dit --name sharp --env CI --env PREBUILD_TOKEN --volume "${PWD}:/mnt/sharp" --workdir /mnt/sharp centos:7
        - sudo docker exec sharp bash -c "curl -sL https://rpm.nodesource.com/setup_14.x | bash -"
        - sudo docker exec sharp yum install -y gcc-c++ make git nodejs
      install: sudo docker exec sharp bash -c "npm install --unsafe-perm"
      script: sudo docker exec sharp bash -c "npm test"

    - name: "Linux x64 (Alpine 3.9, musl 1.1.20) - Node.js 10"
      os: linux
      dist: bionic
      language: shell
      before_install:
        - sudo docker run -dit --name sharp --env CI --env PREBUILD_TOKEN --volume "${PWD}:/mnt/sharp" --workdir /mnt/sharp node:10.17.0-alpine3.9 # https://github.com/nodejs/docker-node/issues/1158
        - sudo docker exec sharp apk add build-base git python2 --update-cache
      install: sudo docker exec sharp sh -c "npm install --unsafe-perm"
      script: sudo docker exec sharp sh -c "npm test"

    - name: "Linux x64 (Alpine 3.11, musl 1.1.20) - Node.js 12"
      os: linux
      dist: bionic
      language: shell
      before_install:
        - sudo docker run -dit --name sharp --env CI --env PREBUILD_TOKEN --volume "${PWD}:/mnt/sharp" --workdir /mnt/sharp node:12.0-alpine
        - sudo docker exec sharp apk add build-base git python2 --update-cache
      install: sudo docker exec sharp sh -c "npm install --unsafe-perm"
      script: sudo docker exec sharp sh -c "npm test"

    - name: "Linux x64 (Alpine 3.11, musl 1.1.20) - Node.js 13"
      os: linux
      dist: bionic
      language: shell
      before_install:
        - sudo docker run -dit --name sharp --env CI --env PREBUILD_TOKEN --volume "${PWD}:/mnt/sharp" --workdir /mnt/sharp node:13.0-alpine
        - sudo docker exec sharp apk add build-base git python2 --update-cache
      install: sudo docker exec sharp sh -c "npm install --unsafe-perm"
      script: sudo docker exec sharp sh -c "npm test"

    - name: "Linux x64 (Alpine 3.11, musl 1.1.20) - Node.js 14"
      os: linux
      dist: bionic
      language: shell
      before_install:
        - sudo docker run -dit --name sharp --env CI --env PREBUILD_TOKEN --volume "${PWD}:/mnt/sharp" --workdir /mnt/sharp node:14.0-alpine
        - sudo docker exec sharp apk add build-base git python2 --update-cache
      install: sudo docker exec sharp sh -c "npm install --unsafe-perm"
      script: sudo docker exec sharp sh -c "npm test"

    - name: "Linux ARM64v8 (Debian 11, glibc 2.29) - Node.js 10"
      arch: arm64
      os: linux
      dist: bionic
      language: shell
      before_install:
        - sudo docker run -dit --name sharp --env CI --env PREBUILD_TOKEN --volume "${PWD}:/mnt/sharp" --workdir /mnt/sharp arm64v8/debian:bullseye
        - sudo docker exec sharp sh -c "apt-get update && apt-get install -y build-essential git python2 curl"
        - sudo docker exec sharp sh -c "curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -"
        - sudo docker exec sharp sh -c "echo 'deb https://deb.nodesource.com/node_10.x buster main' >/etc/apt/sources.list.d/nodesource.list"
        - sudo docker exec sharp sh -c "apt-get update && apt-get install -y nodejs"
      install: sudo docker exec sharp sh -c "npm install --unsafe-perm"
      script: sudo docker exec sharp sh -c "npm test"

    - name: "Linux ARM64v8 (Debian 11, glibc 2.29) - Node.js 12"
      arch: arm64
      os: linux
      dist: bionic
      language: shell
      before_install:
        - sudo docker run -dit --name sharp --env CI --env PREBUILD_TOKEN --volume "${PWD}:/mnt/sharp" --workdir /mnt/sharp arm64v8/debian:bullseye
        - sudo docker exec sharp sh -c "apt-get update && apt-get install -y build-essential git python2 curl"
        - sudo docker exec sharp sh -c "curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -"
        - sudo docker exec sharp sh -c "echo 'deb https://deb.nodesource.com/node_12.x buster main' >/etc/apt/sources.list.d/nodesource.list"
        - sudo docker exec sharp sh -c "apt-get update && apt-get install -y nodejs"
      install: sudo docker exec sharp sh -c "npm install --unsafe-perm"
      script: sudo docker exec sharp sh -c "npm test"

    - name: "Linux ARM64v8 (Debian 11, glibc 2.29) - Node.js 13"
      arch: arm64
      os: linux
      dist: bionic
      language: shell
      before_install:
        - sudo docker run -dit --name sharp --env CI --env PREBUILD_TOKEN --volume "${PWD}:/mnt/sharp" --workdir /mnt/sharp arm64v8/debian:bullseye
        - sudo docker exec sharp sh -c "apt-get update && apt-get install -y build-essential git python2 curl"
        - sudo docker exec sharp sh -c "curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -"
        - sudo docker exec sharp sh -c "echo 'deb https://deb.nodesource.com/node_13.x buster main' >/etc/apt/sources.list.d/nodesource.list"
        - sudo docker exec sharp sh -c "apt-get update && apt-get install -y nodejs"
      install: sudo docker exec sharp sh -c "npm install --unsafe-perm"
      script: sudo docker exec sharp sh -c "npm test"

    - name: "Linux ARM64v8 (Debian 11, glibc 2.29) - Node.js 14"
      arch: arm64
      os: linux
      dist: bionic
      language: shell
      before_install:
        - sudo docker run -dit --name sharp --env CI --env PREBUILD_TOKEN --volume "${PWD}:/mnt/sharp" --workdir /mnt/sharp arm64v8/debian:bullseye
        - sudo docker exec sharp sh -c "apt-get update && apt-get install -y build-essential git python2 curl"
        - sudo docker exec sharp sh -c "curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -"
        - sudo docker exec sharp sh -c "echo 'deb https://deb.nodesource.com/node_14.x buster main' >/etc/apt/sources.list.d/nodesource.list"
        - sudo docker exec sharp sh -c "apt-get update && apt-get install -y nodejs"
      install: sudo docker exec sharp sh -c "npm install --unsafe-perm"
      script: sudo docker exec sharp sh -c "npm test"

    - name: "macOS (10.13) - Node.js 10"
      os: osx
      osx_image: xcode10.1
      language: node_js
      node_js: "10"

    - name: "macOS (10.13) - Node.js 12"
      os: osx
      osx_image: xcode10.1
      language: node_js
      node_js: "12"

    - name: "macOS (10.13) - Node.js 13"
      os: osx
      osx_image: xcode10.1
      language: node_js
      node_js: "13"

    - name: "macOS (10.13) - Node.js 14"
      os: osx
      osx_image: xcode10.1
      language: node_js
      node_js: "14"

    - name: "Unit test coverage report"
      os: linux
      dist: bionic
      language: node_js
      node_js: "13"
      before_install: unset PREBUILD_TOKEN
      after_success:
        - npm install coveralls
        - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js

cache:
  npm: false
