Skip to content

Commit

Permalink
Improve: New local changes (#15)
Browse files Browse the repository at this point in the history
* chore(actions): removed useless actions from repository

* chore(ci): added gitlab ci config file

* Merge: Checked local changes

* Update README.md

* Merge: merge local changes

* fix(compose): docker compose fixes

* Fix: fixed docker compose config

* Merge: local changes

* merge(local): merged local changes

* Merged: merged local changes

* Improve: moved topics config to db (#11)

* Update production.toml

* chore(rmq): replaced direct to fanout exchange kind

* Improve: Merge local changes

* chore(git): updated .gitignore file

* fix(rss): return current datetime on parsing rss item error

* fix(rss): return err from spawned thread if rss error

* chore(tracing): updated tracing msg formatting

* chore(tracing): updated tracing msg formatting

* fix(datetime): added dateparser crate

* hotfix(docker): added coping configs to container

* chore(docker): optimized docker image size

* chore(git): updated .gitignore

* chore(git): added actions to build release

* chore(git): added actions to build release

* chore(docs): updated README.md file

---------

Co-authored-by: Bread White <[email protected]>
  • Loading branch information
breadrock1 and Bread White authored Jan 6, 2025
1 parent 9a4b91f commit 513c91f
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 10 deletions.
File renamed without changes.
68 changes: 68 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: "Create release"
on:
push:
branches:
- "master"
- "release/**"

jobs:
create-release:
name: create release
runs-on: ubuntu-latest
permissions:
contents: write

outputs:
version_output: ${{ steps.version.outputs.project_version }}
upload_url_output: ${{ steps.release.outputs.upload_url }}

steps:
- uses: actions/checkout@v4

- name: Get project version
id: version
run: |
VERSION=$(cargo metadata --format-version=1 | jq '.packages[] | select(.name=="news-rss").version')
echo "project_version=$VERSION" | grep -E '\d\.\d\.\d' >> $GITHUB_OUTPUT
- name: Create github release
id: release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: false
prerelease: false
body_path: CHANGELOG.md
tag_name: news-rss-${{ steps.version.outputs.project_version }}
release_name: news-rss-${{ steps.version.outputs.project_version }}

build:
name: build project
runs-on: ubuntu-latest
needs: create-release
permissions:
contents: write

steps:
- uses: actions/checkout@v4

- name: Build rust library
run: cargo build --release

- name: Create archive
uses: vimtor/action-zip@5f1c4aa587ea41db1110df6a99981dbe19cee310
with:
files: ./target
dest: news-rss-${{ needs.create-release.outputs.version_output }}.zip
recursive: true

- name: Upload linux artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url_output }}
asset_name: news-rss-${{ needs.create-release.outputs.version_output }}.zip
asset_path: ./news-rss-${{ needs.create-release.outputs.version_output }}.zip
asset_content_type: application/zip
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
.run
.vscode

.env
.DS_Store

/rabbitmq-data
/redis-data
/redis-dataru

/target
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## What's Changed
* Feature: Impl Redis cache by @breadrock1 in https://github.com/breadrock1/news-rss/pull/1
* Improve: Impled Readme file and some fix resources by @breadrock1 in https://github.com/breadrock1/news-rss/pull/2
* Feature: Impl GitHub Actions by @breadrock1 in https://github.com/breadrock1/news-rss/pull/3
* Improve: use llm to extract structured data by @breadrock1 in https://github.com/breadrock1/news-rss/pull/4
* Fix: Removed useless tests and data by @breadrock1 in https://github.com/breadrock1/news-rss/pull/5
* Improve: Fixed crawler and added clearing html by @breadrock1 in https://github.com/breadrock1/news-rss/pull/6
* Feat/add rss sources db by @breadrock1 in https://github.com/breadrock1/news-rss/pull/7
* Fix: docker compose fixes by @breadrock1 in https://github.com/breadrock1/news-rss/pull/8
* Feature: pgsql storage routes by @breadrock1 in https://github.com/breadrock1/news-rss/pull/10
* Improve: moved topics config to db by @breadrock1 in https://github.com/breadrock1/news-rss/pull/11
* Merge/local changes by @breadrock1 in https://github.com/breadrock1/news-rss/pull/12
* Fix/fix by @breadrock1 in https://github.com/breadrock1/news-rss/pull/13
* Fix: some rss changes by @breadrock1 in https://github.com/breadrock1/news-rss/pull/14

