microsoft/qdk
Publicmirrored fromhttps://github.com/microsoft/qdkAvailable
.github/workflows/ci.yml
213lines · modecode
| 1 | name: CI Build and Test |
| 2 | |
| 3 | on: |
| 4 | pull_request: |
| 5 | branches: |
| 6 | - main |
| 7 | - "feature/**" |
| 8 | - "release/**" |
| 9 | merge_group: |
| 10 | workflow_dispatch: |
| 11 | |
| 12 | # Cancel in-progress run when a pull request is updated |
| 13 | # Code taken from: |
| 14 | # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-a-fallback-value |
| 15 | concurrency: |
| 16 | group: ${{ github.head_ref || github.run_id }} |
| 17 | cancel-in-progress: true |
| 18 | |
| 19 | env: |
| 20 | CARGO_TERM_COLOR: always |
| 21 | NODE_VERSION: "22.14.0" |
| 22 | PYTHON_VERSION: "3.11" |
| 23 | RUST_TOOLCHAIN_VERSION: "1.93" |
| 24 | RUST_TOOLCHAIN_COMPONENTS: rustfmt clippy |
| 25 | |
| 26 | jobs: |
| 27 | format: |
| 28 | name: Format |
| 29 | runs-on: ubuntu-latest |
| 30 | steps: |
| 31 | - uses: actions/checkout@v6 |
| 32 | with: |
| 33 | submodules: "true" |
| 34 | - name: Setup rust toolchain |
| 35 | uses: ./.github/actions/toolchains/rust |
| 36 | with: |
| 37 | toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} |
| 38 | components: ${{ env.RUST_TOOLCHAIN_COMPONENTS }} |
| 39 | - name: Check Formatting |
| 40 | run: cargo fmt --all -- --check |
| 41 | |
| 42 | clippy: |
| 43 | name: Clippy |
| 44 | runs-on: ubuntu-latest |
| 45 | steps: |
| 46 | - uses: actions/checkout@v6 |
| 47 | with: |
| 48 | submodules: "true" |
| 49 | - name: Setup rust toolchain |
| 50 | uses: ./.github/actions/toolchains/rust |
| 51 | with: |
| 52 | toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} |
| 53 | components: ${{ env.RUST_TOOLCHAIN_COMPONENTS }} |
| 54 | - uses: actions/cache@v4 |
| 55 | with: |
| 56 | path: | |
| 57 | ~/.cargo/bin/ |
| 58 | ~/.cargo/registry/index/ |
| 59 | ~/.cargo/registry/cache/ |
| 60 | ~/.cargo/git/db/ |
| 61 | target/ |
| 62 | key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 63 | - name: Clippy Lints |
| 64 | run: cargo clippy --all-targets --all-features -- -D warnings |
| 65 | |
| 66 | format-qsc: |
| 67 | name: Format Q# Files |
| 68 | runs-on: ubuntu-latest |
| 69 | steps: |
| 70 | - uses: actions/checkout@v6 |
| 71 | with: |
| 72 | submodules: "true" |
| 73 | - name: Setup rust toolchain |
| 74 | uses: ./.github/actions/toolchains/rust |
| 75 | with: |
| 76 | toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} |
| 77 | components: ${{ env.RUST_TOOLCHAIN_COMPONENTS }} |
| 78 | - name: Check Formatting for Libraries and Samples |
| 79 | run: cargo run --release --bin qsc_formatter -- ./library/ ./samples/ -r |
| 80 | |
| 81 | web-check: |
| 82 | name: Check web files |
| 83 | runs-on: ubuntu-latest |
| 84 | steps: |
| 85 | - uses: actions/checkout@v6 |
| 86 | with: |
| 87 | submodules: "true" |
| 88 | - uses: actions/setup-node@v6 |
| 89 | with: |
| 90 | node-version: ${{ env.NODE_VERSION }} |
| 91 | - name: npm install |
| 92 | run: npm install |
| 93 | - name: npm check |
| 94 | run: npm run check |
| 95 | |
| 96 | build: |
| 97 | name: Build and test |
| 98 | runs-on: ubuntu-latest |
| 99 | |
| 100 | steps: |
| 101 | - uses: actions/checkout@v6 |
| 102 | with: |
| 103 | submodules: "true" |
| 104 | - name: Setup rust toolchain |
| 105 | uses: ./.github/actions/toolchains/rust |
| 106 | with: |
| 107 | toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} |
| 108 | components: ${{ env.RUST_TOOLCHAIN_COMPONENTS }} |
| 109 | - uses: actions/setup-python@v6 |
| 110 | with: |
| 111 | python-version: ${{ env.PYTHON_VERSION }} |
| 112 | - uses: actions/setup-node@v6 |
| 113 | with: |
| 114 | node-version: ${{ env.NODE_VERSION }} |
| 115 | - uses: actions/cache@v4 |
| 116 | with: |
| 117 | path: | |
| 118 | ~/.cargo/bin/ |
| 119 | ~/.cargo/registry/index/ |
| 120 | ~/.cargo/registry/cache/ |
| 121 | ~/.cargo/git/db/ |
| 122 | target/ |
| 123 | key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 124 | - name: Prereqs |
| 125 | run: python ./prereqs.py --install |
| 126 | - name: Build and Test |
| 127 | run: python ./build.py --no-check --wasm --npm --vscode --play --pip --widgets --jupyterlab --qdk |
| 128 | |
| 129 | unit-tests: |
| 130 | name: Rust Unit tests |
| 131 | runs-on: ubuntu-latest |
| 132 | |
| 133 | steps: |
| 134 | - uses: actions/checkout@v6 |
| 135 | with: |
| 136 | submodules: "true" |
| 137 | - name: Setup rust toolchain |
| 138 | uses: ./.github/actions/toolchains/rust |
| 139 | with: |
| 140 | toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} |
| 141 | components: ${{ env.RUST_TOOLCHAIN_COMPONENTS }} |
| 142 | - uses: actions/setup-python@v6 |
| 143 | with: |
| 144 | python-version: ${{ env.PYTHON_VERSION }} |
| 145 | - uses: actions/setup-node@v6 |
| 146 | with: |
| 147 | node-version: ${{ env.NODE_VERSION }} |
| 148 | - uses: actions/cache@v4 |
| 149 | with: |
| 150 | path: | |
| 151 | ~/.cargo/bin/ |
| 152 | ~/.cargo/registry/index/ |
| 153 | ~/.cargo/registry/cache/ |
| 154 | ~/.cargo/git/db/ |
| 155 | target/ |
| 156 | key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 157 | - name: Prereqs |
| 158 | run: python ./prereqs.py --install |
| 159 | - name: Build and Test |
| 160 | run: python ./build.py --no-check --cli |
| 161 | |
| 162 | integration-tests: |
| 163 | name: Integration tests |
| 164 | timeout-minutes: 40 |
| 165 | runs-on: ubuntu-latest |
| 166 | |
| 167 | steps: |
| 168 | - uses: actions/checkout@v6 |
| 169 | with: |
| 170 | submodules: "true" |
| 171 | - name: Setup rust toolchain |
| 172 | uses: ./.github/actions/toolchains/rust |
| 173 | with: |
| 174 | toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} |
| 175 | components: ${{ env.RUST_TOOLCHAIN_COMPONENTS }} |
| 176 | - uses: actions/setup-python@v6 |
| 177 | with: |
| 178 | python-version: ${{ env.PYTHON_VERSION }} |
| 179 | - uses: actions/setup-node@v6 |
| 180 | with: |
| 181 | node-version: ${{ env.NODE_VERSION }} |
| 182 | - uses: actions/cache@v4 |
| 183 | with: |
| 184 | path: | |
| 185 | ~/.cargo/bin/ |
| 186 | ~/.cargo/registry/index/ |
| 187 | ~/.cargo/registry/cache/ |
| 188 | ~/.cargo/git/db/ |
| 189 | target/ |
| 190 | key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 191 | - name: Prereqs |
| 192 | run: python ./prereqs.py --install |
| 193 | - name: Run integration tests |
| 194 | run: python ./build.py --no-check --no-test --wasm --npm --vscode --pip --widgets --qdk --integration-tests |
| 195 | |
| 196 | status-check: |
| 197 | name: Status Check |
| 198 | needs: |
| 199 | [ |
| 200 | format, |
| 201 | clippy, |
| 202 | web-check, |
| 203 | build, |
| 204 | unit-tests, |
| 205 | format-qsc, |
| 206 | integration-tests, |
| 207 | ] |
| 208 | runs-on: ubuntu-latest |
| 209 | if: failure() |
| 210 | steps: |
| 211 | - run: | |
| 212 | echo "::error Build failed" |
| 213 | exit 1 |
| 214 | |