summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2019-06-27 14:30:49 +0000
committerNick Thomas <nick@gitlab.com>2019-06-27 14:30:49 +0000
commit7b23c6f01c06de45e97f49ab0557e551a6c1edf0 (patch)
treef216a5e317a2c75afb116449c664d88d619377ac
parente896becc9f6ee5ce9b134c32d7784f7c408bb50e (diff)
parentfdfc4ab091ad5baed7486046873bb16765054f7f (diff)
downloadgitlab-shell-7b23c6f01c06de45e97f49ab0557e551a6c1edf0.tar.gz
Merge branch '194-add-makefile-to-make-things-easier' into 'master'
Add Makefile for easier building and testing Closes #194 See merge request gitlab-org/gitlab-shell!310
-rw-r--r--.gitlab-ci.yml14
-rw-r--r--Makefile35
-rw-r--r--README.md36
3 files changed, 65 insertions, 20 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0b91d44..6bbd334 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:
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..e9a81b2
--- /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
diff --git a/README.md b/README.md
index c22ca28..806de08 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