action.yml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. # NOTE: Do not rely on `make` commands here as this action is used across different repos
  2. # where the Makefile will not be available
  3. name: 'Sentry Setup'
  4. description: 'Sets up a Sentry test environment'
  5. inputs:
  6. workdir:
  7. description: 'Directory where the sentry source is located'
  8. required: false
  9. default: '.'
  10. python-version:
  11. description: 'python version to install'
  12. required: false
  13. default: '3.13.1'
  14. mode:
  15. description: 'Mode to bring up by new devservices'
  16. required: false
  17. default: 'default'
  18. outputs:
  19. yarn-cache-dir:
  20. description: 'Path to yarn cache'
  21. value: ${{ steps.config.outputs.yarn-cache-dir }}
  22. matrix-instance-number:
  23. description: 'The matrix instance number (starting at 1)'
  24. value: ${{ steps.config.outputs.matrix-instance-number }}
  25. matrix-instance-total:
  26. description: 'Reexport of MATRIX_INSTANCE_TOTAL.'
  27. value: ${{ steps.config.outputs.matrix-instance-total }}
  28. runs:
  29. using: 'composite'
  30. steps:
  31. - name: Setup default environment variables
  32. # the default for "bash" is:
  33. # bash --noprofile --norc -eo pipefail {0}
  34. shell: bash --noprofile --norc -eo pipefail -ux {0}
  35. env:
  36. MATRIX_INSTANCE: ${{ matrix.instance }}
  37. # XXX: We should be using something like len(strategy.matrix.instance) (not possible atm)
  38. # If you have other things like python-version: [foo, bar, baz] then the sharding logic
  39. # isn't right because job-total will be 3x larger and you'd never run 2/3 of the tests.
  40. # MATRIX_INSTANCE_TOTAL: ${{ strategy.job-total }}
  41. run: |
  42. echo "PIP_DISABLE_PIP_VERSION_CHECK=on" >> $GITHUB_ENV
  43. echo "PIP_INDEX_URL=https://pypi.devinfra.sentry.io/simple" >> $GITHUB_ENV
  44. echo "SENTRY_SKIP_BACKEND_VALIDATION=1" >> $GITHUB_ENV
  45. ### node configuration ###
  46. echo "NODE_ENV=development" >> $GITHUB_ENV
  47. ### pytest configuration ###
  48. echo "PY_COLORS=1" >> "$GITHUB_ENV"
  49. echo "PYTEST_ADDOPTS=--reruns=5 --durations=10 --fail-slow=60s" >> $GITHUB_ENV
  50. echo "COVERAGE_CORE=sysmon" >> "$GITHUB_ENV"
  51. ### pytest-sentry configuration ###
  52. if [ "$GITHUB_REPOSITORY" = "getsentry/sentry" ]; then
  53. echo "PYTEST_SENTRY_DSN=https://6fd5cfea2d4d46b182ad214ac7810508@sentry.io/2423079" >> $GITHUB_ENV
  54. echo "PYTEST_SENTRY_TRACES_SAMPLE_RATE=0" >> $GITHUB_ENV
  55. # This records failures on master to sentry in order to detect flakey tests, as it's
  56. # expected that people have failing tests on their PRs
  57. if [ "$GITHUB_REF" = "refs/heads/master" ]; then
  58. echo "PYTEST_SENTRY_ALWAYS_REPORT=1" >> $GITHUB_ENV
  59. fi
  60. fi
  61. # Configure a different release version, otherwise it defaults to the
  62. # commit sha which will conflict with our actual prod releases. This is a
  63. # confusing experience because it looks like these are "empty" releases
  64. # because no commits are attached and associates the release with our
  65. # javascript + sentry projects.
  66. echo "SENTRY_RELEASE=ci@$GITHUB_SHA" >> $GITHUB_ENV
  67. # this handles pytest test sharding
  68. if [ "$MATRIX_INSTANCE" ]; then
  69. if ! [ "${MATRIX_INSTANCE_TOTAL:-}" ]; then
  70. echo "MATRIX_INSTANCE_TOTAL is required."
  71. exit 1
  72. fi
  73. echo "TEST_GROUP=$MATRIX_INSTANCE" >> $GITHUB_ENV
  74. echo "TOTAL_TEST_GROUPS=$MATRIX_INSTANCE_TOTAL" >> $GITHUB_ENV
  75. fi
  76. - uses: getsentry/action-setup-venv@a133e6fd5fa6abd3f590a1c106abda344f5df69f # v2.1.0
  77. with:
  78. python-version: ${{ inputs.python-version }}
  79. cache-dependency-path: ${{ inputs.workdir }}/requirements-dev-frozen.txt
  80. install-cmd: cd ${{ inputs.workdir }} && pip install -r requirements-dev-frozen.txt
  81. - name: Set up outputs
  82. id: config
  83. env:
  84. MATRIX_INSTANCE: ${{ matrix.instance }}
  85. shell: bash --noprofile --norc -eo pipefail -ux {0}
  86. run: |
  87. echo "yarn-cache-dir=$(yarn cache dir)" >> "$GITHUB_OUTPUT"
  88. echo "matrix-instance-number=$(($MATRIX_INSTANCE+1))" >> "$GITHUB_OUTPUT"
  89. echo "matrix-instance-total=$((${MATRIX_INSTANCE_TOTAL:-}))" >> "$GITHUB_OUTPUT"
  90. - name: Install python dependencies
  91. shell: bash --noprofile --norc -eo pipefail -ux {0}
  92. env:
  93. # This is necessary when other repositories (e.g. relay) want to take advantage of this workflow
  94. # without needing to fork it. The path needed is the one where setup.py is located
  95. WORKDIR: ${{ inputs.workdir }}
  96. run: |
  97. cd "$WORKDIR"
  98. # We need to install editable otherwise things like check migration will fail.
  99. python3 -m tools.fast_editable --path .
  100. - name: Start new devservices
  101. shell: bash --noprofile --norc -eo pipefail -ux {0}
  102. env:
  103. WORKDIR: ${{ inputs.workdir }}
  104. ENABLE_AUTORUN_MIGRATION_SEARCH_ISSUES: '1'
  105. run: |
  106. sentry init
  107. # This is necessary to bring up devservices with appropriate sentry config
  108. cd "$WORKDIR"
  109. devservices up --mode ${{ inputs.mode }}
  110. # have tests listen on the docker gateway ip so loopback can occur
  111. echo "DJANGO_LIVE_TEST_SERVER_ADDRESS=$(docker network inspect bridge --format='{{(index .IPAM.Config 0).Gateway}}')" >> "$GITHUB_ENV"
  112. docker ps -a