From 0258d8a8607606e9b4c2bb99ede62e7eee94b8ab Mon Sep 17 00:00:00 2001 From: Ash McKenzie Date: Wed, 5 Jun 2019 10:07:35 +1000 Subject: [PATCH 1/3] Add Makefile for easier building and testing --- Makefile | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..e9a81b2e2 --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +.PHONY: test test_ruby test_ruby_rubocop test_ruby_rspec test_go test_go_format test_go_test + +validate: verify test + +verify: verify_ruby verify_golang + +verify_ruby: + bundle exec rubocop + +verify_golang: + support/go-format check + +test: test_ruby test_golang + +test_ruby: + # bin/gitlab-shell must exist and needs to be the Ruby version for + # rspec to be able to test. + cp bin/gitlab-shell-ruby bin/gitlab-shell + bundle exec rspec --color --tag '~go' --format d spec + rm -f bin/gitlab-shell + +test_golang: + support/go-test + +setup: compile +build: compile +compile: + bin/install + bin/compile + +check: + bin/check + +clean: + rm -f bin/gitlab-shell -- GitLab From 2b4aaab11d880942f41825ecd4730f5131acec8e Mon Sep 17 00:00:00 2001 From: Ash McKenzie Date: Thu, 27 Jun 2019 23:22:53 +1000 Subject: [PATCH 2/3] Use new Makefile targets in .gitlab-ci.yml --- .gitlab-ci.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0b91d44fd..6bbd334ba 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,8 +15,7 @@ before_script: # primarily regression tests for particular versions of Ruby. # # The full rspec suite is also run against each suppported golang version - - cp bin/gitlab-shell-ruby bin/gitlab-shell - - bundle exec rspec --color --tag ~go --format d spec + - make test_ruby rspec: <<: *rspec_definition @@ -25,9 +24,9 @@ rspec: except: - tags -rubocop: +verify_ruby: script: - - bundle exec rubocop + - make verify_ruby tags: - ruby except: @@ -77,13 +76,11 @@ rspec:ruby2.1: script: - go version - which go - - bin/compile - - support/go-test - - support/go-format check + - make build verify_golang test_golang # Run the full Ruby test suite in the "go" tests. As more functionality is # migrated into these tests and out of Ruby, the amount of work here will # reduce - - bundle exec rspec --color --format d spec + - make test_ruby go:1.11: <<: *go_definition @@ -111,7 +108,6 @@ codequality: artifacts: paths: [codeclimate.json] - sast: image: docker:stable variables: -- GitLab From fdfc4ab091ad5baed7486046873bb16765054f7f Mon Sep 17 00:00:00 2001 From: Ash McKenzie Date: Thu, 27 Jun 2019 23:33:50 +1000 Subject: [PATCH 3/3] Update README to include new Makefile targets --- README.md | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index c22ca28c7..806de08fb 100644 --- a/README.md +++ b/README.md @@ -15,15 +15,15 @@ If you access a GitLab server over HTTP(S) you end up in [gitlab-workhorse](http An overview of the four cases described above: -1. git pull over ssh -> gitlab-shell -> API call to gitlab-rails (Authorization) -> accept or decline -> establish Gitaly session -1. git push over ssh -> gitlab-shell (git command is not executed yet) -> establish Gitaly session -> (in Gitaly) gitlab-shell pre-receive hook -> API call to gitlab-rails (authorization) -> accept or decline push +1. git pull over SSH -> gitlab-shell -> API call to gitlab-rails (Authorization) -> accept or decline -> establish Gitaly session +1. git push over SSH -> gitlab-shell (git command is not executed yet) -> establish Gitaly session -> (in Gitaly) gitlab-shell pre-receive hook -> API call to gitlab-rails (authorization) -> accept or decline push ## Git hooks The gitlab-shell repository used to also contain the Git hooks that allow GitLab to validate Git pushes (e.g. "is this user allowed to push to this protected branch"). These hooks also trigger -events in GitLab (e.g. to start a CI pipeline after a push). +events in GitLab (e.g. to start a CI pipeline after a push). We are in the process of moving these hooks to Gitaly, because Git hooks require direct disk access to Git repositories, and that is only @@ -68,12 +68,13 @@ To install gitlab-shell you also need a Go compiler version 1.8 or newer. https: ## Setup - ./bin/install - ./bin/compile + make setup ## Check - ./bin/check +Checks if GitLab API access and redis via internal API can be reached: + + make check ## Keys @@ -89,14 +90,27 @@ List all keys: ./bin/gitlab-keys list-keys - Remove all keys from authorized_keys file: ./bin/gitlab-keys clear +## Testing + +Run Ruby and Golang tests: + + make test + +Run Rubocop and gofmt: + + make verify + +Run both test and verify (the default Makefile target): + + make validate + ## Git LFS remark -Starting with GitLab 8.12, GitLab supports Git LFS authentication through ssh. +Starting with GitLab 8.12, GitLab supports Git LFS authentication through SSH. ## Migration to Go feature flags @@ -158,14 +172,14 @@ Rails application: ## Updating VCR fixtures -In order to generate new VCR fixtures you need to have a local GitLab instance -running and have next data: +In order to generate new VCR fixtures you need to have a local GitLab instance +running and have next data: 1. gitlab-org/gitlab-test project. 2. SSH key with access to the project and ID 1 that belongs to Administrator. 3. SSH key without access to the project and ID 2. -You also need to modify `secret` variable at `spec/gitlab_net_spec.rb` so tests +You also need to modify `secret` variable at `spec/gitlab_net_spec.rb` so tests can connect to your local instance. ## Contributing -- GitLab