microsoft/qdk

Public

mirrored fromhttps://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
alex/lsp

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

.github/workflows/ci.yml

218lines · modecode

1name: CI Build and Test
2
3on:
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
15concurrency:
16 group: ${{ github.head_ref || github.run_id }}
17 cancel-in-progress: true
18
19env:
20 CARGO_TERM_COLOR: always
21 NODE_VERSION: "18.17.1"
22 PYTHON_VERSION: "3.11"
23 RUST_TOOLCHAIN_VERSION: "1.75"
24 RUST_TOOLCHAIN_COMPONENTS: rustfmt clippy
25
26jobs:
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 is_pr:
79 - ${{ github.event_name == 'pull_request' }}
80 exclude:
81 - os: macos-latest
82 is_pr: true
83
84 runs-on: ${{matrix.os}}
85
86 steps:
87 - uses: actions/checkout@v3
88 with:
89 submodules: "true"
90 - name: Setup rust toolchain
91 uses: ./.github/actions/toolchains/rust
92 with:
93 toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }}
94 components: ${{ env.RUST_TOOLCHAIN_COMPONENTS }}
95 - name: Add additional Rust targets
96 run: |
97 rustup target add aarch64-apple-darwin
98 if: matrix.os == 'macos-latest'
99 - uses: actions/setup-python@v4
100 with:
101 python-version: ${{ env.PYTHON_VERSION }}
102 - uses: actions/setup-node@v3
103 with:
104 node-version: ${{ env.NODE_VERSION }}
105 - uses: Swatinem/rust-cache@v2
106 - name: Prereqs
107 run: python ./prereqs.py --install
108 - name: Build and Test
109 run: python ./build.py --no-check
110
111 integration-tests:
112 name: Integration tests
113 timeout-minutes: 15
114 strategy:
115 matrix:
116 os: [windows-latest, ubuntu-latest, macos-latest]
117 is_pr:
118 - ${{ github.event_name == 'pull_request' }}
119 exclude:
120 - os: macos-latest
121 is_pr: true
122
123 runs-on: ${{matrix.os}}
124
125 steps:
126 - uses: actions/checkout@v3
127 with:
128 submodules: "true"
129 - name: Setup rust toolchain
130 uses: ./.github/actions/toolchains/rust
131 with:
132 toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }}
133 components: ${{ env.RUST_TOOLCHAIN_COMPONENTS }}
134 - name: Add additional Rust targets
135 run: |
136 rustup target add aarch64-apple-darwin
137 if: matrix.os == 'macos-latest'
138 - uses: actions/setup-python@v4
139 with:
140 python-version: ${{ env.PYTHON_VERSION }}
141 - uses: actions/setup-node@v3
142 with:
143 node-version: ${{ env.NODE_VERSION }}
144 - uses: Swatinem/rust-cache@v2
145 - name: Prereqs
146 run: python ./prereqs.py --install
147 - name: Run integration tests
148 run: python ./build.py --no-check --no-test --wasm --npm --vscode --integration-tests
149
150 runBenchmark:
151 name: run benchmark
152 runs-on: ubuntu-latest
153 steps:
154 - uses: actions/checkout@v3
155 - uses: boa-dev/criterion-compare-action@v3
156 with:
157 branchName: ${{ github.base_ref }}
158 cwd: "compiler/qsc"
159 if: ${{ github.base_ref != null }}
160
161 runMemoryProfile:
162 name: run memory profile
163 runs-on: ubuntu-latest
164 steps:
165 - uses: actions/checkout@v2
166 with:
167 ref: main
168 - uses: Swatinem/rust-cache@v2
169 - run: |
170 MAIN_MEASUREMENT=$(cargo run --bin memtest)
171 echo "MAIN_MEASUREMENT<<EOF" >> $GITHUB_ENV
172 echo "$MAIN_MEASUREMENT" >> $GITHUB_ENV
173 echo "EOF" >> $GITHUB_ENV
174 - run: |
175 echo "${{env.MAIN_MEASUREMENT}}"
176 echo $MAIN_MEASUREMENT
177
178 - uses: actions/checkout@v2
179 - run: |
180 BRANCH_MEASUREMENT=$(cargo run --bin memtest)
181 echo "BRANCH_MEASUREMENT<<EOF" >> $GITHUB_ENV
182 echo "$BRANCH_MEASUREMENT" >> $GITHUB_ENV
183 echo "EOF" >> $GITHUB_ENV
184 - run: |
185 echo "${{env.BRANCH_MEASUREMENT}}"
186 echo $BRANCH_MEASUREMENT
187 - uses: actions/github-script@v6
188 with:
189 script: |
190 if (${{ env.BRANCH_MEASUREMENT }} !== ${{ env.MAIN_MEASUREMENT }}) {
191 try {
192 await github.rest.issues.createComment({
193 issue_number: context.issue.number,
194 owner: context.repo.owner,
195 repo: context.repo.repo,
196 body: `_Change in memory usage detected by benchmark._
197 ## Memory Report for ${{ github.sha }}
198 | Test | This Branch | On Main |
199 |-----------------------------|-------------|----------|
200 | compile core + standard lib | ${{ env.BRANCH_MEASUREMENT }} bytes | ${{ env.MAIN_MEASUREMENT }} bytes |`
201 })
202 } catch (err) {
203 core.warning(`Failed writing comment on GitHub issue: ${err}`)
204 }
205 } else {
206 console.log("no change in memory usage detected by benchmark");
207 }
208 if: ${{ github.base_ref != null }}
209
210 status-check:
211 name: Status Check
212 needs: [format, clippy, web-check, build, integration-tests, runBenchmark, runMemoryProfile]
213 runs-on: ubuntu-latest
214 if: failure()
215 steps:
216 - run: |
217 echo "::error Build failed"
218 exit 1
219