From 23b38497352bcef535d7c98d056d5b3a831abe78 Mon Sep 17 00:00:00 2001 From: Randy Zwitch Date: Wed, 19 Dec 2018 08:55:05 -0500 Subject: [PATCH] Cleanup for Julia 1.0 (#6) * Make tests pass * Update travis file * Update travis and AppVeyor * Minor cleanup --- .travis.yml | 39 ++++++++++++++++++++++++++---------- README.md | 14 +++++-------- REQUIRE | 5 ++--- appveyor.yml | 51 ++++++++++++++++++++++-------------------------- src/LogParser.jl | 9 +-------- test/REQUIRE | 7 ++++--- test/runtests.jl | 9 ++++----- 7 files changed, 68 insertions(+), 66 deletions(-) diff --git a/.travis.yml b/.travis.yml index 315c5fb..442d1ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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"))' diff --git a/README.md b/README.md index dd30a76..4ffbe85 100644 --- a/README.md +++ b/README.md @@ -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)
-pkg.julialang.org: [![LogParser](http://pkg.julialang.org/badges/LogParser_0.3.svg)](http://pkg.julialang.org/?pkg=LogParser)
-pkg.julialang.org: [![LogParser](http://pkg.julialang.org/badges/LogParser_0.4.svg)](http://pkg.julialang.org/?pkg=LogParser)
-pkg.julialang.org: [![LogParser](http://pkg.julialang.org/badges/LogParser_0.5.svg)](http://pkg.julialang.org/?pkg=LogParser)
-pkg.julialang.org: [![LogParser](http://pkg.julialang.org/badges/LogParser_0.6.svg)](http://pkg.julialang.org/?pkg=LogParser)
Windows: [![Build status](https://ci.appveyor.com/api/projects/status/j33i3qtdnpqwjwfk?svg=true)](https://ci.appveyor.com/project/randyzwitch/logparser-jl)
+Codecov: [![codecov](https://codecov.io/gh/randyzwitch/LogParser.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/randyzwitch/LogParser.jl)
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. @@ -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 diff --git a/REQUIRE b/REQUIRE index 38c9569..c80ddd9 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,3 +1,2 @@ -julia 0.7-alpha -DataFrames 0.11 -GZip +julia 1.0 +DataFrames 0.15.2 diff --git a/appveyor.yml b/appveyor.yml index df682a9..e0e5586 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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: @@ -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%" diff --git a/src/LogParser.jl b/src/LogParser.jl index 267d156..d464567 100644 --- a/src/LogParser.jl +++ b/src/LogParser.jl @@ -1,4 +1,3 @@ -__precompile__() module LogParser ############################################################################### @@ -9,10 +8,7 @@ module LogParser # ############################################################################### -export -parseapachecombined, -DataFrame, -ApacheLog +export parseapachecombined, DataFrame, ApacheLog import DataFrames: DataFrame @@ -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) @@ -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] diff --git a/test/REQUIRE b/test/REQUIRE index 1517d7f..a602a11 100644 --- a/test/REQUIRE +++ b/test/REQUIRE @@ -1,3 +1,4 @@ -julia 0.6 -DataFrames -GZip +julia 1.0 +DataFrames 0.15.2 +GZip 0.5.0 +CSV 0.4.3 diff --git a/test/runtests.jl b/test/runtests.jl index ce9684f..4890341 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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