From 51ff4f7e7644813782224ebaede8ec98cf441601 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Wed, 23 Oct 2024 11:39:31 +0200 Subject: [PATCH] Drop support for julia versions < 1.10 --- .github/workflows/Documentation.yml | 26 +++++++++++++ .github/workflows/{CI.yml => Test.yml} | 28 ++----------- Project.toml | 2 +- src/Prometheus.jl | 54 +++++--------------------- src/process_collector.jl | 2 +- 5 files changed, 42 insertions(+), 70 deletions(-) create mode 100644 .github/workflows/Documentation.yml rename .github/workflows/{CI.yml => Test.yml} (58%) diff --git a/.github/workflows/Documentation.yml b/.github/workflows/Documentation.yml new file mode 100644 index 0000000..b7639af --- /dev/null +++ b/.github/workflows/Documentation.yml @@ -0,0 +1,26 @@ +--- +name: Documentation +on: + push: + branches: + - 'master' + - 'release-' + tags: ['*'] + pull_request: +jobs: + docs: + name: Documentation + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v2 + with: + version: '1.11' + - uses: julia-actions/cache@v2 + - name: Install dependencies + run: julia --project=docs -e 'using Pkg; Pkg.instantiate()' + - name: Build and deploy + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} + run: julia --project=docs --color=yes docs/make.jl diff --git a/.github/workflows/CI.yml b/.github/workflows/Test.yml similarity index 58% rename from .github/workflows/CI.yml rename to .github/workflows/Test.yml index 764c129..630a68b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/Test.yml @@ -1,13 +1,12 @@ -name: CI - +--- +name: Test on: push: branches: - 'master' - 'release-' - tags: '*' + tags: ['*'] pull_request: - jobs: test: name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ github.event_name }} @@ -15,10 +14,7 @@ jobs: strategy: matrix: version: - - '1.6' - - '1.7' - - '1.8' - - '1.9' + - '1.10' - '1' - 'nightly' os: @@ -41,19 +37,3 @@ jobs: file: lcov.info env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - docs: - name: Documentation - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: julia-actions/setup-julia@v2 - with: - version: '1.11' - - uses: julia-actions/cache@v2 - - name: Install dependencies - run: julia --project=docs -e 'using Pkg; Pkg.instantiate()' - - name: Build and deploy - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} - run: julia --project=docs --color=yes docs/make.jl diff --git a/Project.toml b/Project.toml index 29ec90b..dd88206 100644 --- a/Project.toml +++ b/Project.toml @@ -11,7 +11,7 @@ SimpleBufferStream = "777ac1f9-54b0-4bf8-805c-2214025038e7" CodecZlib = "0.7" HTTP = "1" SimpleBufferStream = "1" -julia = "1.6" +julia = "1.10" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/src/Prometheus.jl b/src/Prometheus.jl index 0e5baa0..45b5b27 100644 --- a/src/Prometheus.jl +++ b/src/Prometheus.jl @@ -64,40 +64,6 @@ function verify_metric_name(metric_name::String) return metric_name end -########################################### -# Compat for const fields, @lock, @atomic # -########################################### -@eval macro $(Symbol("const"))(field) - if VERSION >= v"1.8.0-DEV.1148" - Expr(:const, esc(field)) - else - return esc(field) - end -end -if VERSION < v"1.7.0" - # Defined but not exported - using Base: @lock -end -if !isdefined(Base, Symbol("@atomic")) # v1.7.0 - const ATOMIC_COMPAT_LOCK = ReentrantLock() - macro atomic(expr) - if Meta.isexpr(expr, :(::)) - return esc(expr) - else - return quote - lock(ATOMIC_COMPAT_LOCK) - tmp = $(esc(expr)) - unlock(ATOMIC_COMPAT_LOCK) - tmp - end - end - end -end -if !isdefined(Base, :eachsplit) # v1.8.0 - const eachsplit = split -end - - ##################### # CollectorRegistry # ##################### @@ -151,8 +117,8 @@ end # certain types of exceptions. This is count_exceptions in Python. mutable struct Counter <: Collector - @const metric_name::String - @const help::String + const metric_name::String + const help::String @atomic value::Float64 function Counter( @@ -222,8 +188,8 @@ end # https://prometheus.io/docs/instrumenting/writing_clientlibs/#gauge mutable struct Gauge <: Collector - @const metric_name::String - @const help::String + const metric_name::String + const help::String @atomic value::Float64 function Gauge( @@ -335,12 +301,12 @@ const DEFAULT_BUCKETS = [ ] mutable struct Histogram <: Collector - @const metric_name::String - @const help::String - @const buckets::Vector{Float64} + const metric_name::String + const help::String + const buckets::Vector{Float64} @atomic _count::Int @atomic _sum::Float64 - @const bucket_counters::Vector{Threads.Atomic{Int}} + const bucket_counters::Vector{Threads.Atomic{Int}} function Histogram( metric_name::String, help::String; buckets::Vector{Float64} = DEFAULT_BUCKETS, @@ -439,8 +405,8 @@ end # https://prometheus.io/docs/instrumenting/writing_clientlibs/#summary mutable struct Summary <: Collector - @const metric_name::String - @const help::String + const metric_name::String + const help::String @atomic _count::Int @atomic _sum::Float64 diff --git a/src/process_collector.jl b/src/process_collector.jl index d0560f6..5d5e414 100644 --- a/src/process_collector.jl +++ b/src/process_collector.jl @@ -5,7 +5,7 @@ ################################# mutable struct ProcessCollector <: Collector - @const pid::Function + const pid::Function @atomic initialized::Ptr{Nothing} @atomic system_boot_time::Int @atomic clock_ticks_per_second::Int