Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
GH Actions fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
0nkery committed Jul 19, 2022
1 parent 2ed5a83 commit 450f02c
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 57 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Check

on:
push:
branches: [ master ]
pull_request:

env:
CARGO_TERM_COLOR: always

jobs:
ci:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Install latest stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v1
- name: clippy
run: cargo clippy -- -D warnings
- name: fmt
run: cargo fmt -- --check
- name: Run tests
run: cargo test --verbose
env:
RUST_BACKTRACE: 1
31 changes: 0 additions & 31 deletions .github/workflows/ci.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: deploy
name: Deploy

on:
workflow_dispatch:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/mdbook.yml → .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: mdBook
name: Docs
on:
push:
tags:
Expand Down Expand Up @@ -26,3 +26,4 @@ jobs:
AWS_ENDPOINT: ${{ secrets.AWS_ENDPOINT }}
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
MDBOOK_BUCKET: docs.netology-group.services.website.yandexcloud.net
8 changes: 4 additions & 4 deletions Cargo.lock

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

16 changes: 9 additions & 7 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct TagListQueryString {
struct TagEmptyResponse {}

#[derive(Debug)]
#[allow(dead_code)]
struct SignState {
application_id: AccountId,
authz: svc_authz::ClientMap,
Expand Down Expand Up @@ -149,7 +150,7 @@ impl_web! {
fn valid_referer(&self, bucket: &str, referer: Option<String>) -> Result<(), Error> {
let error = || Error::builder().kind("set_read_error", "Error reading an object by key");

match self.aud_estm.estimate(&bucket) {
match self.aud_estm.estimate(bucket) {
Ok(aud) => match self.audiences_settings.get(aud) {
Some(aud_settings) => if !aud_settings.valid_referer(referer.as_deref()) {
let e = error().status(StatusCode::FORBIDDEN).detail("Invalid request").build();
Expand Down Expand Up @@ -268,7 +269,7 @@ impl_web! {
fn valid_referer(&self, bucket: &str, referer: Option<String>) -> Result<(), Error> {
let error = || Error::builder().kind("set_read_error", "Error reading an object using Set API");

match self.aud_estm.estimate(&bucket) {
match self.aud_estm.estimate(bucket) {
Ok(aud) => match self.audiences_settings.get(aud) {
Some(aud_settings) => if !aud_settings.valid_referer(referer.as_deref()) {
let e = error().status(StatusCode::FORBIDDEN).detail("Invalid request").build();
Expand Down Expand Up @@ -451,9 +452,9 @@ impl_web! {
match self.aud_estm.parse_bucket(&query_string.filter) {
Ok(filter_b) => {
let include = parse_sets(&query_string.include, filter_b.audience());
let exclude = parse_sets(&query_string.exclude.unwrap_or_else(|| String::from("")), filter_b.audience());
let offset = query_string.offset.unwrap_or_else(|| 0);
let limit = std::cmp::min(query_string.limit.unwrap_or_else(|| MAX_LIMIT), MAX_LIMIT);
let exclude = parse_sets(&query_string.exclude.unwrap_or_default(), filter_b.audience());
let offset = query_string.offset.unwrap_or(0);
let limit = std::cmp::min(query_string.limit.unwrap_or(MAX_LIMIT), MAX_LIMIT);

future::Either::B(self.authz.authorize(filter_b.audience(), &sub, zobj, zact).and_then(move |zresp| match zresp {
Err(err) => future::Either::A(wrap_error(error().status(StatusCode::FORBIDDEN).detail(&err.to_string()).build())),
Expand Down Expand Up @@ -548,7 +549,7 @@ impl_web! {
// Authz subject, object, and action
let (object, zobj) = match body.set {
Some(ref set) => (
s3_object(&set, &body.object),
s3_object(set, &body.object),
vec!["buckets", &body.bucket, "sets", set]
),
None => (
Expand Down Expand Up @@ -590,7 +591,7 @@ impl_web! {
fn valid_referer(&self, bucket: &str, referer: Option<String>) -> Result<(), Error> {
let error = || Error::builder().kind("sign_error", "Error signing a request");

match self.aud_estm.estimate(&bucket) {
match self.aud_estm.estimate(bucket) {
Ok(aud) => match self.audiences_settings.get(aud) {
Some(aud_settings) => if !aud_settings.valid_referer(referer.as_deref()) {
let e = error().status(StatusCode::FORBIDDEN).detail("Invalid request").build();
Expand Down Expand Up @@ -669,6 +670,7 @@ fn wrap_error<T>(err: Error) -> impl Future<Item = Result<T, Error>, Error = ()>

////////////////////////////////////////////////////////////////////////////////

#[allow(clippy::mutable_key_type)]
pub(crate) fn run(db: Option<ConnectionPool>, cache: Option<Cache>) {
use http::{header, Method};
use std::collections::HashSet;
Expand Down
7 changes: 1 addition & 6 deletions src/app/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,7 @@ mod tower_web {
let config = context.config::<Config>().expect("missing config");
let h = context.request().headers().get(http::header::AUTHORIZATION);
let q = url::form_urlencoded::parse(
context
.request()
.uri()
.query()
.unwrap_or_else(|| "")
.as_bytes(),
context.request().uri().query().unwrap_or("").as_bytes(),
)
.find(|(key, _)| key == "access_token")
.map(|(_, val)| val);
Expand Down
3 changes: 3 additions & 0 deletions src/db/tag.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::extra_unused_lifetimes)]

use chrono::{DateTime, Utc};
use diesel::pg::PgConnection;
use diesel::result::Error;
Expand All @@ -10,6 +12,7 @@ use crate::schema::set_tag;

#[derive(Debug, Identifiable, Queryable, QueryableByName)]
#[table_name = "set_tag"]
#[allow(dead_code)]
pub(crate) struct Object {
id: Uuid,
tag: Set,
Expand Down
9 changes: 2 additions & 7 deletions src/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl Client {
let mut parsed_url = Url::parse(&url).context("failed to parse generated uri")?;

parsed_url
.set_host(Some(&proxy_host))
.set_host(Some(proxy_host))
.context("failed to set proxy backend")?;

Ok(parsed_url.to_string())
Expand All @@ -62,12 +62,7 @@ impl Client {
}
}

pub(crate) fn presigned_url(
self: &Self,
method: &str,
bucket: &str,
object: &str,
) -> Result<String> {
pub(crate) fn presigned_url(&self, method: &str, bucket: &str, object: &str) -> Result<String> {
self.sign_request(&mut self.create_request(method, bucket, object))
}
}
1 change: 1 addition & 0 deletions src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ impl<'de> Visitor<'de> for AllowedOriginsVisitor {
}
}

#[allow(clippy::mutable_key_type)]
fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
where
A: SeqAccess<'de>,
Expand Down

0 comments on commit 450f02c

Please sign in to comment.