Skip to content

Commit

Permalink
Merge pull request #2443 from FarmBot/staging
Browse files Browse the repository at this point in the history
v15.8.5
  • Loading branch information
gabrielburnworth authored Oct 10, 2023
2 parents a46408f + 444ad76 commit 932ccfa
Show file tree
Hide file tree
Showing 23 changed files with 122 additions and 114 deletions.
3 changes: 0 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ commands:
- run:
name: Build and Install Deps
command: |
sudo mkdir -p /usr/local/lib/docker/cli-plugins
sudo curl -SL "https://github.com/docker/compose/releases/download/v2.4.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/lib/docker/cli-plugins/docker-compose
sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
mv .circleci/circle_envs .env
echo -e '\ndocker_volumes/db/pg_wal/*' >> .dockerignore
sudo docker compose run web gem install bundler
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
.vscode
*.log
*.pem
passenger.*.pid
*.tsbuildinfo
*.pid.lock
*scratchpad*
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.6
3.1.4
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source "https://rubygems.org"
ruby "~> 3.0.6"
ruby "~> 3.1.4"

gem "rails", "~> 6"
gem "active_model_serializers"
Expand Down
36 changes: 17 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ GEM
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
active_model_serializers (0.10.13)
actionpack (>= 4.1, < 7.1)
activemodel (>= 4.1, < 7.1)
active_model_serializers (0.10.14)
actionpack (>= 4.1)
activemodel (>= 4.1)
case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
activejob (6.1.7.6)
Expand Down Expand Up @@ -146,8 +146,8 @@ GEM
faraday-retry (1.0.3)
faraday_middleware (1.2.0)
faraday (~> 1.0)
globalid (1.1.0)
activesupport (>= 5.0)
globalid (1.2.1)
activesupport (>= 6.1)
google-apis-core (0.11.1)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.16.2, < 2.a)
Expand Down Expand Up @@ -175,10 +175,9 @@ GEM
google-cloud-core (~> 1.6)
googleauth (>= 0.16.2, < 2.a)
mini_mime (~> 1.0)
googleauth (1.7.0)
googleauth (1.8.1)
faraday (>= 0.17.3, < 3.a)
jwt (>= 1.4, < 3.0)
memoist (~> 0.16)
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a)
Expand Down Expand Up @@ -206,7 +205,7 @@ GEM
activesupport (>= 4)
railties (>= 4)
request_store (~> 1.0)
loofah (2.21.3)
loofah (2.21.4)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.8.1)
Expand All @@ -215,22 +214,21 @@ GEM
net-pop
net-smtp
marcel (1.0.2)
memoist (0.16.2)
method_source (1.0.0)
mini_mime (1.1.5)
minitest (5.19.0)
minitest (5.20.0)
multi_json (1.15.0)
multipart-post (2.3.0)
mutations (0.9.1)
activesupport
net-imap (0.3.7)
net-imap (0.4.1)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.1)
timeout
net-smtp (0.3.3)
net-smtp (0.4.0)
net-protocol
nio4r (2.5.9)
nokogiri (1.15.4-x86_64-linux)
Expand All @@ -240,7 +238,7 @@ GEM
passenger (6.0.18)
rack
rake (>= 0.8.1)
pg (1.5.3)
pg (1.5.4)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
Expand Down Expand Up @@ -338,7 +336,7 @@ GEM
railties (>= 4.0.0)
secure_headers (6.5.0)
set (1.0.3)
signet (0.17.0)
signet (0.18.0)
addressable (~> 2.8)
faraday (>= 0.17.5, < 3.a)
jwt (>= 1.5, < 3.0)
Expand All @@ -355,7 +353,7 @@ GEM
sorted_set (1.0.3)
rbtree
set (~> 1.0)
sprockets (4.2.0)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
sprockets-rails (3.4.2)
Expand All @@ -375,15 +373,15 @@ GEM
rails
warden (1.2.9)
rack (>= 2.0.9)
webmock (3.19.0)
webmock (3.19.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webrick (1.8.1)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.6.11)
zeitwerk (2.6.12)

PLATFORMS
x86_64-linux
Expand Down Expand Up @@ -431,7 +429,7 @@ DEPENDENCIES
webmock

RUBY VERSION
ruby 3.0.6p216
ruby 3.1.4p223

BUNDLED WITH
2.4.18
2.4.19
2 changes: 1 addition & 1 deletion app/controllers/api/ais_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def page_url(page_name)
def get_page_data(page_name)
url = page_url(page_name)
begin
URI.open(url).read
URI.parse(url).open.read
rescue SocketError => exception
puts "AI Lua docs fetch error: #{exception.message}" unless Rails.env.test?
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def self.connection_warning(username)

def self.get_utc_ota_hour(timezone, local_ota_hour)
utc_offset = Time.now.in_time_zone(timezone).utc_offset / 60 / 60
(local_ota_hour + utc_offset) % 24
(local_ota_hour - utc_offset) % 24
end

# PROBLEM: The device table has an `ota_hour` column. The
Expand Down
2 changes: 1 addition & 1 deletion app/models/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def set_defaults
has_one_attached :attachment

