SmartBear / git-en-boite

Web service facade for interacting with git repos on various providers - GitHub/BitBucket/GitLab etc.
MIT License
18 stars 7 forks source link
cucumber cucumberstudio docker testrun

Test & Deploy

git-en-boite

Put git in a box to make it easy to work with in your apps.

Features

Tech stack

git-en-boite is written in Typescript, and produces a Docker image every time the tests pass on the master branch.

It's separated into multiple NPM packages which are all contained inside this repo under ./packages.

We use yarn workspaces to manage these packages.

Start the application

The following docker-compose command starts the backend HTTP API

docker-compose up

Now you can hit the service:

curl http://localhost:3001

Development

Install yarn, then install dependencies:

yarn

Set up default environment variables (assumes you're using direnv):

cp .envrc.default .envrc
direnv allow .

The integration tests need redis to be running somewhere. If you don't have or want to have it installed on your dev machine, you can spin it up in Docker:

docker-compose up --detach redis

Note for Ubuntu 20 users

On ubuntu 20, the default docker package should be replaced by the latest one to use the long syntax in docker-compose.yml

sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose -version

The version returned should be 1.27.4, build 40524192

Run tests

Build first:

yarn build

Run the tests in each of the packages:

yarn test

Debugging the acceptance tests

When the acceptance tests fail, it's often useful to debug them by logging. You can turn on logging to console like this:

LOGGING_READABLE_BY=humans yarn acceptance test

Smoke tests

Git-en-boîte ships with smoke tests that can be run against any instance of itself.

To run them, two environment variables need to be set:

Optionally, you can also set this, to test out how failures are reported in your infrastructure:

Run the smoke tests with:

yarn smoke start

Examples

To run against a locally-running instance:

smoke_tests_web_server_url=http://localhost:3001 \
    smoke_tests_remote_repo_url=https://<user>:<token>@github.com/SmartBear/git-en-boite-demo\
    yarn smoke start

Run using local containers (for both the smoke tests and the running server):

docker-compose up
smoke_tests_remote_repo_url=https://<user>:<token>@github.com/SmartBear/git-en-boite-demo \
    docker-compose run smoke-tests yarn smoke start

Releasing

Git-en-boite is automatically packaged as a new docker image each time the CI build runs succesfully on the main branch. The docker image is tagged with the git sha of the commit.

To make a semantially-versioned release of the docker-image:

  1. Make sure you've closed the GitHub issues that were in the release. This will trigger a bot workflow to update the changelog.

  2. Update the root package.json file and tag the git commit:

yarn version --major|minor|patch # choose the right switch depending on the type of changes in this release
  1. Push the new git tag and the commit updating the version:
git push && git push --tags

The build script should take care of the rest.

How to resolve "fatal: Not a git repository (or any of the parent directories): .git" issue

Remove the git-repos directory:

sudo rm -rf git-repos