development-environment.yml 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. name: dev env
  2. on:
  3. pull_request:
  4. paths:
  5. - 'Makefile'
  6. - '.github/workflows/development-environment.yml'
  7. - '.envrc'
  8. - 'Brewfile'
  9. - 'scripts/*'
  10. - 'src/sentry/runner/commands/devserver.py'
  11. - 'src/sentry/runner/commands/devservices.py'
  12. jobs:
  13. dev-environment:
  14. name: set up
  15. runs-on: ${{ matrix.os }}
  16. timeout-minutes: 40
  17. strategy:
  18. matrix:
  19. # macosx-11.0 is Big Sur, however, it takes long for jobs to get started
  20. # Using Ubuntu 18 until I figure out this error:
  21. # -> ImportError: libffi.so.6: cannot open shared object file: No such file or directory
  22. os: [ macos-11.0, ubuntu-18.04 ]
  23. fail-fast: false
  24. env:
  25. PIP_DISABLE_PIP_VERSION_CHECK: on
  26. # Make the environment more similar to what Mac defaults to
  27. SHELL: /bin/zsh
  28. steps:
  29. - name: Checkout sentry
  30. uses: actions/checkout@v2
  31. - name: Install prerequisites
  32. # Xcode CLI & brew are already installed, thus, no need to call xcode-select install
  33. # Sometimes, brew needs to be updated before brew bundle would work
  34. # After installing Docker (via homebrew) we need to make sure that it is properly initialized on Mac
  35. run: |
  36. brew update -q && brew bundle -q
  37. # This code is mentioned in our dev docs. Only remove if you adjust the docs as well
  38. SENTRY_NO_VENV_CHECK=1 ./scripts/do.sh init-docker
  39. # The next few steps are to set up the cache quickly
  40. - name: Set environment variables & others
  41. id: info
  42. run: |
  43. echo "::set-output name=python-version::$(cat .python-version)"
  44. echo "::set-output name=pip-cache-dir::$(pip3 cache dir)"
  45. echo "::set-output name=pip-version::$(pip -V | awk -F ' ' '{print $2}')"
  46. echo "::set-output name=yarn-cache-dir::$(yarn cache dir)"
  47. # In a sense, we set up Python two times (once here and once via pyenv). Setting
  48. # it up here is instant and it helps us to get the cache primed sooner
  49. - name: Setup Python
  50. uses: actions/setup-python@v2
  51. with:
  52. python-version: ${{ steps.info.outputs.python-version }}
  53. - name: Cache (pyenv)
  54. uses: actions/cache@v2
  55. with:
  56. path: ~/.pyenv
  57. key: devenv-${{ matrix.os }}-pyenv-${{ hashFiles('.python-version') }}
  58. restore-keys: |
  59. devenv-${{ matrix.os }}-pyenv-
  60. - name: Cache (pip)
  61. uses: actions/cache@v2
  62. with:
  63. path: ${{ steps.info.outputs.pip-cache-dir }}
  64. key: devenv-${{ matrix.os }}-py${{ steps.info.outputs.python-version }}-pip${{ steps.info.outputs.pip-version }}-${{ hashFiles('**/requirements.txt') }}
  65. restore-keys: |
  66. devenv-${{ matrix.os }}-py${{ steps.info.outputs.python-version }}-pip${{ steps.info.outputs.pip-version }}-
  67. - name: Cache (yarn)
  68. uses: actions/cache@v2
  69. id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
  70. with:
  71. path: ${{ steps.info.outputs.yarn-cache-dir }}
  72. key: devenv-${{ matrix.os }}-yarn-${{ hashFiles('yarn.lock') }}
  73. restore-keys: |
  74. devenv-${{ matrix.os }}-yarn-
  75. - name: Set up development environment (mostly as per docs)
  76. run: |
  77. curl https://get.volta.sh | bash
  78. export VOLTA_HOME="$HOME/.volta"
  79. export PATH="$HOME/.volta/bin:$PATH"
  80. make setup-pyenv
  81. eval "$(pyenv init --path)"
  82. python -m venv .venv
  83. source .venv/bin/activate
  84. make bootstrap
  85. - name: Test direnv
  86. run: |
  87. brew install direnv
  88. direnv allow