def set_attachment_by_url(url)
io = URI.open(url)
io = URI.parse(url).open
fname = "image_#{self.id}"
params = { io: io, filename: fname }
attachment.attach(**params)
Expand Down
2 changes: 1 addition & 1 deletion app/models/release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Release < ApplicationRecord
def self.transload(url, gcs = Google::Cloud::Storage.new)
file_name = url.split("/").last
tempdir = "#{Rails.root.join("tmp").to_s}/#{file_name}"
download = URI.open(url)
download = URI.parse(url).open
IO.copy_stream(download, tempdir)
bucket = gcs.bucket(ENV.fetch("GCS_BUCKET"))
file = bucket.upload_file tempdir, "releases/#{file_name}"
Expand Down
7 changes: 5 additions & 2 deletions docker_configs/api.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
FROM ruby:3.0.6
FROM ruby:3.1.4
RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg > /dev/null && \
sh -c '. /etc/os-release; echo $VERSION_CODENAME; echo "deb http://apt.postgresql.org/pub/repos/apt/ $VERSION_CODENAME-pgdg main" >> /etc/apt/sources.list.d/pgdg.list' && \
apt-get update -qq && apt-get install -y build-essential libpq-dev postgresql postgresql-contrib && \
curl -sL https://deb.nodesource.com/setup_20.x | bash - && \
mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
sh -c 'echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >> /etc/apt/sources.list.d/nodesource.list' && \
apt-get update -qq && \
sh -c 'echo "\nPackage: *\nPin: origin deb.nodesource.com\nPin-Priority: 700\n" >> /etc/apt/preferences' && \
apt-get install -y nodejs && \
mkdir /farmbot;
Expand Down
2 changes: 1 addition & 1 deletion docker_configs/rabbitmq.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rabbitmq:3.7.6
FROM rabbitmq:3.12.6
RUN rabbitmq-plugins enable --offline \
rabbitmq_auth_backend_http \
rabbitmq_management \
Expand Down
4 changes: 2 additions & 2 deletions frontend/demo/__tests__/demo_iframe_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import React from "react";
import axios from "axios";
import { shallow } from "enzyme";
import { DemoIframe, WAITING_ON_API, EASTER_EGG, MQTT_CHAN } from "../demo_iframe";
import { MqttClient } from "mqtt";
import { IConnackPacket } from "mqtt";
import { tourPath } from "../../help/tours";
import { Path } from "../../internal_urls";

