-
Notifications
You must be signed in to change notification settings - Fork 11
Functional Testing of git semver
Functional Testing of git-semver is all about testing a series of git-semver commands and making sure that each command produces the expected result on our code changes. This can be carried out on an existing repository that has semantic versioning enabled already and as well as on a new repository.
If you see a semver
branch in a repository, that means git-semver
is enabled with tags created by following semantic versioning
guidelines on that repository.
Functional Testing of git-semver can be achieved in different ways, depending upon what you want to test. If you want to test git-semver for the changes made on main source files(like of .go files) then need to follow the below approach.
If you want to test git-semver for the changes made on supportive source files(like of Dockerfile, Jenkinsfile, go.mod files) then need to follow the below approach.
And the below approach can be used if you want to test any other pipeline or repository for semantic versioning by leveraging the git-semver nexus image
.
- Make sure that your ssh-key setup is done on github.com and you are able to test the connection by using below command,
ssh -T [email protected]
- Clone your fork of git-semver repository locally.
- Create a test repository in github.com and clone it locally.
- We will be using both of the above local clones to bind mount in further levels of the testing.
This section describes the process on how to build git-semver
from the source directly and test git-semver functionality for changes made in main source code files.
- Start the proceedings from the git-semver clone directory.
cd ~/git-semver
- Start a golang container, with required arguments.
All the testing we perform here is within the context of the container, so it should have access to git-semver source code, test repo and ssh-keys as well, so we will bind mount all these directories to different paths within the container.
docker container run \
--rm \
-it \
--env HTTP_PROXY \
--env HTTPS_PROXY \
-e ALL_PROXY=socks5://proxy-us.intel.com:1080 \
-e SEMVER_DEBUG=on \
-v $PWD:/go/src/sandbox \
-v ~/.ssh:/root/.ssh \
-v ~/PARENT_DIR/test_repo:/test_repo \
-w /go/src/sandbox \
golang:1.12-alpine /bin/sh
- Export the required golang environment variables and build the
git-semver
.
export CGO_ENABLED=0
export GO111MODULE=on
apk add --no-cache git openssh-client
go build -v -o /usr/local/bin/git-semver
- Check the connection to GitHub with SSH, inside the container.
eval `ssh-agent`
ssh-add
apk add --update netcat-openbsd
ssh -T [email protected]
- Change to the bind mount directory of the test repository and start executing
git-semver
commands listed in below commands section.cd ~/test_repo
This section describes the process on how we can leverage the Dockerfile
available from the repository to build the git-semver
and test git-semver functionality for changes made in supportive source code files.
- Change to git-semver clone directory, build the docker image based out on the Dockerfile and tag it as
gitsemver:latest
.
cd ~/git-semver
docker image build \
--build-arg http_proxy \
--build-arg https_proxy \
-t gitsemver:latest .
- Start the container with the image we built, by providing required arguments.
All the testing we perform here is within the context of the container, so it should have access to git-semver source code, test repo and ssh-keys as well, so we will bind mount all these directories to different paths within the container.
docker container run \
--rm \
-it \
--env http_proxy \
--env https_proxy \
-e ALL_PROXY=socks5://proxy-us.intel.com:1080 \
-e SEMVER_DEBUG=on \
-v $PWD:/go/src/sandbox \
-v ~/.ssh:/root/.ssh \
-v ~/PARENT_DIR/test_repo:/test_repo \
-w /go/src/sandbox \
gitsemver:latest /bin/sh
- Check the connection to GitHub with SSH, inside the container.
eval `ssh-agent`
ssh-add
ssh -T [email protected]
- Change to the bind mount directory of the test repository and start executing
git-semver
commands listed in below commands section.cd ~/test_repo
If we are not actually testing the code changes in any of the source files, but wanted to leverage the git-semver
for testing any of the edgex-global-pipelines
, then we can follow this approach.
Here we take the image from Nexus repo, which was thoroughly tested with all functionalities.
- Start the proceedings in a container by pulling the image from Nexus EdgeX Foundry repo, by providing required arguments. All the testing we perform here is within the context of the container, so it should have access to git-semver source code, test repo and ssh-keys as well.
docker container run \
--rm \
-it \
-e SEMVER_DEBUG=on \
-v ~/.ssh:/root/.ssh \
-v $PWD:/test_repo \
nexus3.edgexfoundry.org:10004/edgex-devops/git-semver:latest sh
- Check the connection to GitHub with SSH, inside the container.
eval `ssh-agent`
ssh-add
ssh -T [email protected]
- Change to the bind mount directory of the test repository and start executing
git-semver
commands listed in below commands section.cd ~/test_repo
git semver ----> test the existence of semver repo
git semver init -ver=abc.123def ----> test init with wrong semantic versioning
git semver init -ver=1.2.3-exp.456 ----> test init set valid custom version
git semver ----> test for previously set valid version to STDOUT, after a semver init
rm -rf .semver ----> remove the existing semver branch
git semver ----> STDOUT user that no git-semver repo exists, after removing .semver dir
git semver init ----> test init sets default version to 0.0.0
git semver bump pre ----> test bump pre release version
git semver bump patch ----> test bump patch version
git semver bump minor ----> test bump minor version
git semver bump major ----> test bump major version
git semver bump -pre=exp pre ----> test bump pre to set custom pre release version
git semver bump pre ----> test bump pre to next pre release version
git semver bump final ----> test bump final to remove any pre release from versioning
git semver tag ----> test tag capability to head rev. to the available version
git semver push ----> push everything to repository
git semver init -ver=3.0.0 -force ----> test init to force set the new version
git semver tag -force ----> test force tag the new version on same head revision
- More readings on
git-semver
commands can be found here. - Sample PRs to refer for functional tests: