Compare commits
No commits in common. "HEAD" and "v0.3.0" have entirely different histories.
11 changed files with 695 additions and 1019 deletions
|
@ -1,26 +0,0 @@
|
||||||
name: "Audit dependencies"
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
paths:
|
|
||||||
- '.forgejo/workflows/audit.yml'
|
|
||||||
- '**/Cargo.toml'
|
|
||||||
- '**/Cargo.lock'
|
|
||||||
- '**/audit.toml'
|
|
||||||
schedule:
|
|
||||||
- cron: '0 23 * * 6'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
audit:
|
|
||||||
runs-on: rust-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout sources
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Run cargo audit
|
|
||||||
run: cargo audit
|
|
|
@ -1,29 +0,0 @@
|
||||||
name: "Check and lint"
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
check_lint:
|
|
||||||
name: Check and lint
|
|
||||||
runs-on: rust-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout sources
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Run cargo check
|
|
||||||
run: cargo check --all-features
|
|
||||||
|
|
||||||
- name: Run cargo clippy
|
|
||||||
run: cargo clippy -- -D warnings
|
|
||||||
|
|
||||||
- name: Run cargo fmt
|
|
||||||
run: cargo fmt --all -- --check
|
|
||||||
|
|
||||||
# TODO: Add a test suite first!
|
|
||||||
# - name: Run cargo test
|
|
||||||
# run: cargo test --all-features
|
|
|
@ -1,104 +0,0 @@
|
||||||
name: "Release"
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- v*
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
release:
|
|
||||||
name: "Release"
|
|
||||||
runs-on: rust-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout sources
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Determine the repository name and version of the release
|
|
||||||
run: |
|
|
||||||
REPO_NAME=$(basename $GITHUB_REPOSITORY)
|
|
||||||
VERSION=${GITHUB_REF_NAME#v}
|
|
||||||
echo "Releasing version of $REPO_NAME: $VERSION"
|
|
||||||
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_ENV
|
|
||||||
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: Build a release binary
|
|
||||||
run: |
|
|
||||||
# FIXME: This should be figured out in a better manner!
|
|
||||||
BIN_NAME=${REPO_NAME}-x86_64-unknown-linux-gnu
|
|
||||||
cargo build --release
|
|
||||||
mkdir -p dist
|
|
||||||
cp target/release/${REPO_NAME} dist/${BIN_NAME}
|
|
||||||
shasum -a 256 dist/${BIN_NAME} > dist/${BIN_NAME}.sha256sum
|
|
||||||
|
|
||||||
- name: Release to Forgejo
|
|
||||||
uses: paul/forgejo-release@main
|
|
||||||
with:
|
|
||||||
direction: upload
|
|
||||||
release-dir: dist
|
|
||||||
release-notes: '${{ env.RELEASE_NOTES }}'
|
|
||||||
title: 'Release ${{ env.VERSION }}'
|
|
||||||
token: '${{ secrets.RELEASE_TOKEN }}'
|
|
||||||
verbose: true
|
|
||||||
|
|
||||||
release-crate:
|
|
||||||
name: "Release Rust crate"
|
|
||||||
runs-on: rust-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout sources
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Run cargo publish
|
|
||||||
run: cargo publish --registry luon
|
|
||||||
env:
|
|
||||||
CARGO_REGISTRIES_LUON_INDEX: 'sparse+${{ github.server_url }}/api/packages/${{ github.repository_owner }}/cargo/'
|
|
||||||
CARGO_REGISTRIES_LUON_TOKEN: 'Bearer ${{ secrets.CARGO_TOKEN }}'
|
|
||||||
|
|
||||||
release-docker-image:
|
|
||||||
name: "Release Docker image"
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout sources
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Determine Docker metadata
|
|
||||||
id: meta
|
|
||||||
uses: https://github.com/docker/metadata-action@v4
|
|
||||||
with:
|
|
||||||
images: |
|
|
||||||
git.luon.net/${{ github.repository }}
|
|
||||||
tags: |
|
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
|
||||||
type=semver,pattern={{version}}
|
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
|
||||||
type=semver,pattern={{major}}
|
|
||||||
|
|
||||||
- name: Login to the Forgejo container registry
|
|
||||||
uses: https://github.com/docker/login-action@v2
|
|
||||||
with:
|
|
||||||
registry: git.luon.net
|
|
||||||
username: ${{ github.repository_owner }}
|
|
||||||
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
|
|
||||||
|
|
||||||
- name: Docker build and push
|
|
||||||
uses: https://github.com/docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
83
.gitea/workflows/cargo.yml
Normal file
83
.gitea/workflows/cargo.yml
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
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
|
62
CHANGELOG.md
62
CHANGELOG.md
|
@ -7,60 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
## [0.3.6] - 2024-07-27
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
|
|
||||||
* Switch to Forgejo Actions; add audit workflow
|
|
||||||
* Switch build dependency on `vergen` to `vergen-git2`
|
|
||||||
|
|
||||||
### Security
|
|
||||||
|
|
||||||
* Update dependencies; this fixes several security advisories:
|
|
||||||
* [RUSTSEC-2024-0019](https://rustsec.org/advisories/RUSTSEC-2024-0019)
|
|
||||||
* [RUSTSEC-2024-0332](https://rustsec.org/advisories/RUSTSEC-2024-0332)
|
|
||||||
* [RUSTSEC-2024-0357](https://rustsec.org/advisories/RUSTSEC-2024-0357)
|
|
||||||
|
|
||||||
## [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
|
||||||
|
@ -135,13 +81,7 @@ 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.6...HEAD
|
[Unreleased]: https://git.luon.net/paul/solar-grabber/compare/v0.3.0...HEAD
|
||||||
[0.3.6]: https://git.luon.net/paul/solar-grabber/compare/v0.3.5...v0.3.6
|
|
||||||
[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
|
||||||
|
|
1380
Cargo.lock
generated
1380
Cargo.lock
generated
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.6"
|
version = "0.3.0"
|
||||||
authors = ["Paul van Tilburg <paul@luon.net>"]
|
authors = ["Paul van Tilburg <paul@luon.net>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = """"
|
description = """"
|
||||||
|
@ -24,7 +24,7 @@ thiserror = "1.0.38"
|
||||||
url = "2.2.2"
|
url = "2.2.2"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
vergen-git2 = { version = "1.0.0", features = ["build"] }
|
vergen = { version = "8.1.1", features = ["build", "git", "gitcl"] }
|
||||||
|
|
||||||
[package.metadata.deb]
|
[package.metadata.deb]
|
||||||
maintainer = "Paul van Tilburg <paul@luon.net>"
|
maintainer = "Paul van Tilburg <paul@luon.net>"
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
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.* ./
|
||||||
|
@ -24,7 +25,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:bookworm-slim
|
FROM docker.io/debian:bullseye-slim
|
||||||
|
|
||||||
# Install CA certificates
|
# Install CA certificates
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
|
|
10
build.rs
10
build.rs
|
@ -1,15 +1,9 @@
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use vergen_git2::{BuildBuilder, Emitter, Git2Builder};
|
use vergen::EmitBuilder;
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
// Generate the `cargo:` instructions to fill the appropriate environment variables.
|
// Generate the `cargo:` instructions to fill the appropriate environment variables.
|
||||||
let build = &BuildBuilder::all_build()?;
|
EmitBuilder::builder().all_build().all_git().emit()?;
|
||||||
let git2 = &Git2Builder::all_git()?;
|
|
||||||
|
|
||||||
Emitter::default()
|
|
||||||
.add_instructions(build)?
|
|
||||||
.add_instructions(git2)?
|
|
||||||
.emit()?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -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?
|
// We don't care about the join handle nor error results?t
|
||||||
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, NaiveDateTime, TimeZone};
|
use chrono::{DateTime, Local, 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("")) => Ok(None),
|
Ok(StringOrObject::String(s)) if s.is_empty() => 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,12 +133,9 @@ 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
|
||||||
.from_local_datetime(&dt)
|
.datetime_from_str(s, DATE_TIME_FORMAT)
|
||||||
.latest()
|
.map_err(D::Error::custom)
|
||||||
.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 a new issue