microsoft/qdk
Publicmirrored fromhttps://github.com/microsoft/qdkAvailable
.github/workflows/ci.yml
150lines · 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: "18.17.1" |
| 22 | PYTHON_VERSION: "3.11" |
| 23 | RUST_TOOLCHAIN_VERSION: "1.73" |
| 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 | web-check: |
| 59 | name: Check web files |
| 60 | runs-on: ubuntu-latest |
| 61 | steps: |
| 62 | - uses: actions/checkout@v3 |
| 63 | with: |
| 64 | submodules: "true" |
| 65 | - uses: actions/setup-node@v3 |
| 66 | with: |
| 67 | node-version: ${{ env.NODE_VERSION }} |
| 68 | - name: npm install |
| 69 | run: npm install |
| 70 | - name: npm check |
| 71 | run: npm run check |
| 72 | |
| 73 | build: |
| 74 | name: Build and test |
| 75 | strategy: |
| 76 | matrix: |
| 77 | os: [windows-latest, ubuntu-latest, macos-latest] |
| 78 | |
| 79 | runs-on: ${{matrix.os}} |
| 80 | |
| 81 | steps: |
| 82 | - uses: actions/checkout@v3 |
| 83 | with: |
| 84 | submodules: "true" |
| 85 | - name: Setup rust toolchain |
| 86 | uses: ./.github/actions/toolchains/rust |
| 87 | with: |
| 88 | toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} |
| 89 | components: ${{ env.RUST_TOOLCHAIN_COMPONENTS }} |
| 90 | - name: Add additional Rust targets |
| 91 | run: | |
| 92 | rustup target add aarch64-apple-darwin |
| 93 | if: matrix.os == 'macos-latest' |
| 94 | - uses: actions/setup-python@v4 |
| 95 | with: |
| 96 | python-version: ${{ env.PYTHON_VERSION }} |
| 97 | - uses: actions/setup-node@v3 |
| 98 | with: |
| 99 | node-version: ${{ env.NODE_VERSION }} |
| 100 | - uses: Swatinem/rust-cache@v2 |
| 101 | - name: Prereqs |
| 102 | run: python ./prereqs.py --install |
| 103 | - name: Build and Test |
| 104 | run: python ./build.py --no-check |
| 105 | |
| 106 | integration-tests: |
| 107 | name: Integration tests |
| 108 | if: ${{ ! github.event.pull_request }} |
| 109 | timeout-minutes: 15 |
| 110 | strategy: |
| 111 | matrix: |
| 112 | os: [windows-latest, ubuntu-latest, macos-latest] |
| 113 | |
| 114 | runs-on: ${{matrix.os}} |
| 115 | |
| 116 | steps: |
| 117 | - uses: actions/checkout@v3 |
| 118 | with: |
| 119 | submodules: "true" |
| 120 | - name: Setup rust toolchain |
| 121 | uses: ./.github/actions/toolchains/rust |
| 122 | with: |
| 123 | toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} |
| 124 | components: ${{ env.RUST_TOOLCHAIN_COMPONENTS }} |
| 125 | - name: Add additional Rust targets |
| 126 | run: | |
| 127 | rustup target add aarch64-apple-darwin |
| 128 | if: matrix.os == 'macos-latest' |
| 129 | - uses: actions/setup-python@v4 |
| 130 | with: |
| 131 | python-version: ${{ env.PYTHON_VERSION }} |
| 132 | - uses: actions/setup-node@v3 |
| 133 | with: |
| 134 | node-version: ${{ env.NODE_VERSION }} |
| 135 | - uses: Swatinem/rust-cache@v2 |
| 136 | - name: Prereqs |
| 137 | run: python ./prereqs.py --install |
| 138 | - name: Run integration tests |
| 139 | run: python ./build.py --no-check --no-test --wasm --npm --vscode --integration-tests |
| 140 | |
| 141 | runBenchmark: |
| 142 | name: run benchmark |
| 143 | runs-on: ubuntu-latest |
| 144 | steps: |
| 145 | - uses: actions/checkout@v3 |
| 146 | - uses: boa-dev/criterion-compare-action@v3 |
| 147 | with: |
| 148 | branchName: ${{ github.base_ref }} |
| 149 | cwd: "compiler/qsc" |
| 150 | if: ${{ github.base_ref != null }} |
| 151 | |