|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - '**' |
| 10 | + |
| 11 | +jobs: |
| 12 | + # Check code formatting; anything that doesn't require compilation. |
| 13 | + pre-compile-checks: |
| 14 | + name: Pre-compile checks |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Check out the project |
| 18 | + uses: actions/checkout@v3 |
| 19 | + - name: Install Rust |
| 20 | + uses: dtolnay/rust-toolchain@master |
| 21 | + with: |
| 22 | + toolchain: nightly |
| 23 | + components: rustfmt |
| 24 | + - name: Check code formatting |
| 25 | + run: make check-fmt |
| 26 | + - name: Check license headers |
| 27 | + run: make license |
| 28 | + # - name: Check diagrams |
| 29 | + # run: make check-diagrams |
| 30 | + |
| 31 | + # Test matrix, running tasks from the Makefile. |
| 32 | + tests: |
| 33 | + needs: [pre-compile-checks] |
| 34 | + name: ${{ matrix.make.name }} (${{ matrix.os }}, ${{ matrix.rust }}) |
| 35 | + runs-on: ${{ matrix.os }} |
| 36 | + strategy: |
| 37 | + fail-fast: false |
| 38 | + matrix: |
| 39 | + os: [ubuntu-latest] |
| 40 | + rust: [nightly] |
| 41 | + make: |
| 42 | + - name: Lint |
| 43 | + task: lint |
| 44 | + - name: Test |
| 45 | + task: test |
| 46 | + exclude: |
| 47 | + - rust: stable |
| 48 | + make: |
| 49 | + name: Lint |
| 50 | + |
| 51 | + env: |
| 52 | + RUST_BACKTRACE: full |
| 53 | + RUSTFLAGS: -Dwarnings |
| 54 | + CARGO_INCREMENTAL: '0' |
| 55 | + SCCACHE_CACHE_SIZE: 10G |
| 56 | + CC: "sccache clang" |
| 57 | + CXX: "sccache clang++" |
| 58 | + |
| 59 | + steps: |
| 60 | + - name: Check out the project |
| 61 | + uses: actions/checkout@v3 |
| 62 | + |
| 63 | + - name: Install Rust |
| 64 | + uses: dtolnay/rust-toolchain@master |
| 65 | + with: |
| 66 | + targets: wasm32-unknown-unknown |
| 67 | + toolchain: ${{ matrix.rust }} |
| 68 | + components: rustfmt,clippy |
| 69 | + |
| 70 | + # Protobuf compiler required by libp2p-core |
| 71 | + - name: Install Protoc |
| 72 | + uses: arduino/setup-protoc@v1 |
| 73 | + with: |
| 74 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 75 | + |
| 76 | + - name: Setup sccache |
| 77 | + uses: hanabi1224/sccache-action@v1.2.0 # https://github.com/hanabi1224/sccache-action used by Forest. |
| 78 | + timeout-minutes: 5 |
| 79 | + continue-on-error: true |
| 80 | + with: |
| 81 | + release-name: v0.3.1 |
| 82 | + # Caching everything separately, in case they don't ask for the same things to be compiled. |
| 83 | + cache-key: ${{ matrix.make.name }}-${{ matrix.os }}-${{matrix.rust}}-${{ hashFiles('Cargo.lock', 'rust-toolchain', 'rust-toolchain.toml') }} |
| 84 | + # Not sure why we should ever update a cache that has the hash of the lock file in it. |
| 85 | + # In Forest it only contains the rust-toolchain, so it makes sense to update because dependencies could have changed. |
| 86 | + cache-update: false |
| 87 | + |
| 88 | + - name: ${{ matrix.make.name }} |
| 89 | + run: make ${{ matrix.make.task }} |
0 commit comments