|
| 1 | +--- |
| 2 | +name: Run Tests & Publishing |
| 3 | + |
| 4 | +on: [push, pull_request] |
| 5 | + |
| 6 | +jobs: |
| 7 | + lint: |
| 8 | + name: Lint Codebase |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - name: Checkout Project |
| 12 | + uses: actions/checkout@v3 |
| 13 | + with: |
| 14 | + fetch-depth: 0 |
| 15 | + |
| 16 | + - name: Setup Rust |
| 17 | + uses: actions-rs/toolchain@v1 |
| 18 | + with: |
| 19 | + toolchain: stable |
| 20 | + override: true |
| 21 | + components: rustfmt, clippy |
| 22 | + profile: minimal |
| 23 | + |
| 24 | + - name: Restore Rust Cache |
| 25 | + uses: Swatinem/rust-cache@v1 |
| 26 | + |
| 27 | + - name: Run Lints |
| 28 | + if: github.event_name == 'push' |
| 29 | + uses: actions-rs/clippy-check@v1 |
| 30 | + with: |
| 31 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 32 | + args: --all-features |
| 33 | + |
| 34 | + - name: Run Lints (WebAssembly) |
| 35 | + if: github.event_name == 'push' |
| 36 | + uses: actions-rs/clippy-check@v1 |
| 37 | + with: |
| 38 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 39 | + args: --all-features --target=wasm32-unknown-unknown |
| 40 | + |
| 41 | + - name: Run Lints (PR) |
| 42 | + if: github.event_name == 'pull_request' |
| 43 | + run: cargo clippy --all-features |
| 44 | + |
| 45 | + - name: Run Lints (PR) |
| 46 | + if: github.event_name == 'pull_request' |
| 47 | + run: cargo clippy --all-features --target=wasm32-unknown-unknown |
| 48 | + |
| 49 | + test: |
| 50 | + name: Run Tests |
| 51 | + runs-on: ubuntu-latest |
| 52 | + steps: |
| 53 | + - name: Checkout Project |
| 54 | + uses: actions/checkout@v3 |
| 55 | + with: |
| 56 | + fetch-depth: 0 |
| 57 | + |
| 58 | + - name: Setup Rust |
| 59 | + uses: actions-rs/toolchain@v1 |
| 60 | + with: |
| 61 | + toolchain: stable |
| 62 | + override: true |
| 63 | + components: rustfmt, clippy |
| 64 | + profile: minimal |
| 65 | + |
| 66 | + - name: Restore Rust Cache |
| 67 | + uses: Swatinem/rust-cache@v1 |
| 68 | + |
| 69 | + - name: Run Tests |
| 70 | + run: cargo test --all-features |
| 71 | + |
| 72 | + publish: |
| 73 | + name: Publish to crates.io |
| 74 | + runs-on: ubuntu-latest |
| 75 | + needs: |
| 76 | + - lint |
| 77 | + - test |
| 78 | + if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) |
| 79 | + steps: |
| 80 | + - name: Checkout Project |
| 81 | + uses: actions/checkout@v3 |
| 82 | + with: |
| 83 | + fetch-depth: 0 |
| 84 | + |
| 85 | + - name: Setup Rust |
| 86 | + uses: actions-rs/toolchain@v1 |
| 87 | + with: |
| 88 | + toolchain: stable |
| 89 | + override: true |
| 90 | + components: rustfmt, clippy |
| 91 | + profile: minimal |
| 92 | + |
| 93 | + - name: Restore Rust Cache |
| 94 | + uses: Swatinem/rust-cache@v1 |
| 95 | + |
| 96 | + - name: Run cargo publish --dry-run |
| 97 | + if: github.event_name == 'push' && github.ref == 'refs/heads/master' |
| 98 | + uses: actions-rs/cargo@v1 |
| 99 | + with: |
| 100 | + command: publish |
| 101 | + args: --dry-run |
| 102 | + env: |
| 103 | + RUSTFLAGS: "--cfg releasing" |
| 104 | + |
| 105 | + - name: Run cargo publish |
| 106 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') |
| 107 | + uses: actions-rs/cargo@v1 |
| 108 | + with: |
| 109 | + command: publish |
| 110 | + args: --token ${{ secrets.CRATES_IO_TOKEN }} |
| 111 | + env: |
| 112 | + RUSTFLAGS: "--cfg releasing" |
0 commit comments