|
| 1 | +name: Build |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + - staging |
| 8 | + - trying |
| 9 | + |
| 10 | +env: |
| 11 | + CARGO_TERM_COLOR: always |
| 12 | + |
| 13 | +jobs: |
| 14 | + # Run cargo fmt --check |
| 15 | + style: |
| 16 | + name: style |
| 17 | + runs-on: ubuntu-20.04 |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v1 |
| 21 | + |
| 22 | + - name: Install Rust |
| 23 | + uses: actions-rs/toolchain@v1 |
| 24 | + with: |
| 25 | + profile: minimal |
| 26 | + toolchain: stable |
| 27 | + override: true |
| 28 | + components: rustfmt |
| 29 | + |
| 30 | + - name: cargo fmt --check |
| 31 | + uses: actions-rs/cargo@v1 |
| 32 | + with: |
| 33 | + command: fmt |
| 34 | + args: --all -- --check |
| 35 | + |
| 36 | + # Compilation check |
| 37 | + check: |
| 38 | + name: check |
| 39 | + runs-on: ubuntu-20.04 |
| 40 | + strategy: |
| 41 | + matrix: |
| 42 | + target: |
| 43 | + - x86_64-unknown-linux-gnu |
| 44 | + toolchain: |
| 45 | + - stable |
| 46 | + steps: |
| 47 | + - name: Checkout |
| 48 | + uses: actions/checkout@v2 |
| 49 | + |
| 50 | + - name: Cache cargo dependencies |
| 51 | + uses: actions/cache@v2 |
| 52 | + with: |
| 53 | + path: | |
| 54 | + - ~/.cargo/bin/ |
| 55 | + - ~/.cargo/registry/index/ |
| 56 | + - ~/.cargo/registry/cache/ |
| 57 | + - ~/.cargo/git/db/ |
| 58 | + key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 59 | + restore-keys: | |
| 60 | + ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 61 | + ${{ runner.OS }}-cargo- |
| 62 | +
|
| 63 | + - name: Cache build output dependencies |
| 64 | + uses: actions/cache@v2 |
| 65 | + with: |
| 66 | + path: target |
| 67 | + key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} |
| 68 | + restore-keys: | |
| 69 | + ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} |
| 70 | + ${{ runner.OS }}-build- |
| 71 | +
|
| 72 | + - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }}) |
| 73 | + uses: actions-rs/toolchain@v1 |
| 74 | + with: |
| 75 | + toolchain: ${{ matrix.toolchain }} |
| 76 | + target: ${{ matrix.target }} |
| 77 | + override: true |
| 78 | + |
| 79 | + - name: cargo check |
| 80 | + uses: actions-rs/cargo@v1 |
| 81 | + with: |
| 82 | + use-cross: false |
| 83 | + command: check |
| 84 | + args: --target=${{ matrix.target }} |
| 85 | + |
| 86 | + |
| 87 | + # Refs: https://github.com/rust-lang/crater/blob/9ab6f9697c901c4a44025cf0a39b73ad5b37d198/.github/workflows/bors.yml#L125-L149 |
| 88 | + # |
| 89 | + # ALL THE PREVIOUS JOBS NEEDS TO BE ADDED TO THE `needs` SECTION OF THIS JOB! |
| 90 | + |
| 91 | + ci-success: |
| 92 | + name: ci |
| 93 | + if: github.event_name == 'push' && success() |
| 94 | + needs: |
| 95 | + - style |
| 96 | + - check |
| 97 | + runs-on: ubuntu-20.04 |
| 98 | + steps: |
| 99 | + - name: Mark the job as a success |
| 100 | + run: exit 0 |
0 commit comments