1name: test
2
3on: [push, pull_request]
4
5jobs:
6  test:
7    runs-on: ubuntu-20.04
8
9    strategy:
10      matrix:
11        rust: [stable]
12        webp: [0.4.4, 0.5.2, 1.0.3, 1.1.0, 1.2.0]
13        webp_from: ["build"]
14        common_features: [""]
15        include:
16        - rust: stable
17          webp: 0.6.1
18          webp_from: distr
19          common_features: ""
20        - rust: stable
21          webp: 1.2.0
22          webp_from: bundled
23          common_features: ""
24        - rust: 1.34.0
25          webp: 1.2.0
26          webp_from: build
27          common_features: ""
28        - rust: beta
29          webp: 1.2.0
30          webp_from: build
31          common_features: ""
32        - rust: nightly
33          webp: 1.2.0
34          webp_from: build
35          common_features: ""
36        - rust: nightly
37          webp: 1.2.0
38          webp_from: build
39          common_features: extern-types,
40
41    steps:
42    - uses: actions/checkout@v2
43    - name: Install toolchain
44      uses: actions-rs/toolchain@v1
45      with:
46        toolchain: ${{ matrix.rust }}
47        override: true
48    - name: Install libwebp
49      run: sudo apt-get update && sudo apt-get install libwebp-dev -y;
50      if: matrix.webp_from == 'distr'
51    - name: Install libwebp
52      run: |
53        wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-${{ matrix.webp }}.tar.gz
54        tar zxf libwebp-${{ matrix.webp }}.tar.gz
55        cd libwebp-${{ matrix.webp }}
56        ./configure --enable-libwebpmux --enable-libwebpdemux
57        make
58        sudo make install
59        echo LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
60        echo PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV
61      if: ${{ matrix.webp_from == 'build' }}
62    - name: Set __LIBWEBP_SYS_FORBID_BUILD
63      run: echo __LIBWEBP_SYS_FORBID_BUILD=1 >> $GITHUB_ENV
64      if: ${{ matrix.webp_from != 'bundled' }}
65    - name: Test 0.4
66      run: |
67        cargo test --all --features "${{ matrix.common_features }}"
68        cargo test --all --features "${{ matrix.common_features }}demux"
69        cargo test --all --features "${{ matrix.common_features }}mux"
70        cargo test --all --features "${{ matrix.common_features }}demux,mux"
71    - name: Test 0.5
72      run: |
73        cargo test --all --features "${{ matrix.common_features }}0_5"
74        cargo test --all --features "${{ matrix.common_features }}0_5,demux"
75        cargo test --all --features "${{ matrix.common_features }}0_5,mux"
76        cargo test --all --features "${{ matrix.common_features }}0_5,demux,mux"
77      if: matrix.webp >= '0.5'
78    - name: Test 0.6
79      run: |
80        cargo test --all --features "${{ matrix.common_features }}0_6"
81        cargo test --all --features "${{ matrix.common_features }}0_6,demux"
82        cargo test --all --features "${{ matrix.common_features }}0_6,mux"
83        cargo test --all --features "${{ matrix.common_features }}0_6,demux,mux"
84      if: matrix.webp >= '0.6'
85    - name: Test 1.1
86      run: |
87        cargo test --all --features "${{ matrix.common_features }}1_1"
88        cargo test --all --features "${{ matrix.common_features }}1_1,demux"
89        cargo test --all --features "${{ matrix.common_features }}1_1,mux"
90        cargo test --all --features "${{ matrix.common_features }}1_1,demux,mux"
91      if: matrix.webp >= '1.1'
92    - name: Test 1.2
93      run: |
94        cargo test --all --features "${{ matrix.common_features }}1_2"
95        cargo test --all --features "${{ matrix.common_features }}1_2,demux"
96        cargo test --all --features "${{ matrix.common_features }}1_2,mux"
97        cargo test --all --features "${{ matrix.common_features }}1_2,demux,mux"
98      if: matrix.webp >= '1.2'
99    - name: Test static builds
100      run: |
101        cargo test --all --features "${{ matrix.common_features }}1_2,static"
102        cargo test --all --features "${{ matrix.common_features }}1_2,static,demux"
103        cargo test --all --features "${{ matrix.common_features }}1_2,static,mux"
104        cargo test --all --features "${{ matrix.common_features }}1_2,static,demux,mux"
105      if: matrix.webp_from == 'bundled'
106    - name: Test __doc_cfg
107      run: |
108        cargo doc --all --features "${{ matrix.common_features }}__doc_cfg"
109      if: matrix.rust == 'nightly'
110    - name: Check format
111      run: |
112        rustup component add rustfmt-preview
113        cargo fmt --all -- --check
114      if: matrix.rust == 'stable'
115