|
| 1 | +name: Cargo tests |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + pull_request: |
| 7 | +jobs: |
| 8 | + clippy: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - uses: actions/checkout@v1 |
| 12 | + - uses: actions-rs/toolchain@v1 |
| 13 | + with: |
| 14 | + toolchain: nightly |
| 15 | + components: clippy |
| 16 | + override: true |
| 17 | + - name: Install dependencies |
| 18 | + run: sudo apt install -y openssl libkrb5-dev |
| 19 | + - uses: actions-rs/clippy-check@v1 |
| 20 | + with: |
| 21 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 22 | + args: --features=all |
| 23 | + |
| 24 | + format: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v2 |
| 29 | + - uses: actions-rs/toolchain@v1 |
| 30 | + with: |
| 31 | + toolchain: stable |
| 32 | + components: rustfmt |
| 33 | + override: true |
| 34 | + - uses: mbrobbel/rustfmt-check@master |
| 35 | + with: |
| 36 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + |
| 38 | + cargo-test: |
| 39 | + runs-on: ubuntu-latest |
| 40 | + |
| 41 | + strategy: |
| 42 | + fail-fast: false |
| 43 | + matrix: |
| 44 | + features: |
| 45 | + - "--lib --features=all" |
| 46 | + - "--lib --no-default-features --features=sqlite" |
| 47 | + - "--lib --no-default-features --features=sqlite --features=chrono --features=json --features=uuid --features=pooled --features=serde-support --features=bigdecimal" |
| 48 | + - "--lib --no-default-features --features=postgresql" |
| 49 | + - "--lib --no-default-features --features=postgresql --features=chrono --features=json --features=uuid --features=pooled --features=serde-support --features=bigdecimal" |
| 50 | + - "--lib --no-default-features --features=mysql" |
| 51 | + - "--lib --no-default-features --features=mysql --features=chrono --features=json --features=uuid --features=pooled --features=serde-support --features=bigdecimal" |
| 52 | + - "--lib --no-default-features --features=mssql" |
| 53 | + - "--lib --no-default-features --features=mssql --features=chrono --features=json --features=uuid --features=pooled --features=serde-support --features=bigdecimal" |
| 54 | + - "--doc --features=all" |
| 55 | + env: |
| 56 | + TEST_MYSQL: "mysql://root:prisma@localhost:3306/prisma" |
| 57 | + TEST_MYSQL8: "mysql://root:prisma@localhost:3307/prisma" |
| 58 | + TEST_PSQL: "postgres://postgres:prisma@localhost:5432/postgres" |
| 59 | + TEST_MSSQL: "jdbc:sqlserver://localhost:1433;database=master;user=SA;password=<YourStrong@Passw0rd>;trustServerCertificate=true" |
| 60 | + RUSTFLAGS: "-Dwarnings" |
| 61 | + |
| 62 | + steps: |
| 63 | + - uses: actions/checkout@v2 |
| 64 | + |
| 65 | + - uses: actions-rs/toolchain@v1 |
| 66 | + with: |
| 67 | + toolchain: stable |
| 68 | + |
| 69 | + - uses: actions/cache@v2 |
| 70 | + with: |
| 71 | + path: | |
| 72 | + ~/.cargo/registry |
| 73 | + ~/.cargo/git |
| 74 | + target |
| 75 | + key: ${{ runner.os }}-cargo-${{ matrix.features }} |
| 76 | + |
| 77 | + - name: Start Databases |
| 78 | + run: docker-compose -f docker-compose.yml up -d |
| 79 | + |
| 80 | + - name: Sleep for 20s |
| 81 | + uses: juliangruber/sleep-action@v1 |
| 82 | + with: |
| 83 | + time: 20s |
| 84 | + |
| 85 | + - name: Run tests |
| 86 | + run: cargo test ${{ matrix.features }} |
| 87 | + |
| 88 | + rustdoc: |
| 89 | + needs: [clippy, format, cargo-test] |
| 90 | + runs-on: ubuntu-latest |
| 91 | + if: github.ref == 'refs/heads/master' |
| 92 | + |
| 93 | + steps: |
| 94 | + - uses: actions/checkout@v2 |
| 95 | + |
| 96 | + - uses: actions-rs/toolchain@v1 |
| 97 | + with: |
| 98 | + toolchain: nightly |
| 99 | + |
| 100 | + - uses: actions/cache@v2 |
| 101 | + with: |
| 102 | + path: | |
| 103 | + ~/.cargo/registry |
| 104 | + ~/.cargo/git |
| 105 | + target |
| 106 | + key: linux-cargo-rustdoc |
| 107 | + |
| 108 | + - name: Generate documentation |
| 109 | + run: | |
| 110 | + cargo rustdoc --all-features |
| 111 | + - name: Commit changes |
| 112 | + run: | |
| 113 | + git config user.name "GitHub agent" |
| 114 | + git config user.email "[email protected]" |
| 115 | +
|
| 116 | + rm -rf deploy_docs |
| 117 | + git clone --branch gh-pages "[email protected]:prisma/quaint.git" deploy_docs > /dev/null 2>&1 |
| 118 | + rm -rf deploy_docs/* |
| 119 | + mv target/doc/* deploy_docs/ |
| 120 | + echo "<meta http-equiv=refresh content=0;url=quaint/index.html>" > deploy_docs/index.html |
| 121 | +
|
| 122 | + DIFF=$(git status -s) |
| 123 | + printf "$DIFF\n" |
| 124 | +
|
| 125 | + if [ -z "$DIFF" ] |
| 126 | + then |
| 127 | + echo "Nothing to do" |
| 128 | + else |
| 129 | + git -C deploy_docs add -A . |
| 130 | + git -C deploy_docs commit -m "Add changes" |
| 131 | + fi |
| 132 | + - name: Push changes |
| 133 | + uses: ad-m/github-push-action@master |
| 134 | + with: |
| 135 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 136 | + branch: gh-pages |
| 137 | + directory: deploy_docs |
0 commit comments