action.yml 5.1 KB

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