microsoft/qdk
Publicmirrored from https://github.com/microsoft/qdkAvailable
.github/workflows/ci.yml
190lines · 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 | |
| 152 | runMemoryProfile: |
| 153 | name: run memory profile |
| 154 | runs-on: ubuntu-latest |
| 155 | steps: |
| 156 | - uses: actions/checkout@v2 |
| 157 | with: |
| 158 | ref: main |
| 159 | - uses: Swatinem/rust-cache@v2 |
| 160 | - run: | |
| 161 | MAIN_MEASUREMENT=$(cargo run --bin memtest) |
| 162 | echo "MAIN_MEASUREMENT<<EOF" >> $GITHUB_ENV |
| 163 | echo "$MAIN_MEASUREMENT" >> $GITHUB_ENV |
| 164 | echo "EOF" >> $GITHUB_ENV |
| 165 | - run: | |
| 166 | echo "${{env.MAIN_MEASUREMENT}}" |
| 167 | echo $MAIN_MEASUREMENT |
| 168 | |
| 169 | - uses: actions/checkout@v2 |
| 170 | - run: | |
| 171 | BRANCH_MEASUREMENT=$(cargo run --bin memtest) |
| 172 | echo "BRANCH_MEASUREMENT<<EOF" >> $GITHUB_ENV |
| 173 | echo "$BRANCH_MEASUREMENT" >> $GITHUB_ENV |
| 174 | echo "EOF" >> $GITHUB_ENV |
| 175 | - run: | |
| 176 | echo "${{env.BRANCH_MEASUREMENT}}" |
| 177 | echo $BRANCH_MEASUREMENT |
| 178 | - uses: actions/github-script@v6 |
| 179 | with: |
| 180 | script: | |
| 181 | github.rest.issues.createComment({ |
| 182 | issue_number: context.issue.number, |
| 183 | owner: context.repo.owner, |
| 184 | repo: context.repo.repo, |
| 185 | body: `## Memory Report for ${{ github.sha }} |
| 186 | | Test | This Branch | On Main | |
| 187 | |-----------------------------|-------------|----------| |
| 188 | | compile core + standard lib | ${{ env.BRANCH_MEASUREMENT }} bytes | ${{ env.MAIN_MEASUREMENT }} bytes |` |
| 189 | }) |
| 190 | if: ${{ github.base_ref != null }} |
| 191 | |