rust-code-analysis-code-split 0.0.26-cs.0

Fork of mozilla/rust-code-analysis bumped to tree-sitter 0.26 for use by code-split. Computes complexity metrics (cyclomatic, cognitive, Halstead, MI, LOC).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
version: 1
policy:
  pullRequests: public
tasks:
  $let:
    user: ${event.sender.login}

    head_branch:
      $if: 'tasks_for == "github-pull-request"'
      then: ${event.pull_request.head.ref}
      else:
        $if: 'tasks_for == "github-push"'
        then: ${event.ref}
        else: ${event.release.target_commitish}

    head_rev:
      $if: 'tasks_for == "github-pull-request"'
      then: ${event.pull_request.head.sha}
      else:
        $if: 'tasks_for == "github-push"'
        then: ${event.after}
        else: ${event.release.tag_name}

    repository:
      $if: 'tasks_for == "github-pull-request"'
      then: ${event.pull_request.head.repo.html_url}
      else: ${event.repository.html_url}

    taskboot_image: "mozilla/taskboot:0.4.3"
  in:
    $if: 'tasks_for == "github-push" || (tasks_for == "github-pull-request" && event["action"] in ["opened", "reopened", "synchronize"])'
    then:
      - taskId: {$eval: as_slugid("lint_test_task")}
        created: {$fromNow: ''}
        deadline: {$fromNow: '1 hour'}
        provisionerId: proj-relman
        workerType: ci
        payload:
          maxRunTime: 3600
          image: "rust:bookworm"
          command:
            - "/bin/bash"
            - "-cxe"
            - |-
              apt update
              apt install -y python3-full
              rustup component add clippy rustfmt
              rustup toolchain install nightly
              curl -L https://github.com/est31/cargo-udeps/releases/download/v0.1.55/cargo-udeps-v0.1.55-x86_64-unknown-linux-gnu.tar.gz | tar xz -C /usr/local/cargo/bin --strip-components 2
              curl -L https://github.com/rustsec/rustsec/releases/download/cargo-audit%2Fv0.21.2/cargo-audit-x86_64-unknown-linux-musl-v0.21.2.tgz | tar xzv -C /usr/local/cargo/bin --strip-components 1
              git clone --quiet ${repository}
              cd rust-code-analysis
              git -c advice.detachedHead=false checkout ${head_rev}
              git submodule update --init
              python3 -m venv myenv
              . myenv/bin/activate
              pip3 install --quiet pre-commit
              # FIXME: Remove the line below when fmt is fixed in .pre-commit-config.yaml
              cargo fmt -- --check --verbose
              pre-commit run -a --show-diff-on-failure
              pre-commit run --show-diff-on-failure -c .pre-commit-audit-config.yaml
              cargo test --workspace --verbose --all-features --no-fail-fast -- --nocapture
              cd enums
              cargo build --verbose --all-features
        metadata:
          name: rust-code-analysis lint and test
          description: rust-code-analysis lint and test
          owner: cdenizet@mozilla.com
          source: ${repository}/raw/${head_rev}/.taskcluster.yml

      - taskId: {$eval: as_slugid("build_documentation")}
        created: {$fromNow: ''}
        deadline: {$fromNow: '2 hour'}
        provisionerId: proj-relman
        workerType: ci
        payload:
          maxRunTime: 3600
          image: "rust:bookworm"
          command:
            - "/bin/bash"
            - "-cxe"
            - |-
              git clone --quiet ${repository}
              cd rust-code-analysis
              git -c advice.detachedHead=false checkout ${head_rev}
              cargo install mdbook
              cargo doc --release
              cd rust-code-analysis-book
              mdbook build
              tar -zvcf /book.tar.gz book/
          artifacts:
            public/book.tar.gz:
              expires: {$fromNow: '2 weeks'}
              path: /book.tar.gz
              type: file
        metadata:
          name: rust-code-analysis documentation
          description: rust-code-analysis build documentation
          owner: cdenizet@mozilla.com
          source: ${repository}/raw/${head_rev}/.taskcluster.yml

      - taskId: {$eval: as_slugid("ccov_test_task")}
        created: {$fromNow: ''}
        deadline: {$fromNow: '1 hour'}
        provisionerId: proj-relman
        workerType: ci
        payload:
          maxRunTime: 3600
          image: "rust:bookworm"
          env:
            CODECOV_TOKEN: 4df01912-087e-489a-be28-25aa911cb9d2
            CARGO_INCREMENTAL: "0"
            RUSTFLAGS: -Cinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off
            RUSTDOCFLAGS: -Cinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off
            LLVM_PROFILE_FILE: rust-code-analysis-%p-%m.profraw
          command:
            - "/bin/bash"
            - "-cxe"
            - |-
              apt-get -qq update
              apt-get -qq install -y zip
              curl -L https://github.com/mozilla/grcov/releases/download/v0.8.6/grcov-v0.8.6-x86_64-unknown-linux-gnu.tar.gz | tar xz
              rustup component add llvm-tools-preview
              git clone --quiet ${repository}
              cd rust-code-analysis
              git -c advice.detachedHead=false checkout ${head_rev}
              git submodule update --init
              cargo test --workspace --verbose --all-features --target x86_64-unknown-linux-gnu
              ../grcov . --binary-path ./target/ -s . -t lcov --llvm --branch --ignore-not-existing --ignore '/*' -o lcov.info
              bash <(curl -s https://codecov.io/bash) -f lcov.info
        metadata:
          name: rust-code-analysis grcov test
          description: rust-code-analysis grcov test
          owner: cdenizet@mozilla.com
          source: ${repository}/raw/${head_rev}/.taskcluster.yml

      - taskId: {$eval: as_slugid("windows_test_task")}
        created: {$fromNow: ''}
        deadline: {$fromNow: '1 hour'}
        provisionerId: proj-relman
        workerType: win2022
        payload:
          maxRunTime: 3600
          command:
            - set VSWHERE=%programfiles(x86)%\Microsoft Visual Studio\Installer
            - set VS_BINS=VC\Tools\MSVC\*\bin\Hostx64\x64
            - set RUSTUP_INIT_PATH=%CD%\rustup-init
            - set CARGO_PATH=%USERPROFILE%\.cargo\bin
            - set PATH=%RUSTUP_INIT_PATH%;%CARGO_PATH%;%VSWHERE%;%PATH%
            - set VSWHERE_CMD=vswhere -latest -products * -find %VS_BINS%
            - FOR /F "tokens=*" %%o IN ('%VSWHERE_CMD%') do (SET LIB_PATH=%%o)
            - set PATH=%LIB_PATH%;%PATH%
            - rustup-init -yv --default-toolchain stable ^
                              --default-host x86_64-pc-windows-msvc
            - git config --global core.autocrlf input
            - git clone --quiet ${repository}
            - cd rust-code-analysis
            - git -c advice.detachedHead=false checkout ${head_rev}
            - git submodule update --init
            - cargo test --workspace --verbose --all-features --no-fail-fast -- --nocapture
          mounts:
            - content:
                url: https://win.rustup.rs/
              file: rustup-init\rustup-init.exe
        metadata:
          name: rust-code-analysis windows test
          description: rust-code-analysis windows test
          owner: cdenizet@mozilla.com
          source: ${repository}/raw/${head_rev}/.taskcluster.yml

      - taskId: {$eval: as_slugid("check_tree_sitter_mozcpp")}
        dependencies:
           - {$eval: as_slugid("lint_test_task")}
           - {$eval: as_slugid("windows_test_task")}
        created: {$fromNow: ''}
        deadline: {$fromNow: '3 hours'}
        provisionerId: proj-relman
        workerType: ci
        payload:
          maxRunTime: 10800
          image: "rust:bookworm"
          command:
            - "/bin/bash"
            - "-cxe"
            - |-
              git clone --quiet ${repository}
              cd rust-code-analysis
              git -c advice.detachedHead=false checkout ${head_rev}
              ./check-grammars-crates.sh tree-sitter-mozcpp
          cache:
            rust-code-analysis-mozilla-central-repository: /cache
          artifacts:
            public/json-diffs-and-minimal-tests-mozcpp.tar.gz:
              expires: {$fromNow: '2 weeks'}
              path: /tmp/json-diffs-and-minimal-tests-mozcpp.tar.gz
              type: file
        scopes:
          - "docker-worker:cache:rust-code-analysis-mozilla-central-repository"
        metadata:
          name: rust-code-analysis check tree-sitter-mozcpp
          description: rust-code-analysis check tree-sitter-mozcpp grammar
          owner: cdenizet@mozilla.com
          source: ${repository}/raw/${head_rev}/.taskcluster.yml

      - taskId: {$eval: as_slugid("check_tree_sitter_mozjs")}
        dependencies:
           - {$eval: as_slugid("lint_test_task")}
           - {$eval: as_slugid("windows_test_task")}
        created: {$fromNow: ''}
        deadline: {$fromNow: '3 hours'}
        provisionerId: proj-relman
        workerType: ci
        payload:
          maxRunTime: 10800
          image: "rust:bookworm"
          command:
            - "/bin/bash"
            - "-cxe"
            - |-
              git clone --quiet ${repository}
              cd rust-code-analysis
              git -c advice.detachedHead=false checkout ${head_rev}
              ./check-grammars-crates.sh tree-sitter-mozjs
          cache:
            rust-code-analysis-mozilla-central-repository: /cache
          artifacts:
            public/json-diffs-and-minimal-tests-mozjs.tar.gz:
              expires: {$fromNow: '2 weeks'}
              path: /tmp/json-diffs-and-minimal-tests-mozjs.tar.gz
              type: file
        scopes:
          - "docker-worker:cache:rust-code-analysis-mozilla-central-repository"
        metadata:
          name: rust-code-analysis check tree-sitter-mozjs
          description: rust-code-analysis check tree-sitter-mozjs grammar
          owner: cdenizet@mozilla.com
          source: ${repository}/raw/${head_rev}/.taskcluster.yml

      - taskId: {$eval: as_slugid("check_tree_sitter_rust")}
        dependencies:
           - {$eval: as_slugid("lint_test_task")}
           - {$eval: as_slugid("windows_test_task")}
        created: {$fromNow: ''}
        deadline: {$fromNow: '3 hours'}
        provisionerId: proj-relman
        workerType: ci
        payload:
          maxRunTime: 10800
          image: "rust:bookworm"
          command:
            - "/bin/bash"
            - "-cxe"
            - |-
              git clone --quiet ${repository}
              cd rust-code-analysis
              git -c advice.detachedHead=false checkout ${head_rev}
              ./check-grammars-crates.sh tree-sitter-rust
          cache:
            rust-code-analysis-mozilla-central-repository: /cache
          artifacts:
            public/json-diffs-and-minimal-tests-rust.tar.gz:
              expires: {$fromNow: '2 weeks'}
              path: /tmp/json-diffs-and-minimal-tests-rust.tar.gz
              type: file
        scopes:
          - "docker-worker:cache:rust-code-analysis-mozilla-central-repository"
        metadata:
          name: rust-code-analysis check tree-sitter-rust
          description: rust-code-analysis check tree-sitter-rust grammar
          owner: cdenizet@mozilla.com
          source: ${repository}/raw/${head_rev}/.taskcluster.yml

      - taskId: {$eval: as_slugid("check_tree_sitter_java")}
        dependencies:
           - {$eval: as_slugid("lint_test_task")}
           - {$eval: as_slugid("windows_test_task")}
        created: {$fromNow: ''}
        deadline: {$fromNow: '3 hours'}
        provisionerId: proj-relman
        workerType: ci
        payload:
          maxRunTime: 10800
          image: "rust:bookworm"
          command:
            - "/bin/bash"
            - "-cxe"
            - |-
              git clone --quiet ${repository}
              cd rust-code-analysis
              git -c advice.detachedHead=false checkout ${head_rev}
              ./check-grammars-crates.sh tree-sitter-java
          cache:
            rust-code-analysis-mozilla-central-repository: /cache
          artifacts:
            public/json-diffs-and-minimal-tests-java.tar.gz:
              expires: {$fromNow: '2 weeks'}
              path: /tmp/json-diffs-and-minimal-tests-java.tar.gz
              type: file
        scopes:
          - "docker-worker:cache:rust-code-analysis-mozilla-central-repository"
        metadata:
          name: rust-code-analysis check tree-sitter-java
          description: rust-code-analysis check tree-sitter-java grammar
          owner: cdenizet@mozilla.com
          source: ${repository}/raw/${head_rev}/.taskcluster.yml

      - taskId: {$eval: as_slugid("check_tree_sitter_kotlin")}
        dependencies:
           - {$eval: as_slugid("lint_test_task")}
           - {$eval: as_slugid("windows_test_task")}
        created: {$fromNow: ''}
        deadline: {$fromNow: '3 hours'}
        provisionerId: proj-relman
        workerType: ci
        payload:
          maxRunTime: 10800
          image: "rust:bookworm"
          command:
            - "/bin/bash"
            - "-cxe"
            - |-
              git clone --quiet ${repository}
              cd rust-code-analysis
              git -c advice.detachedHead=false checkout ${head_rev}
              ./check-grammars-crates.sh tree-sitter-kotlin
          cache:
            rust-code-analysis-mozilla-central-repository: /cache
          artifacts:
            public/json-diffs-and-minimal-tests-kotlin.tar.gz:
              expires: {$fromNow: '2 weeks'}
              path: /tmp/json-diffs-and-minimal-tests-kotlin.tar.gz
              type: file
        scopes:
          - "docker-worker:cache:rust-code-analysis-mozilla-central-repository"
        metadata:
          name: rust-code-analysis check tree-sitter-kotlin
          description: rust-code-analysis check tree-sitter-kotlin grammar
          owner: cdenizet@mozilla.com
          source: ${repository}/raw/${head_rev}/.taskcluster.yml

      - taskId: {$eval: as_slugid("check_tree_sitter_python")}
        dependencies:
           - {$eval: as_slugid("lint_test_task")}
           - {$eval: as_slugid("windows_test_task")}
        created: {$fromNow: ''}
        deadline: {$fromNow: '3 hours'}
        provisionerId: proj-relman
        workerType: ci
        payload:
          maxRunTime: 10800
          image: "rust:bookworm"
          command:
            - "/bin/bash"
            - "-cxe"
            - |-
              git clone --quiet ${repository}
              cd rust-code-analysis
              git -c advice.detachedHead=false checkout ${head_rev}
              ./check-grammars-crates.sh tree-sitter-python
          cache:
            rust-code-analysis-mozilla-central-repository: /cache
          artifacts:
            public/json-diffs-and-minimal-tests-python.tar.gz:
              expires: {$fromNow: '2 weeks'}
              path: /tmp/json-diffs-and-minimal-tests-python.tar.gz
              type: file
        scopes:
          - "docker-worker:cache:rust-code-analysis-mozilla-central-repository"
        metadata:
          name: rust-code-analysis check tree-sitter-python
          description: rust-code-analysis check tree-sitter-python grammar
          owner: cdenizet@mozilla.com
          source: ${repository}/raw/${head_rev}/.taskcluster.yml

      - taskId: {$eval: as_slugid("check_tree_sitter_typescript")}
        dependencies:
           - {$eval: as_slugid("lint_test_task")}
           - {$eval: as_slugid("windows_test_task")}
        created: {$fromNow: ''}
        deadline: {$fromNow: '3 hours'}
        provisionerId: proj-relman
        workerType: ci
        payload:
          maxRunTime: 10800
          image: "rust:bookworm"
          command:
            - "/bin/bash"
            - "-cxe"
            - |-
              git clone --quiet ${repository}
              cd rust-code-analysis
              git -c advice.detachedHead=false checkout ${head_rev}
              ./check-grammars-crates.sh tree-sitter-typescript
          cache:
            rust-code-analysis-mozilla-central-repository: /cache
          artifacts:
            public/json-diffs-and-minimal-tests-typescript.tar.gz:
              expires: {$fromNow: '2 weeks'}
              path: /tmp/json-diffs-and-minimal-tests-typescript.tar.gz
              type: file
        scopes:
          - "docker-worker:cache:rust-code-analysis-mozilla-central-repository"
        metadata:
          name: rust-code-analysis check tree-sitter-typescript
          description: rust-code-analysis check tree-sitter-typescript grammar
          owner: cdenizet@mozilla.com
          source: ${repository}/raw/${head_rev}/.taskcluster.yml

      - $if: 'tasks_for == "github-push" && head_branch[:10] == "refs/tags/"'
        then:
          taskId: {$eval: as_slugid("test_mozilla_central")}
          dependencies:
            - {$eval: as_slugid("lint_test_task")}
            - {$eval: as_slugid("windows_test_task")}
          created: {$fromNow: ''}
          deadline: {$fromNow: '1 hour'}
          provisionerId: proj-relman
          workerType: ci
          payload:
            maxRunTime: 3600
            image: "rust:bookworm"
            command:
              - "/bin/bash"
              - "-cxe"
              - |-
                git clone --quiet ${repository}
                [ ! -d "/cache/gecko-dev" ]
                git clone --quiet https://github.com/mozilla/gecko-dev.git /cache/gecko-dev || true
                pushd /cache/gecko-dev
                git pull origin master
                popd
                mkdir -p /tmp/mozilla_central_output
                cd rust-code-analysis
                git -c advice.detachedHead=false checkout ${head_rev}
                cargo build --release --workspace --all-features
                cargo run --release -p rust-code-analysis-cli -- -p /cache/gecko-dev \
                    -j4 --metrics -O json -o /tmp/mozilla_central_output
            cache:
              rust-code-analysis-mozilla-central-repository: /cache
          scopes:
            - "docker-worker:cache:rust-code-analysis-mozilla-central-repository"
          metadata:
            name: rust-code-analysis mozilla-central test
            description: rust-code-analysis-cli tested on mozilla-central
            owner: cdenizet@mozilla.com
            source: ${repository}/raw/${head_rev}/.taskcluster.yml

      - $if: 'tasks_for == "github-push" && head_branch == "refs/heads/master"'
        then:
          taskId: {$eval: as_slugid("deploy_documentation")}
          dependencies:
            - {$eval: as_slugid("build_documentation")}
            - {$eval: as_slugid("lint_test_task")}
            - {$eval: as_slugid("ccov_test_task")}
            - {$eval: as_slugid("windows_test_task")}
          created: {$fromNow: ''}
          deadline: {$fromNow: '2 hour'}
          provisionerId: proj-relman
          workerType: ci
          scopes:
              - secrets:get:project/relman/rust-code-analysis/deploy
          payload:
            features:
              taskclusterProxy: true
            maxRunTime: 3600
            image: "${taskboot_image}"
            env:
                TASKCLUSTER_SECRET: project/relman/rust-code-analysis/deploy
            command:
              - "/bin/sh"
              - "-cxe"
              - |-
                git config --global user.email moz-tools-bot@moz.tools
                git config --global user.name moz.tools Bot
                git clone --quiet ${repository}
                cd rust-code-analysis
                taskboot retrieve-artifact --output-path=. --artifacts=public/book.tar.gz
                tar xfz book.tar.gz -C rust-code-analysis-book
                ./rust-code-analysis-book/deploy-to-GitHub-Pages
                taskboot git-push --force-push github.com/mozilla/rust-code-analysis moz-tools-bot gh-pages
                rm -rf book.tar.gz
          metadata:
            name: "rust-code-analysis book deployment"
            description: rust-code-analysis book deployment on GitHub Pages
            owner: cdenizet@mozilla.com
            source: ${repository}/raw/${head_rev}/.taskcluster.yml

      - $if: 'tasks_for == "github-push" && head_branch[:10] == "refs/tags/"'
        then:
            taskId: {$eval: as_slugid("publish_crates")}
            dependencies:
              - {$eval: as_slugid("test_mozilla_central")}
              - {$eval: as_slugid("deploy_documentation")}
            created: {$fromNow: ''}
            deadline: {$fromNow: '2 hour'}
            provisionerId: proj-relman
            workerType: ci
            scopes:
              - secrets:get:project/relman/rust-code-analysis/deploy
            payload:
              features:
                taskclusterProxy: true
              maxRunTime: 3600
              image: "${taskboot_image}"
              env:
                TASKCLUSTER_SECRET: project/relman/rust-code-analysis/deploy
              command:
                - "/bin/sh"
                - "-cxe"
                - |-
                  git config --global user.email moz-tools-bot@moz.tools
                  git config --global user.name moz.tools Bot
                  git clone --quiet ${repository}
                  cd rust-code-analysis
                  cd tree-sitter-ccomment && taskboot cargo-publish --ignore-published && cd ..
                  cd tree-sitter-preproc && taskboot cargo-publish --ignore-published && cd ..
                  cd tree-sitter-mozjs && taskboot cargo-publish --ignore-published && cd ..
                  cd tree-sitter-mozcpp && taskboot cargo-publish --ignore-published && cd ..
                  taskboot cargo-publish --ignore-published
                  cd rust-code-analysis-cli && taskboot cargo-publish --ignore-published && cd ..
                  cd rust-code-analysis-web && taskboot cargo-publish --igoure-published
            metadata:
              name: "rust-code-analysis crates publishing on crates.io ${head_branch[10:]}"
              description: rust-code-analysis crates publishing on crates.io
              owner: cdenizet@mozilla.com
              source: ${repository}/raw/${head_rev}/.taskcluster.yml

      - $if: 'tasks_for == "github-push" && head_branch[:10] == "refs/tags/"'
        then:
          taskId: {$eval: as_slugid("build_linux_release")}
          dependencies:
            - {$eval: as_slugid("publish_crates")}
          created: {$fromNow: ''}
          deadline: {$fromNow: '2 hour'}
          provisionerId: proj-relman
          workerType: ci
          payload:
            maxRunTime: 3600
            image: "rust:bookworm"
            command:
              - "/bin/bash"
              - "-cxe"
              - |-
                git clone --quiet ${repository}
                cd rust-code-analysis
                git -c advice.detachedHead=false checkout ${head_rev}
                cargo update
                cargo build --workspace --release
                cargo package --all-features
                pushd rust-code-analysis-cli && cargo package --all-features && popd
                pushd rust-code-analysis-web && cargo package --all-features && popd
                cd target/release
                tar -zvcf /rust-code-analysis-linux-cli-x86_64.tar.gz rust-code-analysis-cli
                tar -zvcf /rust-code-analysis-linux-web-x86_64.tar.gz rust-code-analysis-web
            artifacts:
              public/rust-code-analysis-linux-cli-x86_64.tar.gz:
                expires: {$fromNow: '2 weeks'}
                path: /rust-code-analysis-linux-cli-x86_64.tar.gz
                type: file
              public/rust-code-analysis-linux-web-x86_64.tar.gz:
                expires: {$fromNow: '2 weeks'}
                path: /rust-code-analysis-linux-web-x86_64.tar.gz
                type: file
              public/Cargo.lock:
                expires: {$fromNow: '2 weeks'}
                path: /rust-code-analysis/Cargo.lock
                type: file
          metadata:
            name: rust-code-analysis linux release build
            description: rust-code-analysis linux release build
            owner: cdenizet@mozilla.com
            source: ${repository}/raw/${head_rev}/.taskcluster.yml

      - $if: 'tasks_for == "github-push" && head_branch[:10] == "refs/tags/"'
        then:
          taskId: {$eval: as_slugid("build_windows_release")}
          dependencies:
            - {$eval: as_slugid("lint_test_task")}
            - {$eval: as_slugid("windows_test_task")}
          created: {$fromNow: ''}
          deadline: {$fromNow: '2 hour'}
          provisionerId: proj-relman
          workerType: win2022
          payload:
            maxRunTime: 3600
            command:
              - set VSWHERE=%programfiles(x86)%\Microsoft Visual Studio\Installer
              - set VS_BINS=VC\Tools\MSVC\*\bin\Hostx64\x64
              - set RUSTUP_INIT_PATH=%CD%\rustup-init
              - set CARGO_PATH=%USERPROFILE%\.cargo\bin
              - set PATH=%RUSTUP_INIT_PATH%;%CARGO_PATH%;%VSWHERE%;%PATH%
              - set VSWHERE_CMD=vswhere -latest -products * -find %VS_BINS%
              - FOR /F "tokens=*" %%o IN ('%VSWHERE_CMD%') do (SET LIB_PATH=%%o)
              - set PATH=%LIB_PATH%;%PATH%
              - rustup-init -yv --default-toolchain stable ^
                                --default-host x86_64-pc-windows-msvc
              - git clone --quiet ${repository}
              - cd rust-code-analysis
              - git -c advice.detachedHead=false checkout ${head_rev}
              - cargo build --workspace --release
              - 7z a rust-code-analysis-win-cli-x86_64.zip "target\release\rust-code-analysis-cli.exe"
              - 7z a rust-code-analysis-win-web-x86_64.zip "target\release\rust-code-analysis-web.exe"
            mounts:
              - content:
                  url: https://win.rustup.rs/
                file: rustup-init\rustup-init.exe
            artifacts:
              - name: public/rust-code-analysis-win-cli-x86_64.zip
                expires: {$fromNow: '2 weeks'}
                path: rust-code-analysis\rust-code-analysis-win-cli-x86_64.zip
                type: file
              - name: public/rust-code-analysis-win-web-x86_64.zip
                expires: {$fromNow: '2 weeks'}
                path: rust-code-analysis\rust-code-analysis-win-web-x86_64.zip
                type: file
          metadata:
            name: rust-code-analysis windows release build
            description: rust-code-analysis windows release build
            owner: cdenizet@mozilla.com
            source: ${repository}/raw/${head_rev}/.taskcluster.yml

      - $if: 'tasks_for == "github-push" && head_branch[:10] == "refs/tags/"'
        then:
          $let:
            linux_cli: rust-code-analysis-linux-cli-x86_64.tar.gz
            linux_web: rust-code-analysis-linux-web-x86_64.tar.gz
            win_cli: rust-code-analysis-win-cli-x86_64.zip
            win_web: rust-code-analysis-win-web-x86_64.zip
          in:
            taskId: {$eval: as_slugid("deploy_release")}
            dependencies:
              - {$eval: as_slugid("build_linux_release")}
              - {$eval: as_slugid("build_windows_release")}
              - {$eval: as_slugid("test_mozilla_central")}
              - {$eval: as_slugid("deploy_documentation")}
            created: {$fromNow: ''}
            deadline: {$fromNow: '2 hour'}
            provisionerId: proj-relman
            workerType: ci
            scopes:
              - secrets:get:project/relman/rust-code-analysis/deploy
            payload:
              features:
                taskclusterProxy: true
              maxRunTime: 3600
              image: "${taskboot_image}"
              env:
                TASKCLUSTER_SECRET: project/relman/rust-code-analysis/deploy
              command:
                - "/bin/sh"
                - "-cxe"
                - |-
                  taskboot github-release mozilla/rust-code-analysis ${head_branch[10:]} --asset Cargo.lock:public/Cargo.lock ${linux_cli}:public/${linux_cli} ${linux_web}:public/${linux_web} ${win_cli}:public/${win_cli} ${win_web}:public/${win_web}
            metadata:
              name: "rust-code-analysis release publication ${head_branch[10:]}"
              description: rust-code-analysis release publication on Github
              owner: cdenizet@mozilla.com
              source: ${repository}/raw/${head_rev}/.taskcluster.yml