on-create-command.sh 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. mkdir -p $gclient_root/.git-cache
  10. rm -f $buildtools/configs
  11. ln -s $buildtools_configs $buildtools/configs
  12. # Write the gclient config if it does not already exist
  13. if [ ! -f $gclient_root/.gclient ]; then
  14. echo "Creating gclient config"
  15. echo "solutions = [
  16. { \"name\" : \"src/electron\",
  17. \"url\" : \"https://github.com/electron/electron\",
  18. \"deps_file\" : \"DEPS\",
  19. \"managed\" : False,
  20. \"custom_deps\" : {
  21. },
  22. \"custom_vars\": {},
  23. },
  24. ]
  25. " >$gclient_root/.gclient
  26. fi
  27. # Write the default buildtools config file if it does
  28. # not already exist
  29. if [ ! -f $buildtools/configs/evm.testing.json ]; then
  30. echo "Creating build-tools testing config"
  31. write_config() {
  32. echo "
  33. {
  34. \"goma\": \"$1\",
  35. \"root\": \"/workspaces/gclient\",
  36. \"remotes\": {
  37. \"electron\": {
  38. \"origin\": \"https://github.com/electron/electron.git\"
  39. }
  40. },
  41. \"gen\": {
  42. \"args\": [
  43. \"import(\\\"//electron/build/args/testing.gn\\\")\",
  44. \"import(\\\"/home/builduser/.electron_build_tools/third_party/goma.gn\\\")\"
  45. ],
  46. \"out\": \"Testing\"
  47. },
  48. \"env\": {
  49. \"CHROMIUM_BUILDTOOLS_PATH\": \"/workspaces/gclient/src/buildtools\",
  50. \"GIT_CACHE_PATH\": \"/workspaces/gclient/.git-cache\"
  51. },
  52. \"\$schema\": \"file:///home/builduser/.electron_build_tools/evm-config.schema.json\"
  53. }
  54. " >$buildtools/configs/evm.testing.json
  55. }
  56. # Start out as cache only
  57. write_config cache-only
  58. e use testing
  59. # Attempt to auth to the goma service via codespaces tokens
  60. # if it works we can use the goma cluster
  61. export NOTGOMA_CODESPACES_TOKEN=$GITHUB_TOKEN
  62. if e d goma_auth login; then
  63. echo "$GITHUB_USER has GOMA access - switching to cluster mode"
  64. write_config cluster
  65. fi
  66. else
  67. echo "build-tools testing config already exists"
  68. # Re-auth with the goma cluster regardless.
  69. NOTGOMA_CODESPACES_TOKEN=$GITHUB_TOKEN e d goma_auth login || true
  70. fi