<commit_before>#!/bin/bash

set -ex
if [ "$GERRIT_PROJECT" == "canvas-lms" ]; then
  # when parent is not in $GERRIT_BRANCH (i.e. master)
  if ! git merge-base --is-ancestor HEAD~1 origin/$GERRIT_BRANCH; then
    message="This commit is built upon commits not currently merged in $GERRIT_BRANCH. Ensure that your dependent patchsets are merged first!\\n"
    gergich comment "{\"path\":\"/COMMIT_MSG\",\"position\":1,\"severity\":\"warn\",\"message\":\"$message\"}"
  fi

  # when modifying Dockerfile or Dockerfile.jenkins*, Dockerfile.template must also be modified.
  ruby build/dockerfile_writer.rb --env development --compose-file docker-compose.yml,docker-compose.override.yml --in build/Dockerfile.template --out Dockerfile
  ruby build/dockerfile_writer.rb --env jenkins --compose-file docker-compose.yml,docker-compose.override.yml --in build/Dockerfile.template --out Dockerfile.jenkins
  if ! git diff --exit-code Dockerfile; then
    message="Dockerfile and build/Dockerfile.template need to be kept in sync. Update Dockerfile by running the command given at the top.\\n"
    gergich comment "{\"path\":\"\Dockerfile\",\"position\":1,\"severity\":\"error\",\"message\":\"$message\"}"
  fi
  if ! git diff --exit-code Dockerfile.jenkins; then
    message="Dockerfile.jenkins and build/Dockerfile.template need to be kept in sync. Update Dockerfile.jenkins by running the command given at the top.\\n"
    gergich comment "{\"path\":\"\Dockerfile.jenkins\",\"position\":1,\"severity\":\"error\",\"message\":\"$message\"}"
  fi
fi

# always keep the graphQL schema up-to-date
rake graphql:schema RAILS_ENV=test

if ! git diff --exit-code ui/shared/apollo/fragmentTypes.json; then
    message="ui/shared/apollo/fragmentTypes.json needs to be kept up-to-date. Run bundle exec rake graphql:schema and push the changes.\\n"
    gergich comment "{\"path\":\"ui/shared/apollo/fragmentTypes.json\",\"position\":1,\"severity\":\"error\",\"message\":\"$message\"}"
  fi

gergich capture custom:./build/gergich/xsslint:Gergich::XSSLint 'node script/xsslint.js'
gergich capture i18nliner 'rake i18n:check'
# purposely don't run under bundler; they shell out and use bundler as necessary
ruby script/brakeman
ruby script/tatl_tael
ruby script/stylelint
ruby script/rlint --no-fail-on-offense
[ "${SKIP_ESLINT-}" != "true" ] && ruby script/eslint
ruby script/lint_commit_message
node script/yarn-validate-workspace-deps.js 2>/dev/null < <(yarn --silent workspaces info --json)
node ui-build/tools/component-info.mjs -i -v -g<commit_msg>remove need for .git directory for graphql schema check<commit_after>#!/bin/bash

set -ex
if [ "$GERRIT_PROJECT" == "canvas-lms" ]; then
  # when parent is not in $GERRIT_BRANCH (i.e. master)
  if ! git merge-base --is-ancestor HEAD~1 origin/$GERRIT_BRANCH; then
    message="This commit is built upon commits not currently merged in $GERRIT_BRANCH. Ensure that your dependent patchsets are merged first!\\n"
    gergich comment "{\"path\":\"/COMMIT_MSG\",\"position\":1,\"severity\":\"warn\",\"message\":\"$message\"}"
  fi

  # when modifying Dockerfile or Dockerfile.jenkins*, Dockerfile.template must also be modified.
  ruby build/dockerfile_writer.rb --env development --compose-file docker-compose.yml,docker-compose.override.yml --in build/Dockerfile.template --out Dockerfile
  ruby build/dockerfile_writer.rb --env jenkins --compose-file docker-compose.yml,docker-compose.override.yml --in build/Dockerfile.template --out Dockerfile.jenkins
  if ! git diff --exit-code Dockerfile; then
    message="Dockerfile and build/Dockerfile.template need to be kept in sync. Update Dockerfile by running the command given at the top.\\n"
    gergich comment "{\"path\":\"\Dockerfile\",\"position\":1,\"severity\":\"error\",\"message\":\"$message\"}"
  fi
  if ! git diff --exit-code Dockerfile.jenkins; then
    message="Dockerfile.jenkins and build/Dockerfile.template need to be kept in sync. Update Dockerfile.jenkins by running the command given at the top.\\n"
    gergich comment "{\"path\":\"\Dockerfile.jenkins\",\"position\":1,\"severity\":\"error\",\"message\":\"$message\"}"
  fi
fi

cp ui/shared/apollo/fragmentTypes.json ui/shared/apollo/fragmentTypes.json.old

# always keep the graphQL schema up-to-date
rake graphql:schema RAILS_ENV=test

if ! diff ui/shared/apollo/fragmentTypes.json ui/shared/apollo/fragmentTypes.json.old; then
    message="ui/shared/apollo/fragmentTypes.json needs to be kept up-to-date. Run bundle exec rake graphql:schema and push the changes.\\n"
    gergich comment "{\"path\":\"ui/shared/apollo/fragmentTypes.json\",\"position\":1,\"severity\":\"error\",\"message\":\"$message\"}"
  fi

gergich capture custom:./build/gergich/xsslint:Gergich::XSSLint 'node script/xsslint.js'
gergich capture i18nliner 'rake i18n:check'
# purposely don't run under bundler; they shell out and use bundler as necessary
ruby script/brakeman
ruby script/tatl_tael
ruby script/stylelint
ruby script/rlint --no-fail-on-offense
[ "${SKIP_ESLINT-}" != "true" ] && ruby script/eslint
ruby script/lint_commit_message
node script/yarn-validate-workspace-deps.js 2>/dev/null < <(yarn --silent workspaces info --json)
node ui-build/tools/component-info.mjs -i -v -g
{'fraction_non_alphanumeric': 0.14856046065259118, 'fraction_numerical': 0.003838771593090211, 'mean_word_length': 4.211, 'pattern_counts': {'":': 32, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '1684156', 'n_tokens_mistral': 1772, 'n_tokens_neox': 1693, 'n_words': 447}