|
| 1 | +# Copyright 2020 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +name: Rust |
| 16 | + |
| 17 | +on: |
| 18 | + |
| 19 | + pull_request: |
| 20 | + branches: |
| 21 | + - master |
| 22 | + |
| 23 | + push: |
| 24 | + branches: |
| 25 | + - master |
| 26 | + |
| 27 | + schedule: |
| 28 | + - cron: '0 0 * * *' |
| 29 | + |
| 30 | +jobs: |
| 31 | + |
| 32 | + licenses: |
| 33 | + runs-on: ubuntu-latest |
| 34 | + |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v2 |
| 37 | + |
| 38 | + - name: Check licenses |
| 39 | + run: | |
| 40 | + go get -u github.com/google/addlicense |
| 41 | + export PATH=$PATH:$(go env GOPATH)/bin |
| 42 | + addlicense -check . |
| 43 | +
|
| 44 | + stable: |
| 45 | + runs-on: ubuntu-latest |
| 46 | + |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v2 |
| 49 | + |
| 50 | + - name: Update Rust |
| 51 | + run: rustup toolchain install stable --component clippy --component rustfmt |
| 52 | + |
| 53 | + - name: Cache (generate keys) |
| 54 | + run: | |
| 55 | + cargo generate-lockfile |
| 56 | + rustc --version | cut -d " " -f2 - > rust-toolchain |
| 57 | +
|
| 58 | + - name: Cache |
| 59 | + uses: actions/cache@v2 |
| 60 | + with: |
| 61 | + path: | |
| 62 | + ~/.cargo/.crates.toml |
| 63 | + ~/.cargo/.crates2.json |
| 64 | + ~/.cargo/bin |
| 65 | + ~/.cargo/registry |
| 66 | + target |
| 67 | + key: ${{ hashFiles('rust-toolchain', 'Cargo.lock') }} |
| 68 | + |
| 69 | + - name: Cache (cleanup) |
| 70 | + run: rm -f rust-toolchain |
| 71 | + |
| 72 | + - name: Build |
| 73 | + env: |
| 74 | + RUSTFLAGS: -D warnings |
| 75 | + run: cargo build --release --all-targets |
| 76 | + |
| 77 | + - name: Format (rustfmt) |
| 78 | + run: cargo fmt -- --check |
| 79 | + |
| 80 | + - name: Format (manifest) |
| 81 | + run: cargo verify-project |
| 82 | + |
| 83 | + - name: Package (docs) |
| 84 | + run: cargo doc --no-deps |
| 85 | + |
| 86 | + nightly: |
| 87 | + runs-on: ubuntu-latest |
| 88 | + |
| 89 | + steps: |
| 90 | + - uses: actions/checkout@v2 |
| 91 | + |
| 92 | + - name: Update Rust |
| 93 | + run: | |
| 94 | + rustup toolchain install nightly --component clippy --component rustfmt |
| 95 | + rustup default nightly |
| 96 | +
|
| 97 | + - name: Cache (generate keys) |
| 98 | + run: | |
| 99 | + cargo generate-lockfile |
| 100 | + rustc --version | tr " " "-" | cut -d "-" -f3,5-7 | cut -b1-18 > rust-toolchain |
| 101 | +
|
| 102 | + - name: Cache |
| 103 | + uses: actions/cache@v2 |
| 104 | + with: |
| 105 | + path: | |
| 106 | + ~/.cargo/.crates.toml |
| 107 | + ~/.cargo/.crates2.json |
| 108 | + ~/.cargo/bin |
| 109 | + ~/.cargo/registry |
| 110 | + target |
| 111 | + key: ${{ hashFiles('rust-toolchain', 'Cargo.lock') }} |
| 112 | + |
| 113 | + - name: Cache (cleanup) |
| 114 | + run: rm -f rust-toolchain |
| 115 | + |
| 116 | + - name: Build |
| 117 | + env: |
| 118 | + RUSTFLAGS: -D warnings |
| 119 | + run: cargo build --release --all-targets |
| 120 | + |
| 121 | + - name: Format (rustfmt) |
| 122 | + run: cargo fmt -- --check |
| 123 | + |
| 124 | + - name: Format (manifest) |
| 125 | + run: cargo verify-project |
| 126 | + |
| 127 | + - name: Package (docs) |
| 128 | + run: cargo doc --no-deps |
| 129 | + |
| 130 | + examples: |
| 131 | + runs-on: ubuntu-latest |
| 132 | + |
| 133 | + steps: |
| 134 | + - name: Checkout (test framework) |
| 135 | + uses: actions/checkout@v2 |
| 136 | + |
| 137 | + - name: Checkout (Rust SDK) |
| 138 | + uses: actions/checkout@v2 |
| 139 | + with: |
| 140 | + repository: proxy-wasm/proxy-wasm-rust-sdk |
| 141 | + path: proxy-wasm-rust-sdk |
| 142 | + |
| 143 | + - name: Update Rust |
| 144 | + run: | |
| 145 | + rustup toolchain install stable --component clippy --component rustfmt |
| 146 | + rustup target add wasm32-unknown-unknown |
| 147 | +
|
| 148 | + - name: Cache (generate keys) |
| 149 | + run: | |
| 150 | + cargo generate-lockfile |
| 151 | + cd proxy-wasm-rust-sdk && cargo generate-lockfile && cd .. |
| 152 | + rustc --version | cut -d " " -f2 - > rust-toolchain |
| 153 | +
|
| 154 | + - name: Cache |
| 155 | + uses: actions/cache@v2 |
| 156 | + with: |
| 157 | + path: | |
| 158 | + ~/.cargo/.crates.toml |
| 159 | + ~/.cargo/.crates2.json |
| 160 | + ~/.cargo/bin |
| 161 | + ~/.cargo/registry |
| 162 | + target |
| 163 | + proxy-wasm-rust-sdk/target |
| 164 | + key: ${{ hashFiles('rust-toolchain', 'Cargo.lock', 'proxy-wasm-rust-sdk/Cargo.lock') }} |
| 165 | + |
| 166 | + - name: Cache (cleanup) |
| 167 | + run: rm -f rust-toolchain |
| 168 | + |
| 169 | + - name: Build (test framework) |
| 170 | + env: |
| 171 | + RUSTFLAGS: -D warnings |
| 172 | + run: cargo build --release --all-targets |
| 173 | + |
| 174 | + - name: Build (Rust SDK examples) |
| 175 | + env: |
| 176 | + RUSTFLAGS: -C link-args=-S -D warnings |
| 177 | + run: cd proxy-wasm-rust-sdk && cargo build --release --examples --target=wasm32-unknown-unknown && cd .. |
| 178 | + |
| 179 | + - name: Test (hello_world) |
| 180 | + run: target/release/examples/hello_world proxy-wasm-rust-sdk/target/wasm32-unknown-unknown/release/examples/hello_world.wasm |
| 181 | + |
| 182 | + - name: Test (http_auth_random) |
| 183 | + run: target/release/examples/http_auth_random proxy-wasm-rust-sdk/target/wasm32-unknown-unknown/release/examples/http_auth_random.wasm |
| 184 | + |
| 185 | + - name: Test (http_headers) |
| 186 | + run: target/release/examples/http_headers proxy-wasm-rust-sdk/target/wasm32-unknown-unknown/release/examples/http_headers.wasm |
| 187 | + |
| 188 | + outdated: |
| 189 | + runs-on: ubuntu-latest |
| 190 | + |
| 191 | + steps: |
| 192 | + - uses: actions/checkout@v2 |
| 193 | + |
| 194 | + - name: Run cargo outdated |
| 195 | + run: cargo outdated --exit-code 1 |
| 196 | + |
| 197 | + audit: |
| 198 | + runs-on: ubuntu-latest |
| 199 | + |
| 200 | + steps: |
| 201 | + - uses: actions/checkout@v2 |
| 202 | + |
| 203 | + - name: Run cargo audit |
| 204 | + run: | |
| 205 | + cargo generate-lockfile |
| 206 | + cargo audit |
0 commit comments