microsoft/qdk
Publicmirrored fromhttps://github.com/microsoft/qdkAvailable
.github/workflows/ci.yml
196lines · 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: "20.18.2" |
| 22 | PYTHON_VERSION: "3.11" |
| 23 | RUST_TOOLCHAIN_VERSION: "1.88" |
| 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@v3 |
| 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@v3 |
| 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: Swatinem/rust-cache@v2 |
| 55 | - name: Clippy Lints |
| 56 | run: cargo clippy --all-targets --all-features -- -D warnings |
| 57 | |
| 58 | format-qsc: |
| 59 | name: Format Q# Files |
| 60 | runs-on: ubuntu-latest |
| 61 | steps: |
| 62 | - uses: actions/checkout@v3 |
| 63 | with: |
| 64 | submodules: "true" |
| 65 | - name: Setup rust toolchain |
| 66 | uses: ./.github/actions/toolchains/rust |
| 67 | with: |
| 68 | toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} |
| 69 | components: ${{ env.RUST_TOOLCHAIN_COMPONENTS }} |
| 70 | - name: Check Formatting for Libraries and Samples |
| 71 | run: cargo run --release --bin qsc_formatter -- ./library/ ./samples/ -r |
| 72 | |
| 73 | web-check: |
| 74 | name: Check web files |
| 75 | runs-on: ubuntu-latest |
| 76 | steps: |
| 77 | - uses: actions/checkout@v3 |
| 78 | with: |
| 79 | submodules: "true" |
| 80 | - uses: actions/setup-node@v3 |
| 81 | with: |
| 82 | node-version: ${{ env.NODE_VERSION }} |
| 83 | - name: npm install |
| 84 | run: npm install |
| 85 | - name: npm check |
| 86 | run: npm run check |
| 87 | |
| 88 | build: |
| 89 | name: Build and test |
| 90 | strategy: |
| 91 | matrix: |
| 92 | os: [windows-latest, ubuntu-latest, macos-latest] |
| 93 | |
| 94 | runs-on: ${{matrix.os}} |
| 95 | |
| 96 | steps: |
| 97 | - uses: actions/checkout@v3 |
| 98 | with: |
| 99 | submodules: "true" |
| 100 | - name: Setup rust toolchain |
| 101 | uses: ./.github/actions/toolchains/rust |
| 102 | with: |
| 103 | toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} |
| 104 | components: ${{ env.RUST_TOOLCHAIN_COMPONENTS }} |
| 105 | - name: Add additional Rust targets |
| 106 | run: | |
| 107 | rustup target add x86_64-apple-darwin |
| 108 | if: matrix.os == 'macos-latest' |
| 109 | - uses: actions/setup-python@v4 |
| 110 | with: |
| 111 | python-version: ${{ env.PYTHON_VERSION }} |
| 112 | - uses: actions/setup-node@v3 |
| 113 | with: |
| 114 | node-version: ${{ env.NODE_VERSION }} |
| 115 | - uses: Swatinem/rust-cache@v2 |
| 116 | - name: Prereqs |
| 117 | run: python ./prereqs.py --install |
| 118 | - name: Build and Test |
| 119 | run: python ./build.py --no-check --wasm --npm --vscode --play --pip --widgets --jupyterlab --qdk |
| 120 | |
| 121 | unit-tests: |
| 122 | name: Rust Unit tests |
| 123 | strategy: |
| 124 | matrix: |
| 125 | os: [windows-latest, ubuntu-latest, macos-latest] |
| 126 | |
| 127 | runs-on: ${{matrix.os}} |
| 128 | |
| 129 | steps: |
| 130 | - uses: actions/checkout@v3 |
| 131 | with: |
| 132 | submodules: "true" |
| 133 | - name: Setup rust toolchain |
| 134 | uses: ./.github/actions/toolchains/rust |
| 135 | with: |
| 136 | toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} |
| 137 | components: ${{ env.RUST_TOOLCHAIN_COMPONENTS }} |
| 138 | - name: Add additional Rust targets |
| 139 | run: | |
| 140 | rustup target add x86_64-apple-darwin |
| 141 | if: matrix.os == 'macos-latest' |
| 142 | - uses: actions/setup-python@v4 |
| 143 | with: |
| 144 | python-version: ${{ env.PYTHON_VERSION }} |
| 145 | - uses: actions/setup-node@v3 |
| 146 | with: |
| 147 | node-version: ${{ env.NODE_VERSION }} |
| 148 | - uses: Swatinem/rust-cache@v2 |
| 149 | - name: Prereqs |
| 150 | run: python ./prereqs.py --install |
| 151 | - name: Build and Test |
| 152 | run: python ./build.py --no-check --cli |
| 153 | |
| 154 | integration-tests: |
| 155 | name: Integration tests |
| 156 | timeout-minutes: 30 |
| 157 | strategy: |
| 158 | matrix: |
| 159 | os: [windows-latest, ubuntu-latest, macos-latest] |
| 160 | |
| 161 | runs-on: ${{matrix.os}} |
| 162 | |
| 163 | steps: |
| 164 | - uses: actions/checkout@v3 |
| 165 | with: |
| 166 | submodules: "true" |
| 167 | - name: Setup rust toolchain |
| 168 | uses: ./.github/actions/toolchains/rust |
| 169 | with: |
| 170 | toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} |
| 171 | components: ${{ env.RUST_TOOLCHAIN_COMPONENTS }} |
| 172 | - name: Add additional Rust targets |
| 173 | run: | |
| 174 | rustup target add x86_64-apple-darwin |
| 175 | if: matrix.os == 'macos-latest' |
| 176 | - uses: actions/setup-python@v4 |
| 177 | with: |
| 178 | python-version: ${{ env.PYTHON_VERSION }} |
| 179 | - uses: actions/setup-node@v3 |
| 180 | with: |
| 181 | node-version: ${{ env.NODE_VERSION }} |
| 182 | - uses: Swatinem/rust-cache@v2 |
| 183 | - name: Prereqs |
| 184 | run: python ./prereqs.py --install |
| 185 | - name: Run integration tests |
| 186 | run: python ./build.py --no-check --no-test --wasm --npm --vscode --pip --widgets --qdk --integration-tests |
| 187 | |
| 188 | status-check: |
| 189 | name: Status Check |
| 190 | needs: [format, clippy, web-check, build, unit-tests, format-qsc, integration-tests] |
| 191 | runs-on: ubuntu-latest |
| 192 | if: failure() |
| 193 | steps: |
| 194 | - run: | |
| 195 | echo "::error Build failed" |
| 196 | exit 1 |