Skip to content

Commit

Permalink
Merged master
Browse files Browse the repository at this point in the history
  • Loading branch information
sonofmun committed May 24, 2017
2 parents 1b2376b + 28741bd commit f2236b4
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.3 - 2017-05-12

Made the creation of the tar archive on build an option with the --tar flag.

## 1.0.2 - 2017-05-04

Enabled the URNs for the "commentary" type to be found in the metadata files and, thus, to show up in the inventory
Expand Down
15 changes: 8 additions & 7 deletions HookTest/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Build(object):
:type dest: str
"""

def __init__(self, path, dest):
def __init__(self, path, dest, tar=False):

if path.endswith('/'):
self.path = path
Expand All @@ -27,6 +27,7 @@ def __init__(self, path, dest):
self.dest = dest
else:
self.dest = dest + '/'
self.tar = tar

def repo_file_list(self):
""" Build the list of XML files for the source repo represented by self.path
Expand Down Expand Up @@ -105,11 +106,11 @@ def run(self):
return False, 'The manifest file is empty.\nStopping build.'
self.remove_failing(self.repo_file_list(), passing)
self.plain_text()
to_zip = [x for x in glob('{}*'.format(self.dest))]
with tarfile.open("{}release.tar.gz".format(self.dest), mode="w:gz") as f:
for file in sorted(to_zip):
f.add(file)

if self.tar is True:
to_zip = [x for x in glob('{}*'.format(self.dest))]
with tarfile.open("{}release.tar.gz".format(self.dest), mode="w:gz") as f:
for file in sorted(to_zip):
f.add(file)
return True, 'Build successful.'


Expand All @@ -122,7 +123,7 @@ def cmd(**kwargs):
:rtype:
"""
if kwargs['travis'] is True:
status, message = Travis(path=kwargs['path'], dest=kwargs['dest']).run()
status, message = Travis(path=kwargs['path'], dest=kwargs['dest'], tar=kwargs['tar']).run()
return status, message
else:
return False, 'You cannot run build on the base class'
1 change: 1 addition & 0 deletions HookTest/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def parse_args_build(args):
default='./'
)
parser.add_argument("--travis", help="Run build on Travis or similar CI environment", action="store_true", default=False)
parser.add_argument("--tar", help="Build a tar archive of the passing files", action="store_true", default=False)

args = parser.parse_args(args)
return args
Expand Down
16 changes: 8 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,23 +121,23 @@ Once you have done this, you will need to add a `.travis.yml` file to root folde
- '3.5'
install:
- pip3 install HookTest
script: hooktest --scheme epidoc --workers 3 --verbose --manifest --console --countword --allowfailure ./
script: hooktest ./ --console table --scheme epidoc --workers 3 --verbose 5 --manifest --countword --allowfailure ./
before_deploy:
- hooktest-build --travis ./
- results=$(cat manifest.txt)
- DATE=`date +%Y-%m-%d`
- git config --global user.email "builds@travis-ci.com"
- git config --global user.name "Travis CI"
- export GIT_TAG=$major_version.$minor_version.$TRAVIS_BUILD_NUMBER
- git add -A
- git rm --cached =*
- git tag $GIT_TAG -a -m "$DATE" -m "PASSING FILES" -m "$results"
- git push -q https://$GITPERM@github.com/YOUR_REPOSITORY_NAME --tags
- ls -R
deploy:
provider: releases
api_key:
secure: YOUR_SECURE_GITHUB_OATH_TOKEN
file: release.tar.gz
api_key: $GITPERM
skip_cleanup: true
on:
repo: YOUR_REPOSITORY_NAME
Expand Down Expand Up @@ -177,6 +177,8 @@ This line runs HookTest. The parameters are those described in the parameter tab
- git config --global user.email "builds@travis-ci.com"
- git config --global user.name "Travis CI"
- export GIT_TAG=$major_version.$minor_version.$TRAVIS_BUILD_NUMBER
- git add -A
- git rm --cached =*
- git tag $GIT_TAG -a -m "$DATE" -m "PASSING FILES" -m "$results"
- git push -q https://$GITPERM@github.com/YOUR_REPOSITORY_NAME --tags
- ls -R
Expand All @@ -189,9 +191,7 @@ The second important change to this line is to replace the string "YOUR_REPOSITO
deploy:
provider: releases
api_key:
secure: YOUR_SECURE_GITHUB_OATH_TOKEN
file: release.tar.gz
api_key: $GITPERM
skip_cleanup: true
on:
repo: YOUR_REPOSITORY_NAME
Expand All @@ -202,7 +202,7 @@ The second important change to this line is to replace the string "YOUR_REPOSITO
major_version: 0
minor_version: 0
These lines define the deployment and release of your repository to Github. They will zip all of the passing files into the `release.tar.gz` file and then create a release on Github that has as its lable the major_version.minor_version.$TRAVIS_BUILD_NUMBER. You should set the major_version and minor_version environment variables to match the release status of your repository. Besides the major_version and minor_version environment variables, there are two other changes that you should make to these lines for each individual repository. The first is to replace the string "YOUR_SECURE_GITHUB_OATH_TOKEN" with an encrypted Github OAuth token that is produced by Travis for precisely this purpose. See the documentation at https://docs.travis-ci.com/user/deployment/releases/#Authenticating-with-an-Oauth-token to find out how to produce such an encrypted OAuth token. We suggest that you first remove the `deploy` section from your `.travis.yml` file, then use the `travis setup releases` command to produce a `deploy` section that is tailored to your repository, and then add the missing lines from the `deploy` code block above to finish the file off.
These lines define the deployment and release of your repository to Github. They will create a release on Github that has as its lable the major_version.minor_version.$TRAVIS_BUILD_NUMBER. You should set the major_version and minor_version environment variables to match the release status of your repository.

Once you have created and tailored this `.travis.yml` file to your repository, you should then push it to your Github corpus repository. If you have set up Travis to test with repository, as described above, then Travis should read this `.travis.yml` file and automatically run HookTest and, if appropriate, build your first automatic release for the repository.

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name='HookTest',
version="1.0.2",
version="1.0.3",
description='Hook Test Script for GitHub/CapiTainS repositories',
long_description=long_description,
url='http://github.com/Capitains/HookTest',
Expand Down
9 changes: 8 additions & 1 deletion tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,17 @@ def test_remove_failing_all(self):
def test_tar_contents(self):
""" Compares the contents of the release.tar.gz file produced to the expected contents"""
self.createTestDir('tests/100PercentRepo')
HookTest.build.Travis(path=self.TESTDIR, dest=self.TESTDIR).run()
HookTest.build.Travis(path=self.TESTDIR, dest=self.TESTDIR, tar=True).run()
self.assertTrue(os.path.isfile(self.TESTDIR + 'release.tar.gz'))
with tarfile.open(self.TESTDIR + 'release.tar.gz', mode='r:gz') as f:
self.assertCountEqual(f.getnames(), self.tar_contents)

def test_no_tar(self):
""" Tests to make sure no tar file for the repo is created if tar is False"""
self.createTestDir('tests/100PercentRepo')
HookTest.build.Travis(path=self.TESTDIR, dest=self.TESTDIR, tar=False).run()
self.assertFalse(os.path.isfile(self.TESTDIR + 'release.tar.gz'))

def test_base_class(self):
""" Tests to make sure a build run on the base class returns and error"""
self.createTestDir('tests/emptyDir')
Expand Down

0 comments on commit f2236b4

Please sign in to comment.