Skip to content

Commit bdef54e

Browse files
committed
Merge branch 'release/0.6.0'
2 parents 2172bbc + a16b099 commit bdef54e

16 files changed

+339
-164
lines changed

.github/workflows/automerge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
steps:
1313
- name: Dependabot metadata
1414
id: metadata
15-
uses: dependabot/fetch-metadata@v2.3.0
15+
uses: dependabot/fetch-metadata@v2.4.0
1616
with:
1717
github-token: '${{ secrets.PAT }}'
1818

.github/workflows/push.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ jobs:
1919
runs-on: ubuntu-latest
2020

2121
env:
22-
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
2322
CI: true
2423

2524
steps:
@@ -37,11 +36,10 @@ jobs:
3736
- name: Run tests
3837
run: bundle exec rake test
3938

40-
- name: Send test coverage to CodeClimate
41-
uses: paambaati/codeclimate-action@v9.0.0
42-
if: ${{ env.CC_TEST_REPORTER_ID }}
39+
- uses: qltysh/qlty-action/coverage@v1
4340
with:
44-
coverageCommand: true
41+
token: ${{ secrets.QLTY_COVERAGE_TOKEN }}
42+
files: coverage/.resultset.json
4543

4644
build:
4745
runs-on: ubuntu-latest

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.4.3
1+
3.4.5

Dockerfile

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,34 @@
1-
FROM ruby:3.4.3-alpine AS builder
1+
FROM ruby:3.4.5-alpine AS builder
22
RUN apk add --no-cache build-base
33

