Compare commits
27 Commits
Author | SHA1 | Date |
---|---|---|
Paul van Tilburg | 03c51e2a2c | |
Paul van Tilburg | cc1a0e4748 | |
Paul van Tilburg | d2b90c16f6 | |
Paul van Tilburg | d5eed08072 | |
Paul van Tilburg | 247e9d51f5 | |
Paul van Tilburg | 5241d90e79 | |
Paul van Tilburg | c61bbfef5b | |
Paul van Tilburg | f3ff02e4ff | |
Paul van Tilburg | f2be089fb9 | |
Paul van Tilburg | 45b3f52e71 | |
Paul van Tilburg | ff12875a08 | |
Paul van Tilburg | 1bf6a4e772 | |
Paul van Tilburg | c6f7511fc7 | |
Paul van Tilburg | 3fed86d36f | |
Paul van Tilburg | d3cc19524b | |
Paul van Tilburg | 92c75d09b9 | |
Paul van Tilburg | e1319dcfc2 | |
Paul van Tilburg | 0f1bc9d83d | |
Paul van Tilburg | 0068f6e9de | |
Paul van Tilburg | caad71389b | |
Paul van Tilburg | 0b76db96f0 | |
Paul van Tilburg | 42a43cc83d | |
Paul van Tilburg | 1aca61d3fd | |
Paul van Tilburg | 35dda781a3 | |
Paul van Tilburg | 14bda61a9e | |
Paul van Tilburg | bc22fd2d70 | |
Paul van Tilburg | fd00ef0b4f |
|
@ -1,83 +0,0 @@
|
||||||
name: "Check, Test and Lint Using Cargo"
|
|
||||||
|
|
||||||
on:
|
|
||||||
- push
|
|
||||||
- pull_request
|
|
||||||
- workflow_dispatch
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
check:
|
|
||||||
name: Check
|
|
||||||
runs-on: debian-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout sources
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Install stable toolchain
|
|
||||||
uses: https://github.com/actions-rs/toolchain@v1
|
|
||||||
with:
|
|
||||||
profile: minimal
|
|
||||||
toolchain: stable
|
|
||||||
override: true
|
|
||||||
|
|
||||||
- name: Use sparse Cargo index for crates.io
|
|
||||||
run: echo -e '[registries.crates-io]\nprotocol = "sparse"' >> /root/.cargo/config.toml
|
|
||||||
|
|
||||||
- name: Run cargo check
|
|
||||||
uses: https://github.com/actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: check
|
|
||||||
|
|
||||||
# TODO: Add a test suite first!
|
|
||||||
# test:
|
|
||||||
# name: Test Suite
|
|
||||||
# runs-on: debian-latest
|
|
||||||
# steps:
|
|
||||||
# - name: Checkout sources
|
|
||||||
# uses: actions/checkout@v3
|
|
||||||
#
|
|
||||||
# - name: Install stable toolchain
|
|
||||||
# uses: https://github.com/actions-rs/toolchain@v1
|
|
||||||
# with:
|
|
||||||
# profile: minimal
|
|
||||||
# toolchain: stable
|
|
||||||
# override: true
|
|
||||||
#
|
|
||||||
# - name: Use sparse Cargo index for crates.io
|
|
||||||
# run: echo -e '[registries.crates-io]\nprotocol = "sparse"' >> /root/.cargo/config.toml
|
|
||||||
#
|
|
||||||
# - name: Run cargo test
|
|
||||||
# uses: https://github.com/actions-rs/cargo@v1
|
|
||||||
# with:
|
|
||||||
# command: test
|
|
||||||
# args: --all-features
|
|
||||||
|
|
||||||
lints:
|
|
||||||
name: Lints
|
|
||||||
runs-on: debian-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout sources
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Install stable toolchain
|
|
||||||
uses: https://github.com/actions-rs/toolchain@v1
|
|
||||||
with:
|
|
||||||
profile: minimal
|
|
||||||
toolchain: stable
|
|
||||||
override: true
|
|
||||||
components: rustfmt, clippy
|
|
||||||
|
|
||||||
- name: Use sparse Cargo index for crates.io
|
|
||||||
run: echo -e '[registries.crates-io]\nprotocol = "sparse"' >> /root/.cargo/config.toml
|
|
||||||
|
|
||||||
- name: Run cargo fmt
|
|
||||||
uses: https://github.com/actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: fmt
|
|
||||||
args: --all -- --check
|
|
||||||
|
|
||||||
- name: Run cargo clippy
|
|
||||||
uses: https://github.com/actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: clippy
|
|
||||||
args: -- -D warnings
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
name: "Check and lint using Cargo"
|
||||||
|
|
||||||
|
on:
|
||||||
|
- pull_request
|
||||||
|
- push
|
||||||
|
- workflow_dispatch
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check_lint:
|
||||||
|
name: Check and lint
|
||||||
|
runs-on: debian-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install Rust stable toolchain
|
||||||
|
uses: https://github.com/actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: stable
|
||||||
|
override: true
|
||||||
|
components: rustfmt, clippy
|
||||||
|
|
||||||
|
- name: Run cargo check
|
||||||
|
uses: https://github.com/actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: check
|
||||||
|
|
||||||
|
- name: Run cargo clippy
|
||||||
|
uses: https://github.com/actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: clippy
|
||||||
|
args: -- -D warnings
|
||||||
|
|
||||||
|
- name: Run cargo fmt
|
||||||
|
uses: https://github.com/actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: fmt
|
||||||
|
args: --all -- --check
|
||||||
|
|
||||||
|
# TODO: Add a test suite first!
|
||||||
|
# - name: Run cargo test
|
||||||
|
# uses: https://github.com/actions-rs/cargo@v1
|
||||||
|
# with:
|
||||||
|
# command: test
|
||||||
|
# args: --all-features
|
|
@ -0,0 +1,122 @@
|
||||||
|
name: "Release"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
name: "Release"
|
||||||
|
runs-on: debian-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Determine the version of the release
|
||||||
|
run: |
|
||||||
|
VERSION=${GITHUB_REF_NAME#v}
|
||||||
|
echo "Releasing version: $VERSION"
|
||||||
|
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Get the release notes from the changelog
|
||||||
|
run: |
|
||||||
|
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
|
||||||
|
RELEASE_NOTES=$(sed -n -e "/^## \[$VERSION\]/,/^## \[/{//"'!'"p;}" CHANGELOG.md | sed -e '1d;$d')
|
||||||
|
echo "Release notes:"
|
||||||
|
echo
|
||||||
|
echo "$RELEASE_NOTES"
|
||||||
|
echo "RELEASE_NOTES<<$EOF" >> "$GITHUB_ENV"
|
||||||
|
echo "$RELEASE_NOTES" >> "$GITHUB_ENV"
|
||||||
|
echo "$EOF" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v4
|
||||||
|
with:
|
||||||
|
go-version: '>=1.20.1'
|
||||||
|
|
||||||
|
- name: Release to Gitea
|
||||||
|
uses: actions/release-action@main
|
||||||
|
with:
|
||||||
|
# This is available by default.
|
||||||
|
api_key: '${{ secrets.RELEASE_TOKEN }}'
|
||||||
|
files: FIXME
|
||||||
|
title: 'Release ${{ env.VERSION }}'
|
||||||
|
body: '${{ env.RELEASE_NOTES }}'
|
||||||
|
|
||||||
|
release-crate:
|
||||||
|
name: "Release Rust crate"
|
||||||
|
runs-on: debian-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Install Rust stable toolchain
|
||||||
|
uses: https://github.com/actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: stable
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: Use sparse Cargo index for crates.io
|
||||||
|
run: echo -e '[registries.crates-io]\nprotocol = "sparse"' >> /root/.cargo/config.toml
|
||||||
|
|
||||||
|
- name: Register the Gitea crate registry with Cargo
|
||||||
|
run: echo -e '[registries.luon]\nindex = "https://git.luon.net/paul/_cargo-index.git"' >> /root/.cargo/config.toml
|
||||||
|
|
||||||
|
- name: Run cargo publish
|
||||||
|
uses: https://github.com/actions-rs/cargo@v1
|
||||||
|
env:
|
||||||
|
# This needs to be provided for the repository; no login necessary as a result.
|
||||||
|
CARGO_REGISTRIES_LUON_TOKEN: '${{ secrets.CARGO_TOKEN }}'
|
||||||
|
with:
|
||||||
|
command: publish
|
||||||
|
args: --registry luon
|
||||||
|
|
||||||
|
release-docker-image:
|
||||||
|
name: "Release Docker image"
|
||||||
|
runs-on: debian-latest
|
||||||
|
container:
|
||||||
|
image: ghcr.io/catthehacker/ubuntu:act-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Docker metadata
|
||||||
|
id: meta
|
||||||
|
uses: https://github.com/docker/metadata-action@v4
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
git.luon.net/paul/solar-grabber
|
||||||
|
tags: |
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: https://github.com/docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
- name: Login to the Gitea Docker registry
|
||||||
|
uses: https://github.com/docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: git.luon.net
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
# This needs to be provided by the repository owner and have the packages scopes enabled.
|
||||||
|
# Note that the default `GITEA_TOKEN` secret does not have this scope enabled.
|
||||||
|
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
|
||||||
|
|
||||||
|
- name: Docker build and push
|
||||||
|
uses: https://github.com/docker/build-push-action@v4
|
||||||
|
env:
|
||||||
|
ACTIONS_RUNTIME_TOKEN: '' # See https://gitea.com/gitea/act_runner/issues/119
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
47
CHANGELOG.md
47
CHANGELOG.md
|
@ -7,6 +7,46 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.3.5] - 2024-02-27
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
* Fix clippy issue
|
||||||
|
|
||||||
|
## [0.3.4] - 2024-02-27
|
||||||
|
|
||||||
|
### Security
|
||||||
|
|
||||||
|
* Updated dependencies, fixes security advisories:
|
||||||
|
* [RUSTSEC-2024-0003](https://rustsec.org/advisories/RUSTSEC-2024-0003)
|
||||||
|
* [RUSTSEC-2023-0072](https://rustsec.org/advisories/RUSTSEC-2024-0072)
|
||||||
|
|
||||||
|
## [0.3.3] - 2023-11-03
|
||||||
|
|
||||||
|
### Security
|
||||||
|
|
||||||
|
* Update dependencies ([RUSTSEC-2020-0071](https://rustsec.org/advisories/RUSTSEC-2020-0071.html))
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
* Switch to Rocket 0.5 RC4
|
||||||
|
|
||||||
|
## [0.3.2] - 2023-08-27
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
* Switch to Debian bookworm Docker image for runtime; fixes Docker image
|
||||||
|
|
||||||
|
## [0.3.1] - 2023-08-26
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
* Fix and improve Gitea Actions workflow
|
||||||
|
|
||||||
|
### Security
|
||||||
|
|
||||||
|
* Update dependencies ([RUSTSEC-2023-0044](https://rustsec.org/advisories/RUSTSEC-2023-0044))
|
||||||
|
|
||||||
## [0.3.0] - 2023-04-15
|
## [0.3.0] - 2023-04-15
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -81,7 +121,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
Rename Autarco Scraper project to Solar Grabber.
|
Rename Autarco Scraper project to Solar Grabber.
|
||||||
|
|
||||||
[Unreleased]: https://git.luon.net/paul/solar-grabber/compare/v0.3.0...HEAD
|
[Unreleased]: https://git.luon.net/paul/solar-grabber/compare/v0.3.5...HEAD
|
||||||
|
[0.3.5]: https://git.luon.net/paul/solar-grabber/compare/v0.3.4...v0.3.5
|
||||||
|
[0.3.4]: https://git.luon.net/paul/solar-grabber/compare/v0.3.3...v0.3.4
|
||||||
|
[0.3.3]: https://git.luon.net/paul/solar-grabber/compare/v0.3.2...v0.3.3
|
||||||
|
[0.3.2]: https://git.luon.net/paul/solar-grabber/compare/v0.3.1...v0.3.2
|
||||||
|
[0.3.1]: https://git.luon.net/paul/solar-grabber/compare/v0.3.0...v0.3.1
|
||||||
[0.3.0]: https://git.luon.net/paul/solar-grabber/compare/v0.2.2...v0.3.0
|
[0.3.0]: https://git.luon.net/paul/solar-grabber/compare/v0.2.2...v0.3.0
|
||||||
[0.2.2]: https://git.luon.net/paul/solar-grabber/compare/v0.2.1...v0.2.2
|
[0.2.2]: https://git.luon.net/paul/solar-grabber/compare/v0.2.1...v0.2.2
|
||||||
[0.2.1]: https://git.luon.net/paul/solar-grabber/compare/v0.2.0...v0.2.1
|
[0.2.1]: https://git.luon.net/paul/solar-grabber/compare/v0.2.0...v0.2.1
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "solar-grabber"
|
name = "solar-grabber"
|
||||||
version = "0.3.0"
|
version = "0.3.5"
|
||||||
authors = ["Paul van Tilburg <paul@luon.net>"]
|
authors = ["Paul van Tilburg <paul@luon.net>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = """"
|
description = """"
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
FROM docker.io/rust:1 as builder
|
FROM docker.io/rust:1 as builder
|
||||||
|
|
||||||
# Build the dependencies first
|
# Build the dependencies first
|
||||||
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
|
|
||||||
RUN USER=root cargo new --bin /usr/src/solar-grabber
|
RUN USER=root cargo new --bin /usr/src/solar-grabber
|
||||||
WORKDIR /usr/src/solar-grabber
|
WORKDIR /usr/src/solar-grabber
|
||||||
COPY ./Cargo.* ./
|
COPY ./Cargo.* ./
|
||||||
|
@ -25,7 +24,7 @@ RUN cargo build --release
|
||||||
|
|
||||||
########################## RUNTIME IMAGE ##########################
|
########################## RUNTIME IMAGE ##########################
|
||||||
# Create new stage with a minimal image for the actual runtime image/container
|
# Create new stage with a minimal image for the actual runtime image/container
|
||||||
FROM docker.io/debian:bullseye-slim
|
FROM docker.io/debian:bookworm-slim
|
||||||
|
|
||||||
# Install CA certificates
|
# Install CA certificates
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
|
|
|
@ -135,7 +135,7 @@ pub fn setup() -> Rocket<Build> {
|
||||||
.expect("Invalid configuration");
|
.expect("Invalid configuration");
|
||||||
let service = services::get(config.service).expect("Invalid service");
|
let service = services::get(config.service).expect("Invalid service");
|
||||||
|
|
||||||
// We don't care about the join handle nor error results?t
|
// We don't care about the join handle nor error results?
|
||||||
let _service = rocket::tokio::spawn(update_loop(service));
|
let _service = rocket::tokio::spawn(update_loop(service));
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use chrono::{DateTime, Local, TimeZone};
|
use chrono::{DateTime, Local, NaiveDateTime, TimeZone};
|
||||||
use md5::{Digest, Md5};
|
use md5::{Digest, Md5};
|
||||||
use reqwest::{cookie::Jar as CookieJar, Client, ClientBuilder, Url};
|
use reqwest::{cookie::Jar as CookieJar, Client, ClientBuilder, Url};
|
||||||
use rocket::{
|
use rocket::{
|
||||||
|
@ -112,7 +112,7 @@ where
|
||||||
use rocket::serde::de::Error;
|
use rocket::serde::de::Error;
|
||||||
|
|
||||||
match <StringOrObject<'_, T>>::deserialize(deserializer) {
|
match <StringOrObject<'_, T>>::deserialize(deserializer) {
|
||||||
Ok(StringOrObject::String(s)) if s.is_empty() => Ok(None),
|
Ok(StringOrObject::String("")) => Ok(None),
|
||||||
Ok(StringOrObject::String(_)) => Err(Error::custom("Non-empty string not allowed here")),
|
Ok(StringOrObject::String(_)) => Err(Error::custom("Non-empty string not allowed here")),
|
||||||
Ok(StringOrObject::Object(t)) => Ok(Some(t)),
|
Ok(StringOrObject::Object(t)) => Ok(Some(t)),
|
||||||
Ok(StringOrObject::Value(j)) => Err(Error::custom(&format!(
|
Ok(StringOrObject::Value(j)) => Err(Error::custom(&format!(
|
||||||
|
@ -133,9 +133,12 @@ where
|
||||||
use rocket::serde::de::Error;
|
use rocket::serde::de::Error;
|
||||||
|
|
||||||
let s = <&str>::deserialize(deserializer)?;
|
let s = <&str>::deserialize(deserializer)?;
|
||||||
|
let dt = NaiveDateTime::parse_from_str(s, DATE_TIME_FORMAT).map_err(D::Error::custom)?;
|
||||||
|
|
||||||
Local
|
Local
|
||||||
.datetime_from_str(s, DATE_TIME_FORMAT)
|
.from_local_datetime(&dt)
|
||||||
.map_err(D::Error::custom)
|
.latest()
|
||||||
|
.ok_or_else(|| D::Error::custom("time representation is invalid for server time zone"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deserializes a string ([`&str`]) into a float ([`f32`]).
|
/// Deserializes a string ([`&str`]) into a float ([`f32`]).
|
||||||
|
|
Loading…
Reference in New Issue