<commit_before>name: ci-test

on:
  push:
    branches: [auto, canary]
  pull_request:
    branches: [main, master, release-*, gha-test-*]

defaults:
  run:
    shell: bash

env:
  max_threads: 16
  pre_command: cd /opt/git/diem/

jobs:
  prepare:
    runs-on: ubuntu-latest
    outputs:
      changes-target-branch: ${{ steps.changes.outputs.changes-target-branch }}
      changes-base-githash: ${{ steps.changes.outputs.changes-base-githash }}
      changes-pull-request-number: ${{ steps.changes.outputs.changes-pull-request-number }}
      test-rust: ${{ steps.rust-changes.outputs.changes-found }}
      test-dev-setup: ${{ steps.dev-setup-sh-changes.outputs.changes-found }}
      test-website-build: ${{ steps.website-changes.outputs.changes-found }}
      test-non-rust-lint: ${{ steps.non-rust-lint-changes.outputs.changes-found }}
    steps:
      - uses: actions/checkout@v2
        with:
          # This ensures that the tip of the PR is checked out instead of the merge between the base ref and the tip
          # On `push` this value will be empty and will "do-the-right-thing"
          ref: ${{ github.event.pull_request.head.sha }}
          fetch-depth: 0 #get all the history!!!
      - name: Git Hooks and Checks
        run: ./scripts/git-checks.sh
      - id: changes
        name: determine changes
        uses: ./.github/actions/changes
        with:
          workflow-file: ci-test.yml
      - id: rust-changes
        name: find rust/cargo changes.
        uses: ./.github/actions/matches
        with:
          pattern: '^documentation\|^docker\|^scripts\|^.circleci'
          invert: "true"
      - id: non-rust-lint-changes
        name: find shell/dockerfile changes
        uses: ./.github/actions/matches
        with:
          pattern: 'Dockerfile$\|.*.sh$'
      - id: dev-setup-sh-changes
        name: find dev-setup.sh/base docker image changes
        uses: ./.github/actions/matches
        with:
          pattern: '^.github\|docker/ci\|scripts/dev_setup.sh'
      - id: website-changes
        name: find website changes.
        uses: ./.github/actions/matches
        with:
          pattern: "^documentation"

  dev-setup-sh-test:
    runs-on: ubuntu-latest-xl
    timeout-minutes: 30
    needs: prepare
    if: ${{ needs.prepare.outputs.test-dev-setup == 'true' }}
    strategy:
      matrix:
        target_os: [alpine, centos, github] #arch is broken, re-add when fixed: https://bugs.archlinux.org/task/69563
    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.event.pull_request.head.sha }}
      - uses: ./.github/actions/check-machine
        with:
          webhook-gha-hardware: ${{ secrets.WEBHOOK_GHA_HARDWARE }}
      - name: build image with dev-setup.sh
        run: docker build -f docker/ci/${{ matrix.target_os }}/Dockerfile -t diem/build_environment:test .

  non-rust-lint:
    runs-on: ubuntu-latest
    timeout-minutes: 5
    needs: prepare
    if: ${{ needs.prepare.outputs.test-non-rust-lint == 'true'  }}
    container:
      image: diem/build_environment:${{ needs.prepare.outputs.changes-target-branch }}
    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.event.pull_request.head.sha }}
      - uses: ./.github/actions/build-setup
      - uses: ./.github/actions/check-machine
        with:
          min-cpu: 2
          min-ram: 7
          webhook-gha-hardware: ${{ secrets.WEBHOOK_GHA_HARDWARE }}
      - name: shell lints
        run: |
          shellcheck scripts/dev_setup.sh && \
          shellcheck scripts/dockerhub_prune.sh && \
          shellcheck .github/actions/changes/get_pr_info.sh && \
          shellcheck docker/build_push.sh && \
          shellcheck docker/docker_republish.sh
      - name: docker lints
        uses: ./.github/actions/docker-checks

  lint:
    runs-on: ubuntu-latest-xl
    timeout-minutes: 30
    needs: prepare
    #if: ${{ needs.prepare.outputs.test-rust == 'true' }}<commit_msg>[ci] bump timeout for non-rust-lint<commit_after>name: ci-test

