|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - auto |
| 7 | + - try |
| 8 | + |
| 9 | + pull_request: |
| 10 | + |
| 11 | +jobs: |
| 12 | + frontend: |
| 13 | + name: Frontend |
| 14 | + runs-on: ubuntu-16.04 |
| 15 | + env: |
| 16 | + JOBS: 1 # See https://git.io/vdao3 for details. |
| 17 | + PERCY_PARALLEL_TOTAL: 2 |
| 18 | + # Percy secrets are included here to enable Percy's GitHub integration |
| 19 | + # on community-submitted PRs |
| 20 | + PERCY_TOKEN: 0d8707a02b19aebbec79bb0bf302b8d2fa95edb33169cfe41b084289596670b1 |
| 21 | + PERCY_PROJECT: crates-io/crates.io |
| 22 | + |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v2-beta |
| 25 | + |
| 26 | + - uses: actions/cache@v1 |
| 27 | + with: |
| 28 | + path: ~/.npm |
| 29 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 30 | + restore-keys: | |
| 31 | + ${{ runner.os }}-node- |
| 32 | +
|
| 33 | + - uses: actions/setup-node@v1 |
| 34 | + with: |
| 35 | + node-version: '12.x' |
| 36 | + |
| 37 | + - name: Install node modules |
| 38 | + run: npm ci |
| 39 | + |
| 40 | + - name: Lint |
| 41 | + run: | |
| 42 | + npm run lint:hbs |
| 43 | + npm run lint:js |
| 44 | + npm run lint:deps |
| 45 | +
|
| 46 | + - name: Add nonce for parallel tests |
| 47 | + run: echo ::set-env name=PERCY_PARALLEL_NONCE::`date +%s` |
| 48 | + |
| 49 | + - name: Test |
| 50 | + run: npm test |
| 51 | + |
| 52 | + backend: |
| 53 | + name: Backend |
| 54 | + runs-on: ubuntu-16.04 |
| 55 | + strategy: |
| 56 | + # TODO: [ci] should be true if GitHub Actions supports ""allow failures" on matrix |
| 57 | + fail-fast: false |
| 58 | + matrix: |
| 59 | + rust: |
| 60 | + - stable |
| 61 | + - beta |
| 62 | + - nightly |
| 63 | + |
| 64 | + env: |
| 65 | + DATABASE_URL: postgres://postgres:@localhost/cargo_registry_test |
| 66 | + TEST_DATABASE_URL: postgres://postgres:@localhost/cargo_registry_test |
| 67 | + CARGO_INCREMENTAL: 0 |
| 68 | + RUSTFLAGS: "-C debuginfo=0 -D warnings" |
| 69 | + |
| 70 | + steps: |
| 71 | + - uses: actions/checkout@v2-beta |
| 72 | + |
| 73 | + - name: Cleanup pre-installed Rust toolchains |
| 74 | + # The pre-installed toolchain is under root permission, and this would |
| 75 | + # make tarball fail to extract. Here we remove the symlink and install |
| 76 | + # our own Rust toolchain if necessary. |
| 77 | + run: | |
| 78 | + which rustup |
| 79 | + which cargo |
| 80 | + if [[ -L "$HOME/.cargo" && -L "$HOME/.rustup" ]]; then |
| 81 | + rm -v "$HOME/.rustup" |
| 82 | + rm -v "$HOME/.cargo" |
| 83 | + fi |
| 84 | + echo "::add-path::$HOME/.cargo/bin" |
| 85 | +
|
| 86 | + - name: Cache rustup |
| 87 | + uses: actions/cache@v1 |
| 88 | + with: |
| 89 | + path: ~/.rustup |
| 90 | + key: ${{ runner.os }}-rustup-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }} |
| 91 | + restore-key: | |
| 92 | + ${{ runner.os }}-rustup-${{ matrix.rust }}- |
| 93 | + ${{ runner.os }}-rustup- |
| 94 | +
|
| 95 | + - name: Cache cargo binaries |
| 96 | + uses: actions/cache@v1 |
| 97 | + with: |
| 98 | + path: ~/.cargo/bin |
| 99 | + key: ${{ runner.os }}-cargo-bin-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }} |
| 100 | + restore-key: | |
| 101 | + ${{ runner.os }}-cargo-bin-${{ matrix.rust }}- |
| 102 | + ${{ runner.os }}-cargo-bin- |
| 103 | +
|
| 104 | + - name: Cache cargo registry cache |
| 105 | + uses: actions/cache@v1 |
| 106 | + with: |
| 107 | + path: ~/.cargo/registry/cache |
| 108 | + key: ${{ runner.os }}-cargo-registry-cache-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }} |
| 109 | + restore-key: | |
| 110 | + ${{ runner.os }}-cargo-registry-cache-${{ matrix.rust }}- |
| 111 | + ${{ runner.os }}-cargo-registry-cache- |
| 112 | +
|
| 113 | + - name: Cache cargo registry index |
| 114 | + uses: actions/cache@v1 |
| 115 | + with: |
| 116 | + path: ~/.cargo/registry/index |
| 117 | + key: ${{ runner.os }}-cargo-registry-index-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }} |
| 118 | + restore-key: | |
| 119 | + ${{ runner.os }}-cargo-registry-index-${{ matrix.rust }}- |
| 120 | + ${{ runner.os }}-cargo-registry-index- |
| 121 | +
|
| 122 | + - name: Cache cargo git db |
| 123 | + uses: actions/cache@v1 |
| 124 | + with: |
| 125 | + path: ~/.cargo/git/db |
| 126 | + key: ${{ runner.os }}-cargo-git-db-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }} |
| 127 | + restore-key: | |
| 128 | + ${{ runner.os }}-cargo-git-db-${{ matrix.rust }}- |
| 129 | + ${{ runner.os }}-cargo-git-db- |
| 130 | +
|
| 131 | + - name: Cache cargo build |
| 132 | + uses: actions/cache@v1 |
| 133 | + with: |
| 134 | + path: target |
| 135 | + key: ${{ runner.os }}-cargo-build-target-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }} |
| 136 | + restore-key: | |
| 137 | + ${{ runner.os }}-cargo-build-target-${{ matrix.rust }}- |
| 138 | + ${{ runner.os }}-cargo-build-target- |
| 139 | +
|
| 140 | + - name: Install ${{ matrix.rust }} Rust |
| 141 | + run: | |
| 142 | + if [[ ! -d "$HOME/.cargo" || ! -d "$HOME/.rustup" ]]; then |
| 143 | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh |
| 144 | + sh rustup-init.sh -y --default-toolchain none |
| 145 | + fi |
| 146 | + rustup set profile minimal |
| 147 | + rustup update ${{ matrix.rust }} |
| 148 | + rustup default ${{ matrix.rust }} |
| 149 | +
|
| 150 | + - name: Install lint tools |
| 151 | + if: matrix.rust == 'stable' |
| 152 | + run: | |
| 153 | + rustup component add rustfmt |
| 154 | + rustup component add clippy |
| 155 | +
|
| 156 | + - name: Cargo clean on new rustc version |
| 157 | + run: script/ci/cargo-clean-on-new-rustc-version.sh |
| 158 | + |
| 159 | + - name: Install required system libraries |
| 160 | + run: | |
| 161 | + sudo tee /etc/apt/sources.list.d/pgdg.list <<END |
| 162 | + deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main |
| 163 | + END |
| 164 | + wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - |
| 165 | + sudo apt-get update |
| 166 | + sudo apt-get install -y libpq-dev postgresql-11 |
| 167 | + mkdir -p /etc/postgresql/11/main |
| 168 | + sudo tee /etc/postgresql/11/main/pg_hba.conf <<END |
| 169 | + local all all trust |
| 170 | + host all all 127.0.0.1/32 trust |
| 171 | + END |
| 172 | + sudo systemctl restart postgresql@11-main |
| 173 | +
|
| 174 | + - name: Setup database |
| 175 | + run: | |
| 176 | + which diesel || cargo install diesel_cli --vers $(cat .diesel_version) --no-default-features --features postgres |
| 177 | + diesel database setup --locked-schema |
| 178 | +
|
| 179 | + - name: Lint |
| 180 | + if: matrix.rust == 'stable' |
| 181 | + run: | |
| 182 | + cargo fmt -- --check |
| 183 | + cargo clippy --all-targets --all-features --all |
| 184 | +
|
| 185 | + - name: Test |
| 186 | + run: cargo test |
| 187 | + |
| 188 | + - name: Prune unnecessary cache |
| 189 | + run: script/ci/prune-cache.sh |
| 190 | + |
| 191 | + |
| 192 | + # These jobs doesn't actually test anything, but they're only used to tell |
| 193 | + # bors the build completed, as there is no practical way to detect when a |
| 194 | + # workflow is successful listening to webhooks only. |
| 195 | + # |
| 196 | + # ALL THE PREVIOUS JOBS NEEDS TO BE ADDED TO THE `needs` SECTION OF THIS JOB! |
| 197 | + |
| 198 | + end-success: |
| 199 | + name: bors build finished |
| 200 | + if: success() |
| 201 | + runs-on: ubuntu-latest |
| 202 | + needs: [frontend, backend] |
| 203 | + |
| 204 | + steps: |
| 205 | + - name: Mark the job as successful |
| 206 | + run: exit 0 |
| 207 | + |
| 208 | + end-failure: |
| 209 | + name: bors build finished |
| 210 | + if: "!success()" |
| 211 | + runs-on: ubuntu-latest |
| 212 | + needs: [frontend, backend] |
| 213 | + |
| 214 | + steps: |
| 215 | + - name: Mark the job as a failure |
| 216 | + run: exit 1 |
0 commit comments