Skip to content

Commit

Permalink
Merge branch 'release/v0.11.16'
Browse files Browse the repository at this point in the history
  • Loading branch information
ja573 committed Feb 19, 2024
2 parents f9cb0f6 + 0e1ff95 commit 6532713
Show file tree
Hide file tree
Showing 25 changed files with 170 additions and 22,522 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/check_changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: check-changelog
on:
pull_request:

jobs:
check-changelog:
runs-on: ubuntu-latest
steps:
- uses: tarides/changelog-check-action@v2
with:
changelog: CHANGELOG.md
5 changes: 5 additions & 0 deletions .github/workflows/run_migrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,8 @@ jobs:
with:
command: run
args: migrate
- name: Revert migrations
uses: actions-rs/cargo@v1
with:
command: run
args: migrate --revert
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [[0.11.16]](https://github.com/thoth-pub/thoth/releases/tag/v0.11.16) - 2024-02-19
### Changed
- [561](https://github.com/thoth-pub/thoth/issues/561) - Add "Publisher Website" as a location platform
- [553](https://github.com/thoth-pub/thoth/pull/553) - Upgrade rust to `1.76.0` in production and development `Dockerfile`
- [305](https://github.com/thoth-pub/thoth/issues/305) - Update rust edition to 2021
- [555](https://github.com/thoth-pub/thoth/pull/555) - Remove thoth-client's schema.json with auto-generated GraphQL schema language file on compilation

### Added
- [244](https://github.com/thoth-pub/thoth/issues/244) - Expose GraphQL schema file in /schema.graphql
- [503](https://github.com/thoth-pub/thoth/issues/503) - Allow reverting migrations in the CLI and check that migrations can be reverted in run-migration github action
- [557](https://github.com/thoth-pub/thoth/pull/557) - Added github action to chech that the changelog has been updated on PRs

## [[0.11.15]](https://github.com/thoth-pub/thoth/releases/tag/v0.11.15) - 2024-01-18
### Changed
- [536](https://github.com/thoth-pub/thoth/issues/536) - Rename "SciELO" location platform to "SciELO Books"
Expand Down
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "thoth"
version = "0.11.15"
version = "0.11.16"
authors = ["Javier Arias <[email protected]>", "Ross Higman <[email protected]>"]
edition = "2018"
edition = "2021"
license = "Apache-2.0"
description = "GraphQL API for bibliographic data"
repository = "https://github.com/thoth-pub/thoth"
Expand All @@ -16,11 +16,11 @@ maintenance = { status = "actively-developed" }
members = ["thoth-api", "thoth-api-server", "thoth-app", "thoth-app-server", "thoth-client", "thoth-errors", "thoth-export-server"]

[dependencies]
thoth-api = { version = "0.11.15", path = "thoth-api", features = ["backend"] }
thoth-api-server = { version = "0.11.15", path = "thoth-api-server" }
thoth-app-server = { version = "0.11.15", path = "thoth-app-server" }
thoth-errors = { version = "0.11.15", path = "thoth-errors" }
thoth-export-server = { version = "0.11.15", path = "thoth-export-server" }
thoth-api = { version = "0.11.16", path = "thoth-api", features = ["backend"] }
thoth-api-server = { version = "0.11.16", path = "thoth-api-server" }
thoth-app-server = { version = "0.11.16", path = "thoth-app-server" }
thoth-errors = { version = "0.11.16", path = "thoth-errors" }
thoth-export-server = { version = "0.11.16", path = "thoth-export-server" }
clap = { version = "4.4.7", features = ["cargo", "env"] }
dialoguer = { version = "0.11.0", features = ["password"] }
dotenv = "0.15.0"
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG RUST_IMAGE=rust:1.75.0
ARG MUSL_IMAGE=clux/muslrust:1.75.0
ARG RUST_IMAGE=rust:1.76.0
ARG MUSL_IMAGE=clux/muslrust:1.76.0

FROM ${RUST_IMAGE} as wasm

Expand Down
3 changes: 2 additions & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG RUST_VERSION=1.75.0
ARG RUST_VERSION=1.76.0

FROM rust:${RUST_VERSION}

Expand Down Expand Up @@ -48,6 +48,7 @@ RUN mkdir thoth-api/src thoth-api-server/src thoth-app/src \
RUN touch thoth-api/src/lib.rs thoth-api-server/src/lib.rs \
thoth-app/src/lib.rs thoth-app-server/src/lib.rs thoth-client/src/lib.rs \
thoth-errors/src/lib.rs thoth-export-server/src/lib.rs
RUN echo "fn main() {}" > thoth-client/build.rs
RUN wasm-pack build thoth-app/ \
--target web \
--debug
Expand Down
20 changes: 16 additions & 4 deletions src/bin/thoth.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use clap::{crate_authors, crate_version, value_parser, Arg, Command};
use clap::{crate_authors, crate_version, value_parser, Arg, ArgAction, Command};
use dialoguer::{console::Term, theme::ColorfulTheme, Input, MultiSelect, Password, Select};
use dotenv::dotenv;
use std::env;
use thoth::api::account::model::{AccountData, LinkedPublisher};
use thoth::api::account::service::{all_emails, all_publishers, register, update_password};
use thoth::api::db::{establish_connection, run_migrations};
use thoth::api::db::{establish_connection, revert_migrations, run_migrations};
use thoth::api_server;
use thoth::app_server;
use thoth::export_server;
Expand Down Expand Up @@ -129,7 +129,16 @@ fn thoth_commands() -> Command {
.about(env!("CARGO_PKG_DESCRIPTION"))
.subcommand_required(true)
.arg_required_else_help(true)
.subcommand(Command::new("migrate").about("Run the database migrations"))
.subcommand(
Command::new("migrate")
.about("Run the database migrations")
.arg(
Arg::new("revert")
.long("revert")
.help("Revert all database migrations")
.action(ArgAction::SetTrue),
),
)
.subcommand(
Command::new("start")
.about("Start an instance of Thoth API or GUI")
Expand Down Expand Up @@ -240,7 +249,10 @@ fn main() -> ThothResult<()> {
}
_ => unreachable!(),
},
Some(("migrate", _)) => run_migrations(),
Some(("migrate", migrate_matches)) => match migrate_matches.get_flag("revert") {
true => revert_migrations(),
false => run_migrations(),
},
Some(("init", init_matches)) => {
let host = init_matches.get_one::<String>("host").unwrap().to_owned();
let port = init_matches.get_one::<String>("port").unwrap().to_owned();
Expand Down
8 changes: 4 additions & 4 deletions thoth-api-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[package]
name = "thoth-api-server"
version = "0.11.15"
version = "0.11.16"
authors = ["Javier Arias <[email protected]>", "Ross Higman <[email protected]>"]
edition = "2018"
edition = "2021"
license = "Apache-2.0"
description = "Actix instance serving Thoth's GraphQL endpoints"
repository = "https://github.com/thoth-pub/thoth"
readme = "README.md"

[dependencies]
thoth-api = { version = "0.11.15", path = "../thoth-api", features = ["backend"] }
thoth-errors = { version = "0.11.15", path = "../thoth-errors" }
thoth-api = { version = "0.11.16", path = "../thoth-api", features = ["backend"] }
thoth-errors = { version = "0.11.16", path = "../thoth-errors" }
actix-web = "4.4.1"
actix-cors = "0.7.0"
actix-identity = "0.6.0"
Expand Down
6 changes: 6 additions & 0 deletions thoth-api-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ async fn graphql_index(config: Data<ApiConfig>) -> HttpResponse {
))
}

#[get("/schema.graphql")]
async fn graphql_schema(st: Data<Arc<Schema>>) -> HttpResponse {
HttpResponse::Ok().body(st.as_schema_language())
}

#[post("/graphql")]
async fn graphql(
st: Data<Arc<Schema>>,
Expand Down Expand Up @@ -192,6 +197,7 @@ fn config(cfg: &mut ServiceConfig) {
cfg.service(login_credentials);
cfg.service(login_session);
cfg.service(account_details);
cfg.service(graphql_schema);
}

#[allow(clippy::too_many_arguments)]
Expand Down
6 changes: 3 additions & 3 deletions thoth-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "thoth-api"
version = "0.11.15"
version = "0.11.16"
authors = ["Javier Arias <[email protected]>", "Ross Higman <[email protected]>"]
edition = "2018"
edition = "2021"
license = "Apache-2.0"
description = "GraphQL API for bibliographic data"
repository = "https://github.com/thoth-pub/thoth"
Expand All @@ -16,7 +16,7 @@ maintenance = { status = "actively-developed" }
backend = ["diesel", "diesel-derive-enum", "diesel_migrations", "futures", "actix-web"]

[dependencies]
thoth-errors = { version = "0.11.15", path = "../thoth-errors" }
thoth-errors = { version = "0.11.16", path = "../thoth-errors" }
actix-web = { version = "4.4.1", optional = true }
argon2rs = "0.2.5"
isbn2 = "0.4.0"
Expand Down
34 changes: 34 additions & 0 deletions thoth-api/migrations/v0.11.16/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
UPDATE location SET location_platform = 'Other' WHERE location_platform IN (
'Publisher Website'
);

-- Drop the default and unique constraint, otherwise it won't be able to cast to text
ALTER TABLE location ALTER COLUMN location_platform DROP DEFAULT;
DROP INDEX location_uniq_platform_idx;

ALTER TABLE location ALTER COLUMN location_platform TYPE text;
DROP TYPE location_platform;
CREATE TYPE location_platform AS ENUM (
'Project MUSE',
'OAPEN',
'DOAB',
'JSTOR',
'EBSCO Host',
'OCLC KB',
'ProQuest KB',
'ProQuest ExLibris',
'EBSCO KB',
'JISC KB',
'Google Books',
'Internet Archive',
'ScienceOpen',
'SciELO Books',
'Other'
);
ALTER TABLE location ALTER location_platform TYPE location_platform USING location_platform::location_platform;
ALTER TABLE location
ALTER COLUMN location_platform SET DEFAULT 'Other'::location_platform;

CREATE UNIQUE INDEX location_uniq_platform_idx
ON location (publication_id, location_platform)
WHERE NOT location_platform = 'Other'::location_platform;
1 change: 1 addition & 0 deletions thoth-api/migrations/v0.11.16/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TYPE location_platform ADD VALUE 'Publisher Website';
8 changes: 8 additions & 0 deletions thoth-api/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,11 @@ pub fn run_migrations() -> ThothResult<()> {
Err(error) => Err(ThothError::DatabaseError(error.to_string())),
}
}

pub fn revert_migrations() -> ThothResult<()> {
let mut connection = establish_connection().get().unwrap();
match connection.revert_all_migrations(MIGRATIONS) {
Ok(_) => Ok(()),
Err(error) => Err(ThothError::DatabaseError(error.to_string())),
}
}
11 changes: 11 additions & 0 deletions thoth-api/src/model/location/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ pub enum LocationPlatform {
#[cfg_attr(feature = "backend", db_rename = "SciELO Books")]
#[strum(serialize = "SciELO Books")]
ScieloBooks,
#[cfg_attr(feature = "backend", db_rename = "Publisher Website")]
#[strum(serialize = "Publisher Website")]
PublisherWebsite,
#[cfg_attr(feature = "backend", db_rename = "Other")]
#[default]
Other,
Expand Down Expand Up @@ -180,6 +183,10 @@ fn test_locationplatform_display() {
);
assert_eq!(format!("{}", LocationPlatform::ScienceOpen), "ScienceOpen");
assert_eq!(format!("{}", LocationPlatform::ScieloBooks), "SciELO Books");
assert_eq!(
format!("{}", LocationPlatform::PublisherWebsite),
"Publisher Website"
);
assert_eq!(format!("{}", LocationPlatform::Other), "Other");
}

Expand Down Expand Up @@ -242,6 +249,10 @@ fn test_locationplatform_fromstr() {
LocationPlatform::from_str("SciELO Books").unwrap(),
LocationPlatform::ScieloBooks
);
assert_eq!(
LocationPlatform::from_str("Publisher Website").unwrap(),
LocationPlatform::PublisherWebsite
);
assert_eq!(
LocationPlatform::from_str("Other").unwrap(),
LocationPlatform::Other
Expand Down
4 changes: 2 additions & 2 deletions thoth-app-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "thoth-app-server"
version = "0.11.15"
version = "0.11.16"
authors = ["Javier Arias <[email protected]>", "Ross Higman <[email protected]>"]
edition = "2018"
edition = "2021"
license = "Apache-2.0"
description = "Actix instance serving Thoth's WASM GUI statically"
repository = "https://github.com/thoth-pub/thoth"
Expand Down
8 changes: 4 additions & 4 deletions thoth-app/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "thoth-app"
version = "0.11.15"
version = "0.11.16"
authors = ["Javier Arias <[email protected]>", "Ross Higman <[email protected]>"]
edition = "2018"
edition = "2021"
license = "Apache-2.0"
description = "WASM APP for bibliographic data"
repository = "https://github.com/thoth-pub/thoth"
Expand Down Expand Up @@ -41,5 +41,5 @@ uuid = { version = "0.8.2", features = ["serde", "v4"] }
# `getrandom` is a dependency of `uuid`, we need to explicitly import and include the `js` feature to enable wasm
# https://docs.rs/getrandom/latest/getrandom/#webassembly-support
getrandom = { version = "0.2", features = ["js"] }
thoth-api = { version = "0.11.15", path = "../thoth-api" }
thoth-errors = { version = "0.11.15", path = "../thoth-errors" }
thoth-api = { version = "0.11.16", path = "../thoth-api" }
thoth-errors = { version = "0.11.16", path = "../thoth-errors" }
2 changes: 1 addition & 1 deletion thoth-app/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"start_url": "/?homescreen=1",
"background_color": "#ffffff",
"theme_color": "#ffdd57",
"version": "0.11.15",
"version": "0.11.16",
"icons": [
{
"src": "\/android-icon-36x36.png",
Expand Down
1 change: 1 addition & 0 deletions thoth-client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
assets/schema.graphql
Loading

0 comments on commit 6532713

Please sign in to comment.