Expand All @@ -27,7 +27,7 @@ describe("<DemoIframe />", () => {
const el = shallow<DemoIframe>(<DemoIframe />);
expect(el.text()).toContain("DEMO THE APP");
el.instance().connectMqtt = () =>
Promise.resolve() as unknown as Promise<MqttClient>;
Promise.resolve() as unknown as Promise<IConnackPacket>;
await el.instance().requestAccount();
await expect(axios.post).toHaveBeenCalled();
expect(el.state().stage).toContain(WAITING_ON_API);
Expand Down
6 changes: 3 additions & 3 deletions frontend/demo/demo_iframe.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { connect, MqttClient } from "mqtt";
import { ClientSubscribeCallback, connect, IConnackPacket } from "mqtt";
import React from "react";
import { uuid } from "farmbot";
import axios from "axios";
Expand Down Expand Up @@ -30,11 +30,11 @@ export class DemoIframe extends React.Component<{}, State> {

setError = (error?: Error) => this.setState({ error });

connectMqtt = (): Promise<MqttClient> => {
connectMqtt = (): Promise<IConnackPacket> => {
const client = connect(globalConfig.MQTT_WS, WS_CONFIG);
return new Promise(resolve => {
client.on("message", this.handleMessage);
client.subscribe(MQTT_CHAN, this.setError);
client.subscribe(MQTT_CHAN, this.setError as ClientSubscribeCallback);
client.on("connect", resolve);
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import React from "react";
import { shallow, mount } from "enzyme";
import {
OtaTimeSelector, OtaTimeSelectorRow, DDI_ASAP,
localHourToUtcHour, utcHourToLocalHour,
} from "../ota_time_selector";
import { FBSelect } from "../../../ui";
import { fakeDevice } from "../../../__test_support__/resource_index_builder";
Expand All @@ -19,6 +20,18 @@ import { fakeTimeSettings } from "../../../__test_support__/fake_time_settings";
import { edit } from "../../../api/crud";
import { updateConfig } from "../../../devices/actions";

describe("localHourToUtcHour()", () => {
it("converts hour", () => {
expect(localHourToUtcHour(10, -2)).toEqual(12);
});
});

describe("utcHourToLocalHour()", () => {
it("converts hour", () => {
expect(utcHourToLocalHour(12, -2)).toEqual(10);
});
});

describe("<OtaTimeSelector />", () => {
const fakeProps = (): OtaTimeSelectorProps => ({
timeSettings: fakeTimeSettings(),
Expand Down
13 changes: 8 additions & 5 deletions frontend/settings/fbos_settings/ota_time_selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ import { isNumber, range } from "lodash";
import { getModifiedClassNameSpecifyDefault } from "../default_values";
import { updateConfig } from "../../devices/actions";

const hourToUtcHour =
(hour: number | undefined, offset: number): number | undefined =>
!isNumber(hour) ? undefined : (hour + offset) % 24;
export const localHourToUtcHour =
(hour: number | undefined, offset: number, direction = 1): number | undefined =>
!isNumber(hour) ? undefined : (hour - (direction * offset)) % 24;

export const utcHourToLocalHour = (hour: number | undefined, offset: number) =>
localHourToUtcHour(hour, offset, -1);

export const DDI_ASAP = (): DropDownItem =>
({ label: t("As soon as possible"), value: "", isNull: true });
Expand All @@ -28,7 +31,7 @@ const formatHour = (hour: number | undefined, hour24: boolean) =>
export const OtaTimeSelector = (props: OtaTimeSelectorProps) => {
const { device, dispatch, timeSettings } = props;
const { utcOffset, hour24 } = timeSettings;
const localHour = hourToUtcHour(device.body.ota_hour_utc, -utcOffset) ??
const localHour = utcHourToLocalHour(device.body.ota_hour_utc, utcOffset) ??
device.body.ota_hour;
const osAutoUpdate = props.sourceFbosConfig("os_auto_update");
const selected = () => {
Expand All @@ -49,7 +52,7 @@ export const OtaTimeSelector = (props: OtaTimeSelectorProps) => {
const newLocalHour = ddi ? parseInt("" + ddi.value) : undefined;
dispatch(edit(device, {
ota_hour: newLocalHour,
ota_hour_utc: hourToUtcHour(newLocalHour, utcOffset),
ota_hour_utc: localHourToUtcHour(newLocalHour, utcOffset),
}));
dispatch(save(device.uuid));
}}
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/api.rake
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ namespace :api do
# 60 days is the current policy.
cutoff = 60.days.ago
# Download release data from github
string_page_1 = URI.open("#{RELEASES_URL}?per_page=100&page=1").read
string_page_2 = URI.open("#{RELEASES_URL}?per_page=100&page=2").read
string_page_1 = URI.parse("#{RELEASES_URL}?per_page=100&page=1").open.read
string_page_2 = URI.parse("#{RELEASES_URL}?per_page=100&page=2").open.read
data = JSON.parse(string_page_1).push(*JSON.parse(string_page_2))
.map { |x| x.slice(VERSION, TIMESTAMP, PRERELEASE) } # Only grab keys that matter
.reject { |x| x.fetch(VERSION).include?("-") } # Remove RC/Beta releases
Expand Down
6 changes: 3 additions & 3 deletions lib/tasks/coverage.rake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ FRACTION_DELIM = "/"
# Fetch JSON over HTTP. Rails probably already has a helper for this :shrug:
def open_json(url)
begin
JSON.parse(URI.open(url).read)
JSON.parse(URI.parse(url).open.read)
rescue *[OpenURI::HTTPError, SocketError] => exception
puts exception.message
return {}
Expand Down Expand Up @@ -131,7 +131,7 @@ end
def get_json_coverage_results()
results = { lines: { covered: 0, total: 0 }, branches: { covered: 0, total: 0 } }
begin
data = open_json(JSON_COVERAGE_FILE_PATH)
data = JSON.parse(File.open(JSON_COVERAGE_FILE_PATH).read)
rescue Errno::ENOENT
return results
end
Expand Down Expand Up @@ -191,7 +191,7 @@ namespace :coverage do
begin
# Fetch current build coverage data from the HTML summary.
statements, branches, functions, lines =
Nokogiri::HTML(URI.open(COVERAGE_FILE_PATH))
Nokogiri::HTML(File.open(COVERAGE_FILE_PATH))
.css(CSS_SELECTOR)
.map(&:text)
.map { |x| x.split(FRACTION_DELIM).map(&:to_f) }
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/fe.rake
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ EXCLUDE = [

# Load package.json as JSON.
def load_package_json()
return JSON.parse(URI.open(PACKAGE_JSON_FILE).read)
return JSON.parse(File.open(PACKAGE_JSON_FILE).read)
end

# Save JSON to package.json.
def save_package_json(json)
URI.open(PACKAGE_JSON_FILE, "w") { |file|
File.open(PACKAGE_JSON_FILE, "w") { |file|
file.write(JSON.pretty_generate(json))
file.puts
}
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/releases.rake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace :releases do
module ReleaseTask
def self.download_metadata(tag_name)
real_url = "https://api.github.com/repos/farmbot/farmbot_os/releases/tags/#{tag_name}"
JSON.parse(URI.open(real_url).read, symbolize_names: true)
JSON.parse(URI.parse(real_url).open.read, symbolize_names: true)
end

def self.select_version(choices)
Expand All @@ -31,7 +31,7 @@ namespace :releases do

def self.get_release_list
uri = "https://api.github.com/repos/farmbot/farmbot_os/releases"
file = URI.open(uri)
file = URI.parse(uri).open
raw_json = file.read
json = JSON.parse(raw_json, symbolize_names: true).pluck(:tag_name)
json.first(9).sort.reverse
Expand Down
Loading

0 comments on commit 932ccfa

Please sign in to comment.