Skip to content

Commit

Permalink
Cleanup for Julia 1.0 (#6)
Browse files Browse the repository at this point in the history
* Make tests pass

* Update travis file

* Update travis and AppVeyor

* Minor cleanup
  • Loading branch information
randyzwitch authored Dec 19, 2018
1 parent f18668d commit 23b3849
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 66 deletions.
39 changes: 29 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
## Documentation: http://docs.travis-ci.com/user/languages/julia/
sudo: required
language: julia

os:
- linux

notifications:
email: false

julia:
#- 0.6
- 1.0
- nightly
notifications:
email: false
git:
depth: 99999999

## uncomment the following lines to allow failures on nightly julia
## (tests will run but not make your overall status red)
matrix:
allow_failures:
- julia: nightly
allow_failures:
- julia: nightly

## uncomment and modify the following lines to manually install system packages
#addons:
# apt: # apt-get for linux
# packages:
# - gfortran
#before_script: # homebrew for mac
# - if [ $TRAVIS_OS_NAME = osx ]; then brew install gcc; fi

script:
- julia -e 'Pkg.init(); Pkg.clone(pwd()); Pkg.test("LogParser")'
## uncomment the following lines to override the default test script
#script:
# - julia -e 'Pkg.clone(pwd()); Pkg.build("LogParser"); Pkg.test("LogParser"; coverage=true)'
after_success:
# push coverage results to Coveralls
#- julia -e 'using Pkg; cd(Pkg.dir("LogParser")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
# push coverage results to Codecov
- julia -e 'using Pkg; cd(Pkg.dir("LogParser")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
#- julia -e 'using Pkg; Pkg.add("Documenter")'
#- julia -e 'using Pkg; cd(Pkg.dir("LogParser")); include(joinpath("docs", "make.jl"))'
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# LogParser

Linux: [![Build Status](https://travis-ci.org/randyzwitch/LogParser.jl.svg?branch=master)](https://travis-ci.org/randyzwitch/LogParser.jl) </br>
pkg.julialang.org: [![LogParser](http://pkg.julialang.org/badges/LogParser_0.3.svg)](http://pkg.julialang.org/?pkg=LogParser) </br>
pkg.julialang.org: [![LogParser](http://pkg.julialang.org/badges/LogParser_0.4.svg)](http://pkg.julialang.org/?pkg=LogParser) </br>
pkg.julialang.org: [![LogParser](http://pkg.julialang.org/badges/LogParser_0.5.svg)](http://pkg.julialang.org/?pkg=LogParser) </br>
pkg.julialang.org: [![LogParser](http://pkg.julialang.org/badges/LogParser_0.6.svg)](http://pkg.julialang.org/?pkg=LogParser) </br>
Windows: [![Build status](https://ci.appveyor.com/api/projects/status/j33i3qtdnpqwjwfk?svg=true)](https://ci.appveyor.com/project/randyzwitch/logparser-jl) </br>
Codecov: [![codecov](https://codecov.io/gh/randyzwitch/LogParser.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/randyzwitch/LogParser.jl) </br>

LogParser.jl is a package for parsing server logs. Currently, only server logs having the [Apache Combined](http://httpd.apache.org/docs/2.2/logs.html#combined) format are supported (although [Apache Common](http://httpd.apache.org/docs/2.2/logs.html#common) may parse as well). Additional types of logs may be added in the future as well.

Expand All @@ -15,16 +12,15 @@ LogParser.jl will attempt to handle the log format even if it is mangled, return

The API for this package is straightforward:

using LogParser, GZip
using LogParser

#Read in gzipped file
jbapachecombined = readdlm(gzopen(Pkg.dir("LogParser", "test", "data", "juliabloggers-apachecombined.gz")), '\t')
logarray = [...] #Any AbstractArray of Strings

#Parse file
jbparsed = parseapachecombined(vec(jbapachecombined))
parsed_vals = parseapachecombined(logarray)

#Convert to DataFrame if desired
jbparsed_df = DataFrame(jbparsed)
parsed_df = DataFrame(parsed_vals)

## Licensing

Expand Down
5 changes: 2 additions & 3 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
julia 0.7-alpha
DataFrames 0.11
GZip
julia 1.0
DataFrames 0.15.2
51 changes: 23 additions & 28 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
environment:
matrix:
#- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
#- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"

## uncomment the following lines to allow failures on nightly julia
## (tests will run but not make your overall status red)
#matrix:
# allow_failures:
# - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
# - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
- julia_version: 1
- julia_version: nightly

platform:
# - x86 # 32-bit
- x64 # 64-bit

# # Uncomment the following lines to allow failures on nightly julia
# # (tests will run but not make your overall status red)
matrix:
allow_failures:
- julia_version: latest

branches:
only:
Expand All @@ -24,24 +25,18 @@ notifications:
on_build_status_changed: false

install:
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
# If there's a newer build queued for the same PR, cancel this one
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
throw "There are newer queued builds for this pull request, failing early." }
# Download most recent Julia Windows binary
- ps: (new-object net.webclient).DownloadFile(
$env:JULIA_URL,
"C:\projects\julia-binary.exe")
# Run installer silently, output to C:\projects\julia
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))

build_script:
# Need to convert from shallow to complete for Pkg.clone to work
- IF EXIST .git\shallow (git fetch --unshallow)
- C:\projects\julia\bin\julia -e "versioninfo();
Pkg.clone(pwd(), \"LogParser\"); Pkg.build(\"LogParser\")"
- echo "%JL_BUILD_SCRIPT%"
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"

test_script:
- C:\projects\julia\bin\julia -e "Pkg.test(\"LogParser\")"
- echo "%JL_TEST_SCRIPT%"
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"

# # Uncomment to support code coverage upload. Should only be enabled for packages
# # which would have coverage gaps without running on Windows
# on_success:
# - echo "%JL_CODECOV_SCRIPT%"
# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"
9 changes: 1 addition & 8 deletions src/LogParser.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
__precompile__()
module LogParser

###############################################################################
Expand All @@ -9,10 +8,7 @@ module LogParser
#
###############################################################################

export
parseapachecombined,
DataFrame,
ApacheLog
export parseapachecombined, DataFrame, ApacheLog

import DataFrames: DataFrame

Expand Down Expand Up @@ -73,7 +69,6 @@ function parseapachecombined(logline::AbstractString)

regexarray = [apachecombinedregex, firstsevenregex, firstsixregex, firstfiveregex, firstfourregex, firstthreeregex, firsttworegex, firstfieldregex]


#Declare variable defaults up front for less coding later
ip = rfc1413 = userid = requesttime = resource = referrer = useragent = String("")
statuscode = requestsize = Int(0)
Expand Down Expand Up @@ -103,8 +98,6 @@ function parseapachecombined(logline::AbstractString)

end #End parseapachecombined::String

#Vectorized version of parseapachecombined
#Use custom version instead of base macro to control return Array type
parseapachecombined(logarray::Array) = ApacheLog[parseapachecombined(x) for x in logarray]


Expand Down
7 changes: 4 additions & 3 deletions test/REQUIRE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
julia 0.6
DataFrames
GZip
julia 1.0
DataFrames 0.15.2
GZip 0.5.0
CSV 0.4.3
9 changes: 4 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using LogParser
using Test
using GZip
using LogParser, Test, GZip, CSV, DataFrames

#Read in gzipped file
jbapachecombined = readdlm(gzopen(joinpath(dirname(@__FILE__), "data", "juliabloggers-apachecombined.gz")), '\t')
gzipfile = gzopen(joinpath(dirname(@__FILE__), "data", "juliabloggers-apachecombined.gz"))
jbapachecombined = CSV.read(gzipfile, delim='\t', datarow=1)

#Parse file
jbparsed = parseapachecombined(vec(jbapachecombined))
jbparsed = parseapachecombined(jbapachecombined[:Column1])

#Test that array is 122,143 elements long
@test size(jbparsed)[1] == 122143
Expand Down

0 comments on commit 23b3849

Please sign in to comment.