on:
  push:
    branches: [auto, canary]
  pull_request:
    branches: [main, master, release-*, gha-test-*]

defaults:
  run:
    shell: bash

env:
  max_threads: 16
  pre_command: cd /opt/git/diem/

jobs:
  prepare:
    runs-on: ubuntu-latest
    outputs:
      changes-target-branch: ${{ steps.changes.outputs.changes-target-branch }}
      changes-base-githash: ${{ steps.changes.outputs.changes-base-githash }}
      changes-pull-request-number: ${{ steps.changes.outputs.changes-pull-request-number }}
      test-rust: ${{ steps.rust-changes.outputs.changes-found }}
      test-dev-setup: ${{ steps.dev-setup-sh-changes.outputs.changes-found }}
      test-website-build: ${{ steps.website-changes.outputs.changes-found }}
      test-non-rust-lint: ${{ steps.non-rust-lint-changes.outputs.changes-found }}
    steps:
      - uses: actions/checkout@v2
        with:
          # This ensures that the tip of the PR is checked out instead of the merge between the base ref and the tip
          # On `push` this value will be empty and will "do-the-right-thing"
          ref: ${{ github.event.pull_request.head.sha }}
          fetch-depth: 0 #get all the history!!!
      - name: Git Hooks and Checks
        run: ./scripts/git-checks.sh
      - id: changes
        name: determine changes
        uses: ./.github/actions/changes
        with:
          workflow-file: ci-test.yml
      - id: rust-changes
        name: find rust/cargo changes.
        uses: ./.github/actions/matches
        with:
          pattern: '^documentation\|^docker\|^scripts\|^.circleci'
          invert: "true"
      - id: non-rust-lint-changes
        name: find shell/dockerfile changes
        uses: ./.github/actions/matches
        with:
          pattern: 'Dockerfile$\|.*.sh$'
      - id: dev-setup-sh-changes
        name: find dev-setup.sh/base docker image changes
        uses: ./.github/actions/matches
        with:
          pattern: '^.github\|docker/ci\|scripts/dev_setup.sh'
      - id: website-changes
        name: find website changes.
        uses: ./.github/actions/matches
        with:
          pattern: "^documentation"

  dev-setup-sh-test:
    runs-on: ubuntu-latest-xl
    timeout-minutes: 30
    needs: prepare
    if: ${{ needs.prepare.outputs.test-dev-setup == 'true' }}
    strategy:
      matrix:
        target_os: [alpine, centos, github] #arch is broken, re-add when fixed: https://bugs.archlinux.org/task/69563
    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.event.pull_request.head.sha }}
      - uses: ./.github/actions/check-machine
        with:
          webhook-gha-hardware: ${{ secrets.WEBHOOK_GHA_HARDWARE }}
      - name: build image with dev-setup.sh
        run: docker build -f docker/ci/${{ matrix.target_os }}/Dockerfile -t diem/build_environment:test .

  non-rust-lint:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    needs: prepare
    if: ${{ needs.prepare.outputs.test-non-rust-lint == 'true'  }}
    container:
      image: diem/build_environment:${{ needs.prepare.outputs.changes-target-branch }}
    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.event.pull_request.head.sha }}
      - uses: ./.github/actions/build-setup
      - uses: ./.github/actions/check-machine
        with:
          min-cpu: 2
          min-ram: 7
          webhook-gha-hardware: ${{ secrets.WEBHOOK_GHA_HARDWARE }}
      - name: shell lints
        run: |
          shellcheck scripts/dev_setup.sh && \
          shellcheck scripts/dockerhub_prune.sh && \
          shellcheck .github/actions/changes/get_pr_info.sh && \
          shellcheck docker/build_push.sh && \
          shellcheck docker/docker_republish.sh
      - name: docker lints
        uses: ./.github/actions/docker-checks

  lint:
    runs-on: ubuntu-latest-xl
    timeout-minutes: 30
    needs: prepare
    #if: ${{ needs.prepare.outputs.test-rust == 'true' }}
{'fraction_non_alphanumeric': 0.13365155131264916, 'fraction_numerical': 0.004647657329481221, 'mean_word_length': 2.1759074591144794, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6512851', 'n_tokens_mistral': 2612, 'n_tokens_neox': 2463, 'n_words': 522}