|
| 1 | +name: Pull Request |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + paths: # Only run when changes are made to rust code or root Cargo |
| 7 | + - "crates/**" |
| 8 | + - "lib/**" |
| 9 | + - "fuzz/**" |
| 10 | + - "xtask/**" |
| 11 | + - "Cargo.toml" |
| 12 | + - "Cargo.lock" |
| 13 | + - "rust-toolchain.toml" |
| 14 | + - "rustfmt.toml" |
| 15 | + |
| 16 | +concurrency: |
| 17 | + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }} |
| 18 | + cancel-in-progress: true |
| 19 | + |
| 20 | +env: |
| 21 | + RUSTFLAGS: -A dead_code |
| 22 | + RUST_LOG: info |
| 23 | + RUST_BACKTRACE: 1 |
| 24 | + RUSTUP_WINDOWS_PATH_ADD_BIN: 1 |
| 25 | + |
| 26 | +jobs: |
| 27 | + format: |
| 28 | + name: Format |
| 29 | + runs-on: ubuntu-latest |
| 30 | + steps: |
| 31 | + - name: Checkout PR branch |
| 32 | + uses: actions/checkout@v4 |
| 33 | + - name: Free Disk Space |
| 34 | + uses: ./.github/actions/free-disk-space |
| 35 | + - name: Install toolchain |
| 36 | + uses: moonrepo/setup-rust@v1 |
| 37 | + with: |
| 38 | + components: rustfmt |
| 39 | + bins: taplo-cli |
| 40 | + cache-base: main |
| 41 | + env: |
| 42 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + - name: Run format |
| 44 | + run: | |
| 45 | + cargo fmt --all --check |
| 46 | + taplo format --check |
| 47 | +
|
| 48 | + actionlint: |
| 49 | + name: Lint GitHub Actions |
| 50 | + runs-on: ubuntu-latest |
| 51 | + steps: |
| 52 | + - uses: actions/checkout@v4 |
| 53 | + - name: Download actionlint |
| 54 | + id: get_actionlint |
| 55 | + run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) |
| 56 | + shell: bash |
| 57 | + - name: Check workflow files |
| 58 | + run: ${{ steps.get_actionlint.outputs.executable }} -color |
| 59 | + shell: bash |
| 60 | + |
| 61 | + lint: |
| 62 | + name: Lint Project |
| 63 | + runs-on: ubuntu-latest |
| 64 | + services: |
| 65 | + postgres: |
| 66 | + image: postgres:latest |
| 67 | + env: |
| 68 | + POSTGRES_USER: postgres |
| 69 | + POSTGRES_PASSWORD: postgres |
| 70 | + POSTGRES_DB: postgres |
| 71 | + ports: |
| 72 | + - 5432:5432 |
| 73 | + steps: |
| 74 | + - name: Checkout PR Branch |
| 75 | + uses: actions/checkout@v4 |
| 76 | + with: |
| 77 | + submodules: true |
| 78 | + - name: Free Disk Space |
| 79 | + uses: ./.github/actions/free-disk-space |
| 80 | + - name: Install toolchain |
| 81 | + uses: moonrepo/setup-rust@v1 |
| 82 | + with: |
| 83 | + components: clippy |
| 84 | + cache-base: main |
| 85 | + env: |
| 86 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 87 | + - name: Run clippy |
| 88 | + run: | |
| 89 | + cargo clippy |
| 90 | + cargo run -p rules_check |
| 91 | +
|
| 92 | + # check-dependencies: |
| 93 | + # name: Check Dependencies |
| 94 | + # runs-on: ubuntu-latest |
| 95 | + # services: |
| 96 | + # postgres: |
| 97 | + # image: postgres:latest |
| 98 | + # env: |
| 99 | + # POSTGRES_USER: postgres |
| 100 | + # POSTGRES_PASSWORD: postgres |
| 101 | + # POSTGRES_DB: postgres |
| 102 | + # ports: |
| 103 | + # - 5432:5432 |
| 104 | + # steps: |
| 105 | + # - name: Checkout PR Branch |
| 106 | + # uses: actions/checkout@v4 |
| 107 | + # with: |
| 108 | + # submodules: true |
| 109 | + # - name: Free Disk Space |
| 110 | + # uses: ./.github/actions/free-disk-space |
| 111 | + # - name: Install toolchain |
| 112 | + # run: rustup toolchain install nightly |
| 113 | + # - name: Install udeps |
| 114 | + # run: cargo install cargo-udeps --locked |
| 115 | + # - name: Detect unused dependencies using udeps |
| 116 | + # run: cargo +nightly udeps --all-targets |
| 117 | + |
| 118 | + test: |
| 119 | + name: Test |
| 120 | + runs-on: ${{ matrix.os }} |
| 121 | + strategy: |
| 122 | + matrix: |
| 123 | + include: |
| 124 | + # reactive once we upgrade to the latest version of pg_query that is windows-compatible |
| 125 | + # - os: windows-latest |
| 126 | + - os: ubuntu-latest |
| 127 | + steps: |
| 128 | + - name: Checkout PR branch |
| 129 | + uses: actions/checkout@v4 |
| 130 | + with: |
| 131 | + submodules: true |
| 132 | + - name: Free Disk Space |
| 133 | + uses: ./.github/actions/free-disk-space |
| 134 | + - name: Install toolchain |
| 135 | + uses: moonrepo/setup-rust@v1 |
| 136 | + with: |
| 137 | + cache-base: main |
| 138 | + env: |
| 139 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 140 | + |
| 141 | + # running containers via `services` only works on linux |
| 142 | + # https://github.com/actions/runner/issues/1866 |
| 143 | + - name: Setup postgres |
| 144 | + uses: ikalnytskyi/action-setup-postgres@v7 |
| 145 | + - name: Run tests |
| 146 | + run: cargo test --workspace |
| 147 | + |
| 148 | + codegen: |
| 149 | + name: Check Codegen |
| 150 | + runs-on: ubuntu-latest |
| 151 | + services: |
| 152 | + postgres: |
| 153 | + image: postgres:latest |
| 154 | + env: |
| 155 | + POSTGRES_USER: postgres |
| 156 | + POSTGRES_PASSWORD: postgres |
| 157 | + POSTGRES_DB: postgres |
| 158 | + ports: |
| 159 | + - 5432:5432 |
| 160 | + steps: |
| 161 | + - name: Checkout PR branch |
| 162 | + uses: actions/checkout@v4 |
| 163 | + with: |
| 164 | + submodules: true |
| 165 | + - name: Free Disk Space |
| 166 | + uses: ./.github/actions/free-disk-space |
| 167 | + - name: Install toolchain |
| 168 | + uses: moonrepo/setup-rust@v1 |
| 169 | + with: |
| 170 | + cache-base: main |
| 171 | + env: |
| 172 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 173 | + - name: Run the analyser codegen |
| 174 | + run: cargo run -p xtask_codegen -- analyser |
| 175 | + - name: Run the configuration codegen |
| 176 | + run: cargo run -p xtask_codegen -- configuration |
| 177 | + - name: Check for git diff |
| 178 | + run: | |
| 179 | + if [[ $(git status --porcelain) ]]; then |
| 180 | + git status |
| 181 | + git diff |
| 182 | + exit 1 |
| 183 | + fi |
0 commit comments