Collector Jira Workflow
Set up
- Install go version 1.19.x, golangci-lint
- Run
npm i
. - Use
go mod edit -module <your module name>
to change the name of your go project ingo.mod
(don't need to do this step unless you want to change the module name of your project). - Setting up VSCode linting intellisense (Optional):
- Go to Go extension in marketplace (install go extension by "Go Team at Google")
- Click on the settings icon
- Click
Extension Settings
- Scroll all the way down and click
Edit settings.json
- Add these two lines:
"go.lintTool": "golangci-lint", "go.lintFlags": [ "--fast"
.husky/pre-commit
hook runs linting with golangci-lint version `v1.46.2` in a docker container as of this writing, but that can be configured to your liking, as well as forked and configured. Ultimately, this pre commit hook golangci-lint version will be the linting version you should be targetting. - Happy coding.
How to run Benchmark test comparison between two versions
First off you will need to install benchstat for go. Then you can do the following:
- Write the benchmark test in a file, and run the command
-
go test -bench=<BenchmarkFunctionName> -benchmem -count 5 -run=^# ./... | tee performance/old.txt
for your old implementation, andgo test -bench=<BenchmarkFunctionName> -benchmem -count 5 -run=^# ./... | tee performance/new.txt
for your new implementation where only the implementation called in the benchmark is changed. - run
/path/to/benchstat performance/old.txt performance/new.txt > performance/last-diff.txt
(running this command from the main repo path), and you have a decreasing delta on the new version, you are doing better than in performance than the old version for (speed, memory etc.)
name | old time/op | new time/op | delta | |
---|---|---|---|---|
CollectRepositories/it_should_collect_and_prune_repositories-12 | 1.60ms ±47% | 1.59ms ±47% | ~ | (p=0.690 n=5+5) |
name | old alloc/op | new alloc/op | delta | |
---|---|---|---|---|
CollectRepositories/it_should_collect_and_prune_repositories-12 | 4.42MB ±54% | 4.40MB ±54% | ~ | (p=0.690 n=5+5) |
name | old alloc/op | new alloc/op | delta | |
---|---|---|---|---|
CollectRepositories/it_should_collect_and_prune_repositories-12 | 354 ± 0% | 353 ± 0% | -0.28% | (p=0.008 n=5+5) |
- Don't forget to remove old.txt and new.txt before commiting.
e2e tests
We are using cypress for our e2e tests. You can
run cypress in dev mode by first starting your dev
environment, and running npx cypress run --config-file cypress/config/development.json
(This won't work right now since
we are still on Cypress9. The way to test e2e on dev
manually at the moment is to install cypress version 9.7.0--which might ot work on everyone's computer--as
dev dependency and run npm run test:e2e
. This command needs to go away after the migration). For e2e
tests in pipeline, we do not need any of the dependencies, and
just package.json
which has the scripts command npm run test:e2e-ci
which uses pipeline's cypress.
Additionally, if you have multiple containers of this
collector deployed, you can simply fill in the configuration
for each instance deployment based on starting url of your
gitlab for deploymentInstances
. This configuration is
found for cypress in cypress/config/pipeline.json
and cypress/config/development.json