Commit 8fdb4f77 authored by Chris Bednarski's avatar Chris Bednarski

WIP 2/4 tests passing, still need to re-implement ZIP and bare compression...

WIP 2/4 tests passing, still need to re-implement ZIP and bare compression files and do some cleanup
parent 47bb5ae8
This diff is collapsed.
......@@ -83,6 +83,111 @@ func TestSimpleCompress(t *testing.T) {
}
}
func TestZipArchive(t *testing.T) {
if os.Getenv(env.TestEnvVar) == "" {
t.Skip(fmt.Sprintf(
"Acceptance tests skipped unless env '%s' set", env.TestEnvVar))
}
ui, artifact, err := setup(t)
if err != nil {
t.Fatalf("Error bootstrapping test: %s", err)
}
if artifact != nil {
defer artifact.Destroy()
}
tpl, err := template.Parse(strings.NewReader(tarTestCase))
if err != nil {
t.Fatalf("Unable to parse test config: %s", err)
}
compressor := PostProcessor{}
compressor.Configure(tpl.PostProcessors[0][0].Config)
artifactOut, _, err := compressor.PostProcess(ui, artifact)
if err != nil {
t.Fatalf("Failed to archive artifact: %s", err)
}
// Cleanup after the test completes
defer artifactOut.Destroy()
// Verify things look good
_, err = os.Stat("package.zip")
if err != nil {
t.Errorf("Unable to read archive: %s", err)
}
}
func TestTarArchive(t *testing.T) {
if os.Getenv(env.TestEnvVar) == "" {
t.Skip(fmt.Sprintf(
"Acceptance tests skipped unless env '%s' set", env.TestEnvVar))
}
ui, artifact, err := setup(t)
if err != nil {
t.Fatalf("Error bootstrapping test: %s", err)
}
if artifact != nil {
defer artifact.Destroy()
}
tpl, err := template.Parse(strings.NewReader(tarTestCase))
if err != nil {
t.Fatalf("Unable to parse test config: %s", err)
}
compressor := PostProcessor{}
compressor.Configure(tpl.PostProcessors[0][0].Config)
artifactOut, _, err := compressor.PostProcess(ui, artifact)
if err != nil {
t.Fatalf("Failed to archive artifact: %s", err)
}
// Cleanup after the test completes
defer artifactOut.Destroy()
// Verify things look good
_, err = os.Stat("package.tar")
if err != nil {
t.Errorf("Unable to read archive: %s", err)
}
}
func TestCompressOptions(t *testing.T) {
if os.Getenv(env.TestEnvVar) == "" {
t.Skip(fmt.Sprintf(
"Acceptance tests skipped unless env '%s' set", env.TestEnvVar))
}
ui, artifact, err := setup(t)
if err != nil {
t.Fatalf("Error bootstrapping test: %s", err)
}
if artifact != nil {
defer artifact.Destroy()
}
tpl, err := template.Parse(strings.NewReader(zipTestCase))
if err != nil {
t.Fatalf("Unable to parse test config: %s", err)
}
compressor := PostProcessor{}
compressor.Configure(tpl.PostProcessors[0][0].Config)
artifactOut, _, err := compressor.PostProcess(ui, artifact)
if err != nil {
t.Fatalf("Failed to archive artifact: %s", err)
}
// Cleanup after the test completes
defer artifactOut.Destroy()
// Verify things look good
_, err = os.Stat("package.gz")
if err != nil {
t.Errorf("Unable to read archive: %s", err)
}
}
const simpleTestCase = `
{
"post-processors": [
......@@ -93,3 +198,38 @@ const simpleTestCase = `
]
}
`
const zipTestCase = `
{
"post-processors": [
{
"type": "compress",
"output": "package.zip"
}
]
}
`
const tarTestCase = `
{
"post-processors": [
{
"type": "compress",
"output": "package.tar"
}
]
}
`
const optionsTestCase = `
{
"post-processors": [
{
"type": "compress",
"output": "package.gz",
"level": 9,
"parallel": false
}
]
}
`
......@@ -15,17 +15,46 @@ archive.
## Configuration
The configuration for this post-processor is extremely simple.
The minimal required configuration is to specify the output file. This will create a gzipped tarball.
* `output` (string) - The path to save the compressed archive.
* `output` (required, string) - The path to save the compressed archive. The archive format is inferred from the filename. E.g. `.tar.gz` will be a gzipped tarball. `.zip` will be a zip file.
If the extension can't be detected tar+gzip will be used as a fallback.
If you want more control over how the archive is created you can specify the following settings:
* `level` (optional, integer) - Specify the compression level, for algorithms that support it. Value from -1 through 9 inclusive. 9 offers the smallest file size, but takes longer
* `keep_input_artifact` (optional, bool) - Keep source files; defaults to false
## Supported Formats
Supported file extensions include `.zip`, `.tar`, `.gz`, `.tar.gz`, `.lz4` and `.tar.lz4`.
## Example
An example is shown below, showing only the post-processor configuration:
Some minimal examples are shown below, showing only the post-processor configuration:
```json
{
"type": "compress",
"output": "archive.tar.gz"
}
```
```json
{
"type": "compress",
"output": "archive.zip"
}
```
A more complex example, again showing only the post-processor configuration:
```javascript
```json
{
"type": "compress",
"output": "foo.tar.gz"
"output": "archive.gz",
"compression": 9,
"parallel": false
}
```
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment