microsoft/qdk

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.1.3

Branches

Tags

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

Clone

HTTPS

Download ZIP

.github/workflows/ci.yml

224lines · 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-14]
78 is_pr:
79 - ${{ github.event_name == 'pull_request' }}
80 exclude:
81 - os: macos-14
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 x86_64-apple-darwin
98 if: matrix.os == 'macos-14'
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-14]
117 is_pr:
118 - ${{ github.event_name == 'pull_request' }}
119 exclude:
120 - os: macos-14
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 x86_64-apple-darwin
137 if: matrix.os == 'macos-14'
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 --pip --widgets --integration-tests
149
150 runBenchmark:
151 name: run benchmark
152 runs-on: ubuntu-latest
153 permissions:
154 contents: read
155 pull-requests: write
156 steps:
157 - uses: actions/checkout@v3
158 - uses: boa-dev/criterion-compare-action@v3
159 with:
160 branchName: ${{ github.base_ref }}
161 cwd: "compiler/qsc"
162 if: ${{ github.base_ref != null }}
163
164 runMemoryProfile:
165 name: run memory profile
166 runs-on: ubuntu-latest
167 permissions:
168 contents: read
169 pull-requests: write
170 steps:
171 - uses: actions/checkout@v2
172 with:
173 ref: main
174 - uses: Swatinem/rust-cache@v2
175 - run: |
176 MAIN_MEASUREMENT=$(cargo run --bin memtest)
177 echo "MAIN_MEASUREMENT<<EOF" >> $GITHUB_ENV
178 echo "$MAIN_MEASUREMENT" >> $GITHUB_ENV
179 echo "EOF" >> $GITHUB_ENV
180 - run: |
181 echo "${{env.MAIN_MEASUREMENT}}"
182 echo $MAIN_MEASUREMENT
183
184 - uses: actions/checkout@v2
185 - run: |
186 BRANCH_MEASUREMENT=$(cargo run --bin memtest)
187 echo "BRANCH_MEASUREMENT<<EOF" >> $GITHUB_ENV
188 echo "$BRANCH_MEASUREMENT" >> $GITHUB_ENV
189 echo "EOF" >> $GITHUB_ENV
190 - run: |
191 echo "${{env.BRANCH_MEASUREMENT}}"
192 echo $BRANCH_MEASUREMENT
193 - uses: actions/github-script@v6
194 with:
195 script: |
196 if (${{ env.BRANCH_MEASUREMENT }} !== ${{ env.MAIN_MEASUREMENT }}) {
197 try {
198 await github.rest.issues.createComment({
199 issue_number: context.issue.number,
200 owner: context.repo.owner,
201 repo: context.repo.repo,
202 body: `_Change in memory usage detected by benchmark._
203 ## Memory Report for ${{ github.sha }}
204 | Test | This Branch | On Main |
205 |-----------------------------|-------------|----------|
206 | compile core + standard lib | ${{ env.BRANCH_MEASUREMENT }} bytes | ${{ env.MAIN_MEASUREMENT }} bytes |`
207 })
208 } catch (err) {
209 core.warning(`Failed writing comment on GitHub issue: ${err}`)
210 }
211 } else {
212 console.log("no change in memory usage detected by benchmark");
213 }
214 if: ${{ github.base_ref != null }}
215
216 status-check:
217 name: Status Check
218 needs: [format, clippy, web-check, build, integration-tests, runBenchmark, runMemoryProfile]
219 runs-on: ubuntu-latest
220 if: failure()
221 steps:
222 - run: |
223 echo "::error Build failed"
224 exit 1
225