@jreisz/mobile-releases v1.0.0
Releases 🔮 - The service that manages the release processes, makes your life easier with automations.
Introduction
Releases is agent that manage the release schedule and workflow, and trigger the right action at the right stage.
It is still under active development, currently it has the following functionalities,
- Scheduling a release and maintain multiple releases' schedule,
- Recording which release has been approved by whom,
- Keeping track of release cuts reported by the pipeline.
Upcoming features:
- Trigger initial release cut at the scheduled time,
- Monitor JIRA project MRI to trigger new RC or hotfix cuts,
Contribute
Everyone can contribute to the code base and make it better!
Prereq before setup
- Install "Developer Proxy CA Certificate Files" through Self Service
- Install "Python Proxy Config" or a Python 3.x.x policy through Self Service, ref: https://engineering.paypalcorp.com/confluence/display/InfoSec/Zscaler+-+Adding+Root+Certificates+to+Python%2C+PIP
- Install "Import Proxy Certificate into a Java JDK" through Self Service, ref: https://engineering.paypalcorp.com/confluence/display/InfoSec/Zscaler+-+Adding+Root+Certificates+to+Java%2C+JDK%2C+JRE
Dev environment setup
You need to run the following command to setup the dev environment:
make setup
Build Releases
It is highly recommended to run build every time you do one of the following:
- Adding a new Go file in any module
- Adding a new dependency
- Adding new imports in a module or between modules
make build
Run Releases
make run
Run Releases in minikube
First install the following tools:
1. Docker
2. Kubernetes
Simply brew install kubectl
3. minikube
Simply brew install minikube
Then you may want to have 3 terminal sessions running
1st terminal session
- Start minikube by running
minikube start
- Run
minikube dashboard
, it will bring up your browser - Keep this terminal session alive!
2nd terminal session (Must ONLY starts after 1st session)
1. This will be your main terminal to interact with the service locally
2. Run eval $(minikube docker-env)
3. Run make minikube
*3rd terminal session (Must ONLY starts after 2nd session succeed)
1. Run minikube service --url mobile-releases
2. Go back to 2nd terminal and try the following command:
grpcurl -plaintext -d '{"platform":"ANDROID"}' <first_URL_from_step_1> releases.Releases/ListRecentReleases
or
grpcurl -plaintext -d '{"repo":"venmo-ios/venmo"}' <first_URL_from_step_1> releases.Releases/ListRecentReleases
Quick Tips
- To stop minikube:
minikube stop
- Disaster recovering minikube:
minikube delete
- Every time you make a change in the code, do
make minikube
- If your changes didn't take any effect from 3 ↑↑↑, try the following then repeat 3 ↑↑↑:
kubectl get pods
# identify all pods and do the following on each of them:
kubectl delete pod <pod_name>
Or
kubectl delete deployment mobile-releases
- To look at the logs, do the following:
kubectl get pods
# identify the name of the pod
kubectl logs -f <pod_name> mobile-releases-grpc
- To look into MySQL database, do the following:
kubectl get pods
# identify the name of the pod
kubectl exec <pod_name> -c mysql -it -- mysql -preleases mobile_releases
Run all unit tests
make test
Use commit template and run linter checks
- After
make setup
, pre-commit and commit template should be configured - Use
git commit
instead ofgit commit -m
- Linter checks would run before popping the template to enter the commit message
- To run the pre-commit checks respectively, use
pre-commit run --all-files
Add new dependency
make adddep DEP=<the dependency and version>
For example,
make adddep DEP=go.uber.org/fx@1.13.1
Update automata
Once you made some changes in the automata yaml file, you will need to regenerate the go file,
# Get the packr2 if you don't have it locally
go get -u github.com/gobuffalo/packr/v2/packr2
# At the releases/ folder
cd releases && packr2
In releases/automata/automata-packr.go
, update the import:
-import _ "github.braintreeps.com/venmo/mobile-releases/releases/packrd"
+import _ "github.braintreeps.com/venmo/releases/packrd"
# Update BUILD.bazel files
make build
Make db schema changes
!!! Note !!! DB schema changes must be in its own PR for review!
- Make the model changes as usual in
db/models.go
, - If you are adding new model(s), make sure to update the
AutoMigrate
code indb/migrate/module.go
, - Follow the steps in "Run Releases in minikube" section to bring up the service,
- Connect to the database and make sure the schema has been changed as you expected,
- Create a PR for review.
For Visual Studio Code
Create a settings.json
under .vscode
at the root of the repo with the following template:
{
"bazel.executable": "<path to your repo root>/mobile-releases/bazelw",
"bazel.buildifierFixOnFormat": true,
"go.gopath": "${workspaceFolder}/bazel-bin/gopath",
"go.toolsGopath": "<hardcode $HOME here>/go",
"go.gocodePackageLookupMode": "bzl",
"go.toolsEnvVars": {
"GOBIN": "$HOME/go/bin"
}
}
USING GOLAND
Get a GoLand License https://venmoinc.atlassian.net/wiki/spaces/IFT/pages/1283655500/Getting+GoLand+License
When setting up the project it is suggested testradamus exist under the global gopath.
Verify your global gopath using go env
and validate it matches GOPATH defined under Goland -> preference -> Go -> GOPATH
Set your project gopath to point to bazl-bin
, this is an important step and will prevent your imports from properly applying.
Under Goland -> preferences (Mac ⌘,) -> Project GOPATH -> click the small +
and add the path to bazl-bin
(Located ${workspaceFolder}/bazel-bin/gopath
)
Additional resources In the case you see a mismatch you can set your gopath Setting gopath for
Bash:
Edit your ~/.bash_profile
to add the following line export GOPATH=$HOME/go
:
echo "export GOPATH=$HOME/go" >> ~/.bash_profile
Note: Open you can also open your ~/.bash_profile
using a text editor, paste line above and save.
$touch ~/.bash_profile; open ~/.bash_profile
You can also use other editors
$nano ~/.bash_profile
$mate ~/.bash_profile
$vim ~/.bash_profile
Fish
set -x -U GOPATH $HOME/go
Testing
Add mocks of Releases modules
- Modify
BUILD.bazel
of the module with the following example, subsitute with whatever interface you want to generate mocks:
# gazelle:exclude mock_repository.go
gomock(
name = "go_mock_source",
out = "mock_repository.go", # <- Replace this with the name of the interface that you want to mock, in the format of "mock_<interface_name>.go"
interfaces = ["Repository"], # <- Replace this with the name of the interface
library = ":go_default_library",
package = "mock",
)
go_library(
name = "go_default_mock",
srcs = ["mock_repository.go"], # <- Same as 'out' from above.
importpath = "github.braintreeps.com/venmo/releases/<module_name>/mock",
visibility = ["//visibility:public"],
deps = [ # Contains all the dependencies that the interface needs
":go_default_library",
"@com_github_golang_mock//gomock:go_default_library",
"@io_gorm_gorm//:go_default_library",
],
)
- In the consumer module, add the follow line of usage in the test code, e.g.:
import (
dbmock "github.braintreeps.com/venmo/testradamus/db/mock"
)
func TestXyz(t *testing.T) {
...
repo *dbmock.MockRepository
...
}
Run
make build
to regenerate theBUILD.bazel
Your test should be able to use the gomock now.
FAQ
Troubleshooting
1. Encountering protobuf build errors during make build
external/com_google_protobuf/src/google/protobuf/arena.cc:66:1: error: unknown type name 'GOOGLE_THREAD_LOCAL'
brew unlink protobuf
can be used to remediate the issue shown above. You can relink using brew link protobuf
2. Encountering protobuf build errors during make build
that includes 'no member named'
Example:
external/com_google_protobuf/src/google/protobuf/any.cc:53:37: error: no member named 'MutableNoArena' in 'google::protobuf::internal::ArenaStringPtr'
message.SerializeToString(value_->MutableNoArena(
~~~~~~ ^
external/com_google_protobuf/src/google/protobuf/any.cc:61:43: error: no member named 'GetNoArena' in 'google::protobuf::internal::ArenaStringPtr'
return message->ParseFromString(value_->GetNoArena());
~~~~~~ ^
Please try deleting the '/usr/local/Cellar/protobuf'
directory and running make build
again
3. Encountering protobuf download errors during make build
ERROR: An error occurred during the fetch of repository 'com_google_protobuf':
java.io.IOException: Error downloading [https://github.com/protocolbuffers/protobuf/archive/v3.12.4.tar.gz] to /private/var/tmp/_bazel_yourusername/external/com_google_protobuf/v3.12.4.tar.gz: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
First try to use your local Java JDK certificate store, follow this guide:
a. Import the certificate to your local Java JDK: https://engineering.paypalcorp.com/confluence/pages/viewpage.action?pageId=602782495
b. Add this line to `.bazelrc` under project directory. If no `.bazelrc` file, create one:
startup --host_jvm_args=-Djavax.net.ssl.trustStore='<your cacert location from step a>' --host_jvm_args=-Djavax.net.ssl.trustStorePassword='changeit'
for example: startup --host_jvm_args=-Djavax.net.ssl.trustStore='/Library/Java/JavaVirtualMachines/openjdk.jdk/Contents/Home/lib/security/cacerts' --host_jvm_args=-Djavax.net.ssl.trustStorePassword='changeit'
If the above method doesn't work, follow the below steps and contact the mobile release team:
a. https://engineering.paypalcorp.com/confluence/pages/viewpage.action?spaceKey=InfoSec&title=Zscaler+-+Enforcement+General+Exception
b. Starting from the step 3, the link there is not working, just go to MyIT and make that web proxy request
4. Encountering unknown revision errors when fetching goworkflow during make build
ERROR: An error occurred during the fetch of repository 'com_braintreeps_github_venmo_goworkflow':
failed to fetch com_braintreeps_github_venmo_goworkflow: fetch_repo: github.braintreeps.com/venmo/goworkflow@v0.0.5: invalid version: unknown revision v0.0.5
Please run
go env -w GOPRIVATE=github.braintreeps.com
git config --global --add url."git@github.braintreeps.com:".insteadOf "https://github.braintreeps.com/"
5. Encountering unable to get local issuer certificate
errors during make setup
, similar to below:
'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate
Make sure you have installed "Python Proxy Config" through self-service tool
If not working, explicit proxy setup on env variables: https://engineering.paypalcorp.com/confluence/pages/viewpage.action?pageId=587277339
6. Encountering SSL module is not available
errors during make build
, similar to below:
failed: Could not fetch URL https://pypi.org/simple/wheel/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/wheel/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping
If you are M1 chip, try to reinstall your openssl by running your terminal with Rosetta on
7. Encounter go linters not found or import troubles in pre-commit:
line 8: goimports: command not found
you may need to install them manually by
go install golang.org/x/lint/golint@latest
go install golang.org/x/tools/cmd/goimports@latest
If you still get error like goimports not installed or available in the PATH
, try put the following in your .zshrc
or .bashrc
:
export PATH="$PATH:$HOME/go/bin"
2 years ago