1name: ci
2on:
3  pull_request:
4  push:
5    branches:
6    - master
7  schedule:
8  - cron: '00 01 * * *'
9jobs:
10  test:
11    name: test
12    env:
13      # For some builds, we use cross to test on 32-bit and big-endian
14      # systems.
15      CARGO: cargo
16      # When CARGO is set to CROSS, TARGET is set to `--target matrix.target`.
17      TARGET:
18    runs-on: ${{ matrix.os }}
19    strategy:
20      matrix:
21        build:
22        - pinned
23        - stable
24        - stable-32
25        - stable-mips
26        - beta
27        - nightly
28        - macos
29        - win-msvc
30        - win-gnu
31        include:
32        - build: pinned
33          os: ubuntu-18.04
34          rust: 1.41.1
35        - build: stable
36          os: ubuntu-18.04
37          rust: stable
38        - build: stable-32
39          os: ubuntu-18.04
40          rust: stable
41          target: i686-unknown-linux-gnu
42        - build: stable-mips
43          os: ubuntu-18.04
44          rust: stable
45          target: mips64-unknown-linux-gnuabi64
46        - build: beta
47          os: ubuntu-18.04
48          rust: beta
49        - build: nightly
50          os: ubuntu-18.04
51          rust: nightly
52        - build: macos
53          os: macos-latest
54          rust: stable
55        - build: win-msvc
56          os: windows-2019
57          rust: stable
58        - build: win-gnu
59          os: windows-2019
60          rust: stable-x86_64-gnu
61    steps:
62    - name: Checkout repository
63      uses: actions/checkout@v1
64      with:
65        fetch-depth: 1
66    - name: Install Rust
67      uses: actions-rs/toolchain@v1
68      with:
69        toolchain: ${{ matrix.rust }}
70        profile: minimal
71        override: true
72    - name: Use Cross
73      if: matrix.target != ''
74      run: |
75        # FIXME: to work around bugs in latest cross release, install master.
76        # See: https://github.com/rust-embedded/cross/issues/357
77        cargo install --git https://github.com/rust-embedded/cross
78        echo "CARGO=cross" >> $GITHUB_ENV
79        echo "TARGET=--target ${{ matrix.target }}" >> $GITHUB_ENV
80    - name: Show command used for Cargo
81      run: |
82        echo "cargo command is: ${{ env.CARGO }}"
83        echo "target flag is: ${{ env.TARGET }}"
84    - name: Show CPU info for debugging
85      if: matrix.os == 'ubuntu-18.04'
86      run: lscpu
87    - run: ${{ env.CARGO }} build --verbose
88    - run: ${{ env.CARGO }} doc --verbose
89    - run: ${{ env.CARGO }} test --verbose
90    - if: matrix.build == 'nightly'
91      run: ${{ env.CARGO }} build --manifest-path aho-corasick-debug/Cargo.toml
92    - if: matrix.build == 'nightly'
93      run: ${{ env.CARGO }} bench --verbose --manifest-path bench/Cargo.toml -- --test
94
95  rustfmt:
96    name: rustfmt
97    runs-on: ubuntu-18.04
98    steps:
99    - name: Checkout repository
100      uses: actions/checkout@v1
101      with:
102        fetch-depth: 1
103    - name: Install Rust
104      uses: actions-rs/toolchain@v1
105      with:
106        toolchain: stable
107        profile: minimal
108        components: rustfmt
109    - name: Check formatting
110      run: |
111        cargo fmt --all -- --check
112