## New Contributors
* @breadrock1 made their first contribution in https://github.com/breadrock1/news-rss/pull/1

**Full Changelog**: https://github.com/breadrock1/news-rss/commits/1
2 changes: 1 addition & 1 deletion Cargo.lock

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

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "news-rss"
version = "0.1.0"
version = "0.1.1"
edition = "2021"

[features]
Expand All @@ -11,6 +11,11 @@ default = []

test-publish-rabbit = []

[profile.release]
lto = true
panic = "abort"
strip = "debuginfo"

[dependencies]
anyhow = "^1.0"
async-trait = "^0.1"
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ RUN cargo install ${FEATURES} --bins --path .


# Target layer based on tiny official ubuntu image with neccessary binaries and data to run.
FROM ubuntu:rolling
FROM debian:bookworm-slim

RUN apt update && apt install -y curl

WORKDIR /app

COPY ./config /app/config
COPY --from=builder /app/target/release/news-rss .

ENTRYPOINT ["/app/news-rss"]
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# News-RSS Project
[![Create release](https://github.com/breadrock1/news-rss/actions/workflows/release.yml/badge.svg)](https://github.com/breadrock1/news-rss/actions/workflows/release.yml)
[![Pipelines](https://img.shields.io/github/actions/workflow/status/breadrock1/news-rss/pull-request.yml?branch=master)](https://img.shields.io/github/actions/workflow/status/breadrock1/news-rss/pull-request.yml?branch=master)
[![Last release: ](https://img.shields.io/github/v/release/breadrock1/news-rss?display_name=release)](https://img.shields.io/github/v/release/breadrock1/news-rss?display_name=release)

## Overview

Expand Down
14 changes: 8 additions & 6 deletions src/feeds/rss_feeds/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,23 @@ where

pub async fn processing_event(&self, channel: rss::Channel) -> Result<(), anyhow::Error> {
let topic = channel.title();
tracing::info!("{topic}: received new content");
tracing::info!(topic = topic, "received new rss content");

for item in channel.items() {
let response = match self.extract_item(item).await {
Ok(it) => it,
Err(err) => {
tracing::error!(err=?err, "{topic}: failed while converting rss item");
tracing::error!(topic=topic, err=?err, "failed while converting rss item");
continue;
}
};

let art_id = response.guid();
if self.cacher().contains(art_id).await {
tracing::warn!(
topic = topic,
article = art_id,
"{topic}: news article has been already parsed"
"news article has been already parsed"
);
continue;
}
Expand All @@ -138,13 +139,14 @@ where
let art_id = art.id();
let publish = self.publisher();
if let Err(err) = publish.publish(&art).await {
tracing::error!(err=?err, article=art_id, "{topic}: failed to send article");
tracing::error!(topic=topic, article=art_id, err=?err, "failed to send article");
continue;
}

tracing::info!(
topic = topic,
article = art_id,
"{topic}: article has been published successful"
"article has been published successful"
);
self.cacher.set(art_id, &art).await;
}
Expand Down Expand Up @@ -183,7 +185,7 @@ where
.map(|it| match dateparser::DateTimeUtc::from_str(it) {
Ok(time) => time.0.naive_utc(),
Err(err) => {
tracing::warn!(err=?err, time=it, "failed to extract datetime");
tracing::warn!(time=it, err=?err, "failed to extract datetime");
Utc::now().naive_utc()
}
})
Expand Down

0 comments on commit 513c91f

Please sign in to comment.