Skip to content

Commit

Permalink
Merge pull request #87 from cyberark/update-go-version
Browse files Browse the repository at this point in the history
Update go version
  • Loading branch information
BradleyBoutcher committed Jan 28, 2021
2 parents 99e6490 + dc730b5 commit f47f4ae
Show file tree
Hide file tree
Showing 23 changed files with 389 additions and 224 deletions.
7 changes: 4 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ test:
artifacts:
untracked: true
reports:
junit: output/junit.xml
junit: output/junit-1.15.xml
when: always
script:
- apk add --no-cache py-pip
- pip install docker-compose
- ./test.sh oss
- export TEST_VERSION=oss
- ./test.sh 1.15
only:
- branches

Expand All @@ -29,7 +30,7 @@ package:
variables:
DOCKER_DRIVER: overlay2
script:
- ./package.sh
- ./bin/package.sh
only:
- branches
dependencies:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Updated Go versions to 1.15

## [0.6.1] - 2020-12-02
### Changed
Expand Down
57 changes: 51 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,61 @@ From here your pull request will be reviewed and once you've responded to all
feedback it will be merged into the project. Congratulations, you're a
contributor!

## Development (docker-compose)
## Development
To start developing and testing using our development scripts ,
the following tools need to be installed:

Kick off your TDD (i.e. goconvey powered) development environment as follows:
- Docker
- docker-compose

```bash
# goconvey will run as a background process
./dev
### Running tests

To run the test suite, run:
```shell
./bin/test.sh
```

This will spin up a containerized Conjur environment and build the test containers,
and will run all tests.

To run the tests against a specific version of Golang, you can run the following:
```shell
./bin/test.sh 1.14
```

Visit localhost:8080 to see the test results in real time.
This will spin up a containerized Conjur environment and build the test containers,
and will run the tests in a `golang:1.14` container

Supported arguments are `1.14` and `1.15`, with the
default being `1.15` if no argument is given.

To run just the tests against just the OSS version of Conjur, run:

```shell
export TEST_VERSION="oss"
# This will spin up a containerized Conjur oss
./bin/test.sh <version>
```

Possible values for `TEST_VERSION` are `oss` and `all`, with `all`
being the default.

### Setting up a development environment
To start a container with terminal access, and the necessary
test running dependencies installed, run:

```shell
./bin/dev.sh
```

You can then run the following command from the container terminal to run
all tests:

```shell
go test -coverprofile="output/c.out" -v ./... | tee output/junit.output;
exit_code=$?;
echo "Exit code: $exit_code"
```

## Releasing

Expand Down
16 changes: 9 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
FROM golang:1.13-alpine
ARG FROM_IMAGE="golang:1.15"
FROM ${FROM_IMAGE}
MAINTAINER Conjur Inc.

CMD /bin/bash
EXPOSE 8080

RUN apk add --no-cache bash \
gcc \
git \
jq \
less \
libc-dev
RUN apt update -y && \
apt install -y bash \
gcc \
git \
jq \
less \
libc-dev

RUN go get -u github.com/jstemmer/go-junit-report && \
go get -u github.com/smartystreets/goconvey && \
Expand Down
26 changes: 18 additions & 8 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,34 @@ pipeline {
stage('Validate') {
parallel {
stage('Changelog') {
steps { sh './parse-changelog.sh' }
steps { sh './bin/parse-changelog.sh' }
}
}
}

stage('Run tests') {
steps {
sh './test.sh'
sh 'mv output/c.out .'
junit 'output/junit.xml'
cobertura autoUpdateHealth: true, autoUpdateStability: true, coberturaReportFile: 'output/coverage.xml', conditionalCoverageTargets: '30, 0, 0', failUnhealthy: true, failUnstable: false, lineCoverageTargets: '30, 0, 0', maxNumberOfBuilds: 0, methodCoverageTargets: '30, 0, 0', onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false
ccCoverage("gocov", "--prefix github.com/cyberark/conjur-api-go")
parallel {
stage("Golang 1.14") {
steps {
sh './bin/test.sh 1.14'
junit 'output/1.14/junit.xml'
}
}
stage("Golang 1.15") {
steps {
sh './bin/test.sh 1.15'
junit 'output/1.15/junit.xml'
cobertura autoUpdateHealth: true, autoUpdateStability: true, coberturaReportFile: 'output/1.15/coverage.xml', conditionalCoverageTargets:'30, 0, 0', failUnhealthy: true, failUnstable: false, lineCoverageTargets: '30, 0, 0', maxNumberOfBuilds: 0, methodCoverageTargets: '30, 0, 0', onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false
sh 'cp output/1.15/c.out .'
ccCoverage("gocov", "--prefix github.com/cyberark/conjur-api-go")
}
}
}
}

stage('Package distribution tarballs') {
steps {
sh './package.sh'
sh './bin/package.sh'
archiveArtifacts artifacts: 'output/dist/*', fingerprint: true
}
}
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ compatibility. When possible, upgrade your Conjur version to match the
when using integrations, choose the latest suite release that matches your Conjur version. For any
questions, please contact us on [Discourse](https://discuss.cyberarkcommons.org/c/conjur/5).

## Compatability

The `conjur-api-go` has been tested against the following Go versions:

- 1.14
- 1.15

## Installation

```
Expand Down
83 changes: 0 additions & 83 deletions _setup.sh

This file was deleted.

5 changes: 5 additions & 0 deletions bin/convey.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

cd "$(dirname "$0")"

goconvey -host 0.0.0.0 ../conjurapi
21 changes: 21 additions & 0 deletions bin/dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash -ex

cd "$(dirname "$0")"
. ./utils.sh

source ./start-conjur.sh

docker-compose build dev
docker-compose run --no-deps -d dev

# When we start the dev container, it mounts the top-level directory in
# the container. This excludes the vendored dependencies that got
# installed during the build, so reinstall them.
exec_on dev go mod download

# Start interactive container
docker exec -it \
-e CONJUR_AUTHN_API_KEY \
-e CONJUR_V4_AUTHN_API_KEY \
-e CONJUR_V4_SSL_CERTIFICATE \
"$(docker-compose ps -q dev)" /bin/bash
23 changes: 23 additions & 0 deletions bin/package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash -e

cd "$(dirname "$0")"

echo "==> Packaging..."
build_dir="../output/dist"
rm -rf "$build_dir"
mkdir -p "$build_dir"

tar --exclude='../.git' --exclude='../output' -cvzf "$build_dir/conjur-api-go.tar.gz" .

# # Make the checksums
echo "==> Checksumming..."
pushd "$build_dir"
if which sha256sum; then
sha256sum * > SHA256SUMS.txt
elif which shasum; then
shasum -a256 * > SHA256SUMS.txt
else
echo "couldn't find sha256sum or shasum"
exit 1
fi
popd
3 changes: 1 addition & 2 deletions parse-changelog.sh → bin/parse-changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
cd "$(dirname "$0")"

docker run --rm \
-v "$PWD/.:/work" \
-v "$(pwd)/..:/work" \
-w "/work" \
ruby:2.5 bash -ec "
gem install -N parse_a_changelog
parse ./CHANGELOG.md
"

0 comments on commit f47f4ae

Please sign in to comment.