|
33 | 33 | --manifest-path sqlx-cli/Cargo.toml |
34 | 34 | --target-dir target/beta/ |
35 | 35 |
|
36 | | - test: |
37 | | - name: Test |
| 36 | + integration-test: |
| 37 | + name: Integration Test |
38 | 38 | runs-on: ${{ matrix.os }} |
39 | 39 |
|
40 | 40 | strategy: |
|
57 | 57 |
|
58 | 58 | - run: cargo test --manifest-path sqlx-cli/Cargo.toml |
59 | 59 |
|
| 60 | + test-mysql: |
| 61 | + name: Functional Test (MySQL) |
| 62 | + runs-on: ubuntu-latest |
| 63 | + # Deliberately not using `tests/docker-compose.yml` because that sets up the database automatically. |
| 64 | + services: |
| 65 | + mysql: |
| 66 | + image: mysql:8 |
| 67 | + env: |
| 68 | + MYSQL_ROOT_PASSWORD: password |
| 69 | + env: |
| 70 | + BASE_URL: mysql://root:password@mysql/ |
| 71 | + |
| 72 | + steps: |
| 73 | + - uses: actions/checkout@v4 |
| 74 | + |
| 75 | + - name: Setup Rust |
| 76 | + run: rustup show active-toolchain || rustup toolchain install |
| 77 | + |
| 78 | + - uses: Swatinem/rust-cache@v2 |
| 79 | + |
| 80 | + - name: Basic Test |
| 81 | + env: |
| 82 | + DATABASE_URL: ${{ env.BASE_URL }}/test1 |
| 83 | + run: | |
| 84 | + cargo run -p sqlx-cli --no-default-features --features mysql -- \ |
| 85 | + db setup --source=test/mysql/migrations |
| 86 | + |
| 87 | + cargo run -p sqlx-cli --no-default-features --features mysql -- \ |
| 88 | + mig info --source=test/mysql/migrations |
| 89 | + |
| 90 | + cargo run -p sqlx-cli --no-default-features --features mysql -- \ |
| 91 | + db drop |
| 92 | +
|
| 93 | + - name: Test .env |
| 94 | + run: | |
| 95 | + echo "DATABASE_URL=${{ env.base_URL }}/test2" > .env |
| 96 | + |
| 97 | + cargo run -p sqlx-cli --no-default-features --features mysql -- \ |
| 98 | + db setup --source=test/mysql/migrations |
| 99 | + |
| 100 | + cargo run -p sqlx-cli --no-default-features --features mysql -- \ |
| 101 | + mig info --source=test/mysql/migrations |
| 102 | + |
| 103 | + cargo run -p sqlx-cli --no-default-features --features mysql -- \ |
| 104 | + db drop |
| 105 | +
|
| 106 | + - name: Test --no-dotenv |
| 107 | + run: | |
| 108 | + # Allow subcommands to fail |
| 109 | + set +e |
| 110 | + |
| 111 | + echo "DATABASE_URL=${{ env.base_URL }}/test3" > .env |
| 112 | + |
| 113 | + ERROR=$(cargo run -p sqlx-cli --no-default-features --features mysql -- \ |
| 114 | + db setup --no-dotenv --source=test/mysql/migrations) |
| 115 | + |
| 116 | + if [[ "$ERROR" == *"--database-url"* ]]; then |
| 117 | + exit 0 |
| 118 | + else |
| 119 | + echo "Unexpected error from sqlx-cli: $ERROR" |
| 120 | + exit 1 |
| 121 | + fi |
| 122 | +
|
| 123 | + - name: Test Reversible Migrations |
| 124 | + env: |
| 125 | + DATABASE_URL: ${{ env.BASE_URL }}/test4 |
| 126 | + run: | |
| 127 | + cargo run -p sqlx-cli --no-default-features --features mysql -- \ |
| 128 | + db setup --source=test/mysql/migrations |
| 129 | + |
| 130 | + INFO_BEFORE=$(cargo run -p sqlx-cli --no-default-features --features mysql -- \ |
| 131 | + mig info --source=test/mysql/migrations) |
| 132 | + |
| 133 | + cargo run -p sqlx-cli --no-default-features --features mysql -- \ |
| 134 | + mig revert --target-version=-1 --source=test/mysql/migrations |
| 135 | + |
| 136 | + INFO_AFTER=$(cargo run -p sqlx-cli --no-default-features --features mysql -- \ |
| 137 | + mig info --source=test/mysql/migrations) |
| 138 | + |
| 139 | + if [[ "$INFO_BEFORE" == "$INFO_AFTER" ]]; then |
| 140 | + echo "Error: migration info is identical before and after migrating: $INFO_BEFORE" |
| 141 | + exit 1 |
| 142 | + fi |
| 143 | +
|
60 | 144 | build: |
61 | 145 | name: Build |
62 | 146 | runs-on: ${{ matrix.os }} |
|
0 commit comments