|
| 1 | +name: ci |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build: |
| 7 | + name: ${{ matrix.kind }} ${{ matrix.os }} ${{ matrix.rust }} |
| 8 | + runs-on: ${{ matrix.os }} |
| 9 | + strategy: |
| 10 | + matrix: |
| 11 | + os: |
| 12 | + - macOS-latest |
| 13 | + - ubuntu-latest |
| 14 | + - windows-latest |
| 15 | + rust: |
| 16 | + # - stable |
| 17 | + # - beta |
| 18 | + - nightly |
| 19 | + |
| 20 | + env: |
| 21 | + CARGO_INCREMENTAL: 0 |
| 22 | + RUST_BACKTRACE: full |
| 23 | + CARGO_TERM_COLOR: always |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Clone repository |
| 27 | + uses: actions/checkout@v2 |
| 28 | + |
| 29 | + - name: Install rust (${{ matrix.rust }}) toolchain |
| 30 | + uses: actions-rs/toolchain@v1 |
| 31 | + with: |
| 32 | + toolchain: ${{ matrix.rust }} |
| 33 | + profile: minimal |
| 34 | + override: true |
| 35 | + components: rustfmt, clippy |
| 36 | + |
| 37 | + - name: Log versions |
| 38 | + run: | |
| 39 | + rustc --version |
| 40 | + cargo --version |
| 41 | +
|
| 42 | + - name: Configure cargo data directory |
| 43 | + # After this point, all cargo registry and crate data is stored in |
| 44 | + # $GITHUB_WORKSPACE/.cargo_home. This allows us to cache only the files |
| 45 | + # that are needed during the build process. Additionally, this works |
| 46 | + # around a bug in the 'cache' action that causes directories outside of |
| 47 | + # the workspace dir to be saved/restored incorrectly. |
| 48 | + run: | |
| 49 | + echo "CARGO_HOME=$(pwd)/.cargo_home" >> $GITHUB_ENV |
| 50 | +
|
| 51 | + - name: Cache |
| 52 | + uses: actions/cache@v2 |
| 53 | + with: |
| 54 | + # Note: crates from the denoland/deno git repo always get rebuilt, |
| 55 | + # and their outputs ('deno', 'libdeno.rlib' etc.) are quite big, |
| 56 | + # so we cache only those subdirectories of target/{debug|release} that |
| 57 | + # contain the build output for crates that come from the registry. |
| 58 | + path: |- |
| 59 | + .cargo_home |
| 60 | + target/*/.* |
| 61 | + target/*/build |
| 62 | + target/*/deps |
| 63 | + key: |
| 64 | + ${{ matrix.config.os }}-${{ matrix.config.rust }}-${{ hashFiles('Cargo.lock') }} |
| 65 | + restore-keys: | |
| 66 | + ${{ matrix.config.os }}-${{ matrix.config.rust }} |
| 67 | +
|
| 68 | + - name: Run cargo fmt |
| 69 | + run: cargo fmt --all -- --check |
| 70 | + |
| 71 | + - name: Run cargo check |
| 72 | + run: cargo check --locked |
| 73 | + |
| 74 | + - name: Run cargo clippy |
| 75 | + run: cargo clippy -- -D warnings |
| 76 | + |
| 77 | + - name: Build release |
| 78 | + run: cargo build --release --locked |
| 79 | + |
| 80 | + - name: Run cargo test |
| 81 | + run: cargo test --locked |
| 82 | + |
| 83 | + - name: Publish |
| 84 | + if: | |
| 85 | + startsWith(matrix.os, 'ubuntu') && |
| 86 | + startsWith(github.repository, 'postcss-rs') && |
| 87 | + startsWith(github.ref, 'refs/tags/') |
| 88 | + env: |
| 89 | + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
| 90 | + run: | |
| 91 | + cargo publish |
0 commit comments