rss2email 2.1.1

An RSS feed aggregator that notifies you of new posts via email.
Documentation
name: Build & Tests

on:
  push:
  pull_request:

env:
  CARGO_TERM_COLOR: always

concurrency:
  group: ci/${{ github.ref }}
  cancel-in-progress: true

jobs:
  build_test_run:
    name: Build and test on ${{ matrix.job.os }} (${{ matrix.job.target }})
    runs-on: ${{ matrix.job.os }}
    strategy:
      fail-fast: false
      matrix:
        job:
          - { target: aarch64-unknown-linux-gnu , os: ubuntu-22.04 }
          - { target: x86_64-unknown-linux-gnu  , os: ubuntu-22.04 }
          - { target: x86_64-apple-darwin       , os: macos-15     }
          - { target: x86_64-pc-windows-msvc    , os: windows-2022 }

    env:
      FEEDS: |
        https://antoniosbarotsis.github.io/index.xml
        https://www.youtube.com/feeds/videos.xml?channel_id=UCiSIL42pQRpc-8JNiYDFyzQ
        https://www.youtube.com/feeds/videos.xml?channel_id=UCUMwY9iS8oMyWDYIe6_RmoA
        https://www.youtube.com/feeds/videos.xml?channel_id=UC8ENHE5xdFSwx71u3fDH5Xw
        https://www.youtube.com/feeds/videos.xml?channel_id=UCsBjURrPoezykLs9EqgamOA
        https://www.youtube.com/feeds/videos.xml?channel_id=UC2Xd-TjJByJyK2w1zNwY0zQ
        https://blog.rust-lang.org/feed.xml
        https://blog.rust-lang.org/inside-rust/feed.xml
        https://this-week-in-rust.org/rss.xml
        https://rust.libhunt.com/newsletter/feed
        https://rustsec.org/feed.xml
        https://console.dev/tools/rss.xml
        https://console.dev/betas/rss.xml
        https://blog.jetbrains.com/feed/
        https://github.blog/feed/
        https://dusted.codes/feed/rss
        https://vladmihalcea.com/blog/feed/
        https://ossinsight.io/blog/rss.xml
        https://www.smartercode.io/feed
        https://fasterthanli.me/index.xml
        https://raphlinus.github.io/feed.xml
        https://www.huy.rocks/rss.xml
        https://gideonwolfe.com/index.xml
        https://blog.m-ou.se/index.xml
        https://liam.rs/index.xml
        https://qristin.wordpress.com/feed/
        https://wakatime.com/blog/all.atom
        https://developerlife.com/feed.xml
        https://grafana.com/blog/index.xml
        https://www.elastic.co/blog/feed
        https://redis.com/blog/feed
        # https://www.stephanboyer.com/rss Going through an outage
        https://medium.com/feed/@clockwork-labs

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.job.target }}

      - name: Use cached dependencies
        uses: Swatinem/rust-cache@v2
        with:
          key: "${{ matrix.job.os }}-${{ matrix.job.target }}-${{ hashFiles('**/Cargo.lock') }}"
          shared-key: "shared"

      - name: Build
        run: cargo build --verbose

      - name: Test
        run: cargo test --verbose
        # Set CI to false so warnings don't panic
        # as some tests are supposed to throw warnings
        env:
          CI: false

      # These are the web feeds I am using at the moment, 
      # this is supposed to function like an integration test
      - name: Run
        run: cargo run --verbose

      - name: Run mail
        run: |
          cd test-docker
          chmod +x build.sh
          ./build.sh
        if: ${{ contains(matrix.job.target, 'linux') }}

      - name: Install Hyperfine
        run: cargo install hyperfine --locked

      - name: Benchmark
        run: hyperfine 'cargo run' -r 5

  docker_build_x86:
    name: Docker build (${{ matrix.job.name }})
    runs-on: ubuntu-22.04
    strategy:
      fail-fast: false
      matrix:
        job:
          - { name: rss2email-base-x86, args: '' }
          - { name: rss2email-aws-x86 , args: --build-arg compile_flag="--features aws-lambda" }

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Create needed files
        run: |
          touch .env
          touch feeds.txt

      - name: Docker build
        run: docker build -f Dockerfile.x86 ${{ matrix.job.args }} .

  docker_build_arm:
    name: Docker build (${{ matrix.job.name }})
    runs-on: ubuntu-22.04

    strategy:
      fail-fast: false
      matrix:
        job:
          - { name: rss2email-base-arm, args: '' }
          - { name: rss2email-aws-arm , args: --features aws-lambda }

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Set up rustup target
        run: rustup target add aarch64-unknown-linux-musl

      - name: Use cached dependencies
        uses: Swatinem/rust-cache@v2
        with:
          key: "docker_build_arm-${{ matrix.job.name }}-${{ startsWith('--build-arg', '${{ matrix.job.args }}') }}-${{ hashFiles('**/Cargo.lock') }}"
          shared-key: "shared"

      - name: Install dependencies
        run: |
          sudo apt-get install libssl-dev -y
          pip3 install ziglang
          cargo install cargo-zigbuild

      - name: Build
        run: cargo zigbuild --release ${{ matrix.job.args }} --target aarch64-unknown-linux-musl

      - name: Docker build
        run: |
          docker build -f Dockerfile.scratch --build-arg path="./target/aarch64-unknown-linux-musl/release/rss2email" .

  lint:
    name: Lint
    runs-on: ${{ matrix.job.os }}
    strategy:
      fail-fast: false
      matrix:
        job:
          - { os: windows-2022, target: x86_64-pc-windows-msvc   }
          - { os: ubuntu-22.04, target: x86_64-unknown-linux-gnu }

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Install clippy and rustfmt
        run: |
          rustup component add clippy
          rustup component add rustfmt

      - name: Use cached dependencies
        uses: Swatinem/rust-cache@v2
        with:
          key: "${{ matrix.job.os }}-${{ matrix.job.target }}-${{ hashFiles('**/Cargo.lock') }}"
          shared-key: "shared"

      - name: Run clippy (base)
        run: cargo clippy --all-targets -- -Dwarnings

      - name: Run clippy (AWS Lambda)
        run: cargo clippy --all-targets -F aws-lambda -- -Dwarnings

      - name: Run fmt
        run: cargo fmt --check