on-create-command.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/bin/bash
  2. set -eo pipefail
  3. buildtools=$HOME/.electron_build_tools
  4. gclient_root=/workspaces/gclient
  5. buildtools_configs=/workspaces/buildtools-configs
  6. export PATH="$PATH:$buildtools/src"
  7. # Create the persisted buildtools config folder
  8. mkdir -p $buildtools_configs
  9. rm -f $buildtools/configs
  10. ln -s $buildtools_configs $buildtools/configs
  11. # Write the gclient config if it does not already exist
  12. if [ ! -f $gclient_root/.gclient ]; then
  13. echo "solutions = [
  14. { \"name\" : \"src/electron\",
  15. \"url\" : \"https://github.com/electron/electron\",
  16. \"deps_file\" : \"DEPS\",
  17. \"managed\" : False,
  18. \"custom_deps\" : {
  19. },
  20. \"custom_vars\": {},
  21. },
  22. ]
  23. " >$gclient_root/.gclient
  24. fi
  25. # Write the default buildtools config file if it does
  26. # not already exist
  27. if [ ! -f $buildtools/configs/evm.testing.json ]; then
  28. write_config() {
  29. echo "
  30. {
  31. \"root\": \"/workspaces/gclient\",
  32. \"goma\": \"$1\",
  33. \"gen\": {
  34. \"args\": [
  35. \"import(\\\"//electron/build/args/testing.gn\\\")\",
  36. \"import(\\\"/home/builduser/.electron_build_tools/third_party/goma.gn\\\")\"
  37. ],
  38. \"out\": \"Testing\"
  39. },
  40. \"env\": {
  41. \"CHROMIUM_BUILDTOOLS_PATH\": \"/workspaces/gclient/src/buildtools\",
  42. \"GIT_CACHE_PATH\": \"/workspaces/gclient/.git-cache\"
  43. },
  44. \"remotes\": {
  45. \"electron\": {
  46. \"origin\": \"https://github.com/electron/electron.git\"
  47. }
  48. }
  49. }
  50. " >$buildtools/configs/evm.testing.json
  51. }
  52. # Start out as cache only
  53. write_config cache-only
  54. e use testing
  55. # Attempt to auth to the goma service via codespaces tokens
  56. # if it works we can use the goma cluster
  57. export NOTGOMA_CODESPACES_TOKEN=$GITHUB_TOKEN
  58. if e d goma_auth login; then
  59. write_config cluster
  60. fi
  61. else
  62. # Even if the config file existed we still need to re-auth with the goma
  63. # cluster
  64. NOTGOMA_CODESPACES_TOKEN=$GITHUB_TOKEN e d goma_auth login || true
  65. fi