|
| 1 | +on: [pull_request] |
| 2 | + |
| 3 | +name: CI Tests |
| 4 | + |
| 5 | +jobs: |
| 6 | + check_and_test: |
| 7 | + name: Check |
| 8 | + strategy: |
| 9 | + matrix: |
| 10 | + rust: ["1.38.0", "stable", "beta", "nightly"] |
| 11 | + backend: ["postgres", "sqlite"] |
| 12 | + os: [ubuntu-18.04, macos-latest, windows-latest] |
| 13 | + runs-on: ${{ matrix.os }} |
| 14 | + steps: |
| 15 | + - name: Checkout sources |
| 16 | + uses: actions/checkout@v1 |
| 17 | + - name: Set environment variables |
| 18 | + shell: bash |
| 19 | + if: matrix.backend == 'postgres' |
| 20 | + run: | |
| 21 | + echo '::set-env name=DATABASE_URL::postgres://postgres:postgres@localhost/wundergraph_test' |
| 22 | +
|
| 23 | + - name: Set environment variables |
| 24 | + shell: bash |
| 25 | + if: matrix.backend == 'sqlite' |
| 26 | + run: | |
| 27 | + echo '::set-env name=DATABASE_URL::./test.db' |
| 28 | + echo '::set-env name=RUST_TEST_THREADS::1' |
| 29 | +
|
| 30 | + - name: Cache cargo registry |
| 31 | + uses: actions/cache@v1 |
| 32 | + with: |
| 33 | + path: ~/.cargo/registry |
| 34 | + key: ${{ runner.os }}-${{ matrix.backend }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }} |
| 35 | + - name: Cache cargo index |
| 36 | + uses: actions/cache@v1 |
| 37 | + with: |
| 38 | + path: ~/.cargo/git |
| 39 | + key: ${{ runner.os }}-${{ matrix.backend }}-cargo-index-${{ hashFiles('**/Cargo.toml') }} |
| 40 | + - name: Install libpq (Linux) |
| 41 | + if: runner.os == 'Linux' && matrix.backend == 'postgres' |
| 42 | + run: | |
| 43 | + sudo apt-get update |
| 44 | + sudo apt-get install -y libpq-dev postgresql |
| 45 | + echo "host all all 127.0.0.1/32 md5" > sudo tee -a /etc/postgresql/9.5/main/pg_hba.conf |
| 46 | + sudo service postgresql restart && sleep 3 |
| 47 | + sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';" |
| 48 | + sudo -u postgres psql -c "CREATE DATABASE wundergraph_test WITH OWNER = 'postgres';" |
| 49 | + sudo service postgresql restart && sleep 3 |
| 50 | +
|
| 51 | + - name: Install sqlite (Linux) |
| 52 | + if: runner.os == 'Linux' && matrix.backend == 'sqlite' |
| 53 | + run: sudo apt-get update && sudo apt-get install -y libsqlite3-dev sqlite3 |
| 54 | + |
| 55 | + - name: Install libpq (MacOs) |
| 56 | + if: runner.os == 'macOS' && matrix.backend == 'postgres' |
| 57 | + run: | |
| 58 | + brew update |
| 59 | + brew install postgres |
| 60 | + /usr/local/opt/postgres/bin/pg_ctl -D /usr/local/var/postgres start |
| 61 | + sleep 3 |
| 62 | + /usr/local/opt/postgres/bin/createuser -s postgres |
| 63 | + /usr/local/opt/postgres/bin/createdb wundergraph_test -O postgres |
| 64 | + /usr/local/opt/postgres/bin/psql -c "ALTER USER postgres PASSWORD 'postgres';" wundergraph_test |
| 65 | +
|
| 66 | + - name: Install sqlite (MacOS) |
| 67 | + if: runner.os == 'macOS' && matrix.backend == 'sqlite' |
| 68 | + run: | |
| 69 | + brew update && |
| 70 | + brew install sqlite |
| 71 | +
|
| 72 | + - name: Install sqlite (Windows) |
| 73 | + if: runner.os == 'Windows' && matrix.backend == 'sqlite' |
| 74 | + shell: cmd |
| 75 | + run: | |
| 76 | + choco install sqlite |
| 77 | + cd /D C:\ProgramData\chocolatey\lib\SQLite\tools |
| 78 | + call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" |
| 79 | + lib /machine:x64 /def:sqlite3.def /out:sqlite3.lib |
| 80 | + echo ::add-path::C:\ProgramData\chocolatey\lib\SQLite\tools |
| 81 | + echo ::set-env name=SQLITE3_LIB_DIR::C:\ProgramData\chocolatey\lib\SQLite\tools |
| 82 | + dir |
| 83 | +
|
| 84 | + - name: Install libpq (Windows) |
| 85 | + if: runner.os == 'Windows' && matrix.backend == 'postgres' |
| 86 | + shell: bash |
| 87 | + run: | |
| 88 | + choco install postgresql12 --force --params '/Password:postgres' |
| 89 | + echo '::add-path::C:\Program Files\PostgreSQL\12\bin' |
| 90 | + echo '::add-path::C:\Program Files\PostgreSQL\12\lib' |
| 91 | + echo '::set-env name=PQ_LIB_DIR::C:\Program Files\PostgreSQL\12\lib' |
| 92 | + PGPASSWORD='postgres' "C:\Program Files\PostgreSQL\12\bin\psql.exe" -Upostgres -c "CREATE DATABASE wundergraph_test WITH OWNER = 'postgres';" |
| 93 | +
|
| 94 | + - name: Install rust toolchain |
| 95 | + uses: actions-rs/toolchain@v1 |
| 96 | + with: |
| 97 | + profile: minimal |
| 98 | + toolchain: ${{ matrix.rust }} |
| 99 | + override: true |
| 100 | + |
| 101 | + - name: Run cargo check for wundergraph_derive |
| 102 | + uses: actions-rs/cargo@v1 |
| 103 | + with: |
| 104 | + command: check |
| 105 | + args: --manifest-path wundergraph_derive/Cargo.toml --features "${{ matrix.backend }}" |
| 106 | + |
| 107 | + - name: Run cargo check for wundergraph |
| 108 | + uses: actions-rs/cargo@v1 |
| 109 | + with: |
| 110 | + command: check |
| 111 | + args: --manifest-path wundergraph/Cargo.toml --features "${{ matrix.backend }}" |
| 112 | + |
| 113 | + - name: Run cargo check for wundergraph_example |
| 114 | + uses: actions-rs/cargo@v1 |
| 115 | + with: |
| 116 | + command: check |
| 117 | + args: --manifest-path wundergraph_example/Cargo.toml --features "${{ matrix.backend }}" --no-default-features |
| 118 | + |
| 119 | + - name: Run cargo check for wundergraph_bench |
| 120 | + uses: actions-rs/cargo@v1 |
| 121 | + with: |
| 122 | + command: check |
| 123 | + args: --manifest-path wundergraph_bench/Cargo.toml --features "${{ matrix.backend }}" --no-default-features |
| 124 | + |
| 125 | + - name: Run cargo check for wundergraph_cli |
| 126 | + uses: actions-rs/cargo@v1 |
| 127 | + with: |
| 128 | + command: check |
| 129 | + args: --manifest-path wundergraph_cli/Cargo.toml --features "${{ matrix.backend }}" --no-default-features |
| 130 | + |
| 131 | + - name: Run cargo test for wundergraph |
| 132 | + uses: actions-rs/cargo@v1 |
| 133 | + with: |
| 134 | + command: test |
| 135 | + args: --manifest-path wundergraph/Cargo.toml --features "${{ matrix.backend }} wundergraph_example/${{ matrix.backend }} wundergraph_bench/${{ matrix.backend }}" --no-default-features |
| 136 | + |
| 137 | + - name: Run cargo test for wundergraph_cli |
| 138 | + uses: actions-rs/cargo@v1 |
| 139 | + with: |
| 140 | + command: test |
| 141 | + args: --manifest-path wundergraph_cli/Cargo.toml --features "${{ matrix.backend }}" --no-default-features -- --nocapture |
| 142 | + |
| 143 | + |
| 144 | + clippy_check: |
| 145 | + name: Rustfmt + Clippy |
| 146 | + runs-on: ubuntu-latest |
| 147 | + steps: |
| 148 | + - uses: actions/checkout@v1 |
| 149 | + - uses: actions-rs/toolchain@v1 |
| 150 | + with: |
| 151 | + toolchain: nightly-2019-10-03 |
| 152 | + profile: minimal |
| 153 | + components: clippy, rustfmt |
| 154 | + - name: Cache cargo registry |
| 155 | + uses: actions/cache@v1 |
| 156 | + with: |
| 157 | + path: ~/.cargo/registry |
| 158 | + key: clippy-cargo-registry-${{ hashFiles('**/Cargo.toml') }} |
| 159 | + - name: Cache cargo index |
| 160 | + uses: actions/cache@v1 |
| 161 | + with: |
| 162 | + path: ~/.cargo/git |
| 163 | + key: clippy-cargo-index-${{ hashFiles('**/Cargo.toml') }} |
| 164 | + - name: Rustfmt |
| 165 | + run: | |
| 166 | + cargo fmt --all -- --check |
| 167 | + - uses: actions-rs/clippy-check@v1 |
| 168 | + name: Clippy wundergraph_derive |
| 169 | + with: |
| 170 | + name: Clippy wundergraph_derive |
| 171 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 172 | + args: --manifest-path wundergraph_derive/Cargo.toml --features "postgres sqlite" |
| 173 | + - uses: actions-rs/clippy-check@v1 |
| 174 | + name: Clippy wundergraph |
| 175 | + with: |
| 176 | + name: Clippy wundergraph |
| 177 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 178 | + args: --manifest-path wundergraph/Cargo.toml --features "postgres sqlite" |
| 179 | + - uses: actions-rs/clippy-check@v1 |
| 180 | + name: Clippy wundergraph_cli |
| 181 | + with: |
| 182 | + name: Clippy wundergraph_cli |
| 183 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 184 | + args: --manifest-path wundergraph_cli/Cargo.toml --features "postgres sqlite" |
0 commit comments