rust-code-analysis 0.0.19

Tool to compute and export code metrics
Documentation
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}
  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:buster"
          command:
            - "/bin/bash"
            - "-cx"
            - "curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python3 get-pip.py &&
               rustup component add clippy rustfmt &&
               git clone --recursive --quiet ${repository} &&
               cd rust-code-analysis &&
               git -c advice.detachedHead=false checkout --recurse-submodules ${head_rev} &&
               pip3 install --quiet pre-commit &&
               pre-commit run -a --show-diff-on-failure &&
               cargo test --all --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:buster"
          command:
            - "/bin/bash"
            - "-cx"
            - "git clone --recursive --quiet ${repository} &&
               cd rust-code-analysis &&
               git -c advice.detachedHead=false checkout --recurse-submodules ${head_rev} &&
               cargo install mdbook --no-default-features --features search,output --vers \"^0.1.0\" &&
               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: "rustlang/rust:nightly"
          env:
            CODECOV_TOKEN: 4df01912-087e-489a-be28-25aa911cb9d2
            CARGO_INCREMENTAL: 0
            RUSTFLAGS: -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort
            RUSTDOCFLAGS: -Cpanic=abort
          command:
            - "/bin/bash"
            - "-cx"
            - "apt-get -qq update &&
               apt-get -qq install -y zip &&
               curl -L https://github.com/mozilla/grcov/releases/latest/download/grcov-linux-x86_64.tar.bz2 | tar jxf - &&
               git clone --recursive --quiet ${repository} &&
               cd rust-code-analysis &&
               git -c advice.detachedHead=false checkout --recurse-submodules ${head_rev} &&
               cargo test --all --verbose --all-features &&
               zip -0 ccov.zip `find . -name 'rust_code_analysis*.gc*' -print` &&
               ../grcov ccov.zip -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: win2012r2
        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 --recursive --quiet ${repository}
            - cd rust-code-analysis
            - git -c advice.detachedHead=false checkout --recurse-submodules ${head_rev}
            - cargo test --all --verbose --all-features
          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

      - $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:buster"
            command:
              - "/bin/bash"
              - "-cx"
              - "git clone --recursive --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 --recurse-submodules ${head_rev} &&
                 cargo build --release --all --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[:10] == "refs/tags/"'
        then:
          taskId: {$eval: as_slugid("build_linux_release")}
          dependencies:
            - {$eval: as_slugid("lint_test_task")}
            - {$eval: as_slugid("windows_test_task")}
          created: {$fromNow: ''}
          deadline: {$fromNow: '2 hour'}
          provisionerId: proj-relman
          workerType: ci
          payload:
            maxRunTime: 3600
            image: "rust:buster"
            command:
              - "/bin/bash"
              - "-cx"
              - "git clone --recursive --quiet ${repository} &&
                 cd rust-code-analysis &&
                 git -c advice.detachedHead=false checkout --recurse-submodules ${head_rev} &&
                 cargo build --all --release &&
                 cd target/release &&
                 strip rust-code-analysis-cli rust-code-analysis-web &&
                 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
          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: win2012r2
          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 --recursive --quiet ${repository}
              - cd rust-code-analysis
              - git -c advice.detachedHead=false checkout --recurse-submodules ${head_rev}
              - cargo build --all --release
            mounts:
              - content:
                  url: https://win.rustup.rs/
                file: rustup-init\rustup-init.exe
            artifacts:
              - name: public/rust-code-analysis-cli.exe
                expires: {$fromNow: '2 weeks'}
                path: rust-code-analysis\target\release\rust-code-analysis-cli.exe
                type: file
              - name: public/rust-code-analysis-web.exe
                expires: {$fromNow: '2 weeks'}
                path: rust-code-analysis\target\release\rust-code-analysis-web.exe
                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:
          taskId: {$eval: as_slugid("strip_windows_binary")}
          dependencies:
              - {$eval: as_slugid("build_windows_release")}
          created: {$fromNow: ''}
          deadline: {$fromNow: '2 hour'}
          provisionerId: proj-relman
          workerType: ci
          payload:
            maxRunTime: 3600
            image: "mozilla/taskboot:0.2.7"
            command:
                - "/bin/sh"
                - "-cx"
                - "taskboot retrieve-artifact --output-path=. --artifacts public/rust-code-analysis-cli.exe public/rust-code-analysis-web.exe &&
                   apk add --no-cache zip &&
                   strip rust-code-analysis-cli.exe rust-code-analysis-web.exe &&
                   zip -9 /rust-code-analysis-win-cli-x86_64.zip rust-code-analysis-cli.exe &&
                   zip -9 /rust-code-analysis-win-web-x86_64.zip rust-code-analysis-web.exe"
            artifacts:
              public/rust-code-analysis-win-cli-x86_64.zip:
                expires: {$fromNow: '2 weeks'}
                path: /rust-code-analysis-win-cli-x86_64.zip
                type: file
              public/rust-code-analysis-win-web-x86_64.zip:
                expires: {$fromNow: '2 weeks'}
                path: /rust-code-analysis-win-web-x86_64.zip
                type: file
          metadata:
            name: strip rust-code-analysis windows binary
            description: strip rust-code-analysis windows binary
            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("deploy_release")}
          dependencies:
            - {$eval: as_slugid("build_linux_release")}
            - {$eval: as_slugid("strip_windows_binary")}
            - {$eval: as_slugid("test_mozilla_central")}
            - {$eval: as_slugid("build_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: "mozilla/taskboot:0.2.7"
            env:
              TASKCLUSTER_SECRET: project/relman/rust-code-analysis/deploy
            command:
              - "/bin/sh"
              - "-cx"
              - "git config --global user.email moz-tools-bot@moz.tools &&
                 git config --global user.name moz.tools Bot &&
                 git clone --recursive --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 &&
                 taskboot github-release mozilla/rust-code-analysis ${head_branch[10:]} --asset rust-code-analysis-linux-cli-x86_64.tar.gz:public/rust-code-analysis-linux-cli-x86_64.tar.gz rust-code-analysis-linux-web-x86_64.tar.gz:public/rust-code-analysis-linux-web-x86_64.tar.gz rust-code-analysis-win-cli-x86_64.zip:public/rust-code-analysis-win-cli-x86_64.zip rust-code-analysis-win-web-x86_64.zip:public/rust-code-analysis-win-web-x86_64.zip &&
                 taskboot cargo-publish"
          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