44
WORKDIR /forecast-collector
55
COPY Gemfile* /forecast-collector/
6-
RUN bundle config --local frozen 1 && \
7-
bundle config --local without 'development test' && \
8-
bundle install -j4 --retry 3 && \
9-
bundle clean --force
10-
11-
FROM ruby:3.4.3-alpine
6+
RUN bundle config set path /usr/local/bundle && \
7+
bundle config set without 'development test' && \
8+
bundle install --jobs $(nproc) --retry 3 && \
9+
bundle clean --force && \
10+
# Remove unneeded files from installed gems (cache, .git, *.o, *.c)
11+
rm -rf /usr/local/bundle/ruby/*/cache && \
12+
rm -rf /usr/local/bundle/ruby/*/gems/*/.git && \
13+
find /usr/local/bundle -type f \( \
14+
-name '*.c' -o \
15+
-name '*.o' -o \
16+
-name '*.log' -o \
17+
-name 'gem_make.out' \
18+
\) -delete && \
19+
find /usr/local/bundle -name '*.so' -exec strip --strip-unneeded {} +
20+
21+
FROM ruby:3.4.5-alpine
1222
LABEL maintainer="georg@ledermann.dev"
1323

1424
# Add tzdata to get correct timezone
1525
RUN apk add --no-cache tzdata
1626

17-
# Decrease memory usage
18-
ENV MALLOC_ARENA_MAX=2
27+
ENV \
28+
# Decrease memory usage
29+
MALLOC_ARENA_MAX=2 \
30+
# Enable YJIT
31+
RUBYOPT=--yjit
1932

2033
# Move build arguments to environment variables
2134
ARG BUILDTIME

Gemfile.lock

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,51 +4,51 @@ GEM
44
addressable (2.8.7)
55
public_suffix (>= 2.0.2, < 7.0)
66
ast (2.4.3)
7-
base64 (0.2.0)
8-
bigdecimal (3.1.9)
7+
base64 (0.3.0)
8+
bigdecimal (3.2.2)
99
climate_control (1.2.0)
1010
crack (1.0.0)
1111
bigdecimal
1212
rexml
13-
csv (3.3.4)
13+
csv (3.3.5)
1414
docile (1.4.1)
1515
dotenv (3.1.8)
16-
hashdiff (1.1.2)
16+
hashdiff (1.2.0)
1717
influxdb-client (3.2.0)
1818
csv
19-
json (2.10.2)
20-
language_server-protocol (3.17.0.4)
19+
json (2.13.2)
20+
language_server-protocol (3.17.0.5)
2121
lint_roller (1.1.0)
2222
logger (1.7.0)
2323
minitest (5.25.5)
2424
minitest-silence (0.2.4)
2525
minitest (~> 5.12)
2626
parallel (1.27.0)
27-
parser (3.3.8.0)
27+
parser (3.3.9.0)
2828
ast (~> 2.4.1)
2929
racc
3030
prism (1.4.0)
31-
public_suffix (6.0.1)
31+
public_suffix (6.0.2)
3232
racc (1.8.1)
3333
rainbow (3.1.1)
34-
rake (13.2.1)
34+
rake (13.3.0)
3535
regexp_parser (2.10.0)
3636
rexml (3.4.1)
37-
rubocop (1.75.2)
37+
rubocop (1.79.1)
3838
json (~> 2.3)
3939
language_server-protocol (~> 3.17.0.2)
4040
lint_roller (~> 1.1.0)
4141
parallel (~> 1.10)
4242
parser (>= 3.3.0.2)
4343
rainbow (>= 2.2.2, < 4.0)
4444
regexp_parser (>= 2.9.3, < 3.0)
45-
rubocop-ast (>= 1.44.0, < 2.0)
45+
rubocop-ast (>= 1.46.0, < 2.0)
4646
ruby-progressbar (~> 1.7)
4747
unicode-display_width (>= 2.4.0, < 4.0)
48-
rubocop-ast (1.44.1)
48+
rubocop-ast (1.46.0)
4949
parser (>= 3.3.7.2)
5050
prism (~> 1.4)
51-
rubocop-minitest (0.38.0)
51+
rubocop-minitest (0.38.1)
5252
lint_roller (~> 1.1)
5353
rubocop (>= 1.75.0, < 2.0)
5454
rubocop-ast (>= 1.38.0, < 2.0)
@@ -64,7 +64,7 @@ GEM
6464
docile (~> 1.1)
6565
simplecov-html (~> 0.11)
6666
simplecov_json_formatter (~> 0.1)
67-
simplecov-html (0.13.1)
67+
simplecov-html (0.13.2)
6868
simplecov_json_formatter (0.1.4)
6969
unicode-display_width (3.1.4)
7070
unicode-emoji (~> 4.0, >= 4.0.4)
@@ -98,4 +98,4 @@ DEPENDENCIES
9898
webmock
9999

100100
BUNDLED WITH
101-
2.6.8
101+
2.7.1

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[![Continuous integration](https://github.com/solectrus/forecast-collector/actions/workflows/push.yml/badge.svg)](https://github.com/solectrus/forecast-collector/actions/workflows/push.yml)
2-
[![Maintainability](https://api.codeclimate.com/v1/badges/7c9a88a5ce7dacfa8781/maintainability)](https://codeclimate.com/github/solectrus/forecast-collector/maintainability)
2+
[![Maintainability](https://qlty.sh/gh/solectrus/projects/forecast-collector/maintainability.svg)](https://qlty.sh/gh/solectrus/projects/forecast-collector)
33
[![wakatime](https://wakatime.com/badge/user/697af4f5-617a-446d-ba58-407e7f3e0243/project/40d80ef4-7f52-4e68-a361-ed42d887c5e2.svg)](https://wakatime.com/badge/user/697af4f5-617a-446d-ba58-407e7f3e0243/project/40d80ef4-7f52-4e68-a361-ed42d887c5e2)
4-
[![Test Coverage](https://api.codeclimate.com/v1/badges/7c9a88a5ce7dacfa8781/test_coverage)](https://codeclimate.com/github/solectrus/forecast-collector/test_coverage)
4+
[![Code Coverage](https://qlty.sh/gh/solectrus/projects/forecast-collector/coverage.svg)](https://qlty.sh/gh/solectrus/projects/forecast-collector)
55

66
# Forecast collector
77

app/flux_writer.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ def initialize(config:)
77

88
attr_reader :config
99

10-
def self.push(config:, data:)
11-
new(config:).push(data)
12-
end
13-
1410
def push(data)
1511
return unless data
1612

@@ -32,6 +28,10 @@ def push(data)
3228
)
3329
end
3430

31+
def ready?
32+
influx_client.ping.status == 'ok'
33+
end
34+
3535
private
3636

3737
def influx_measurement

app/loop.rb

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ def initialize(config:)
1313

1414
attr_reader :config
1515

16-
def self.start(config:, max_count: nil)
17-
new(config:).start(max_count)
16+
def self.start(config:, max_count: nil, max_wait: 12)
17+
new(config:).start(max_count:, max_wait:)
1818
end
1919

20-
def start(max_count)
20+
def start(max_count: nil, max_wait: nil)
21+
return unless influx_ready?(max_wait)
22+
2123
self.count = 0
2224
forecast = make_forecast
2325
loop do
@@ -38,11 +40,31 @@ def start(max_count)
3840

3941
attr_accessor :count
4042

43+
def influx_ready?(max_wait)
44+
print 'Wait until InfluxDB is ready ...'
45+
46+
count = 0
47+
until (ready = flux_writer.ready?) || (max_wait && count >= max_wait)
48+
print '.'
49+
count += 1
50+
sleep 5
51+
end
52+
53+
if ready
54+
puts ' OK'
55+
puts
56+
true
57+
else
58+
puts "\nInfluxDB not ready after #{count * 5} seconds - aborting."
59+
false
60+
end
61+
end
62+
4163
def push_to_influx(data)
4264
return unless data
4365

4466
print ' Pushing forecast to InfluxDB ... '
45-
FluxWriter.push(config:, data:)
67+
flux_writer.push(data)
4668
puts 'OK'
4769
end
4870

@@ -54,4 +76,8 @@ def make_forecast
5476
Solcast.new(config:)
5577
end
5678
end
79+
80+
def flux_writer
81+
@flux_writer ||= FluxWriter.new(config:)
82+
end
5783
end

test/cassettes/forecast_solar_fail.yml

Lines changed: 33 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/cassettes/forecast_solar_multiplane.yml

Lines changed: 21 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)