name: Rust build (stable)

on: [workflow_dispatch, push, pull_request]

env:
  CARGO_TERM_COLOR: always

jobs:
  build:

    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [macos-latest, ubuntu-latest, windows-latest]

    steps:
      - name: Linux dependencies
        if: matrix.os == 'ubuntu-latest'
        run: |
          sudo apt update -y
          sudo apt install -y build-essential gnome-keyring
          # create login keychain with password "test" and unlock it for use in tests
          export $(echo -n "test" | gnome-keyring-daemon --unlock)

      - name: Fetch head
        uses: actions/checkout@v2

      - name: Install Rust Toolchain (stable)
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
          components: rustfmt, clippy

      - name: Build (debug)
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: --verbose --all-targets

      - name: Test
        uses: actions-rs/cargo@v1
        with:
          command: test
          args: --verbose

      - name: Format check
        uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --all -- --check

      - name: Clippy check
        uses: actions-rs/cargo@v1
        with:
          command: clippy
          args: -- -D warnings

name: Rust build (stable)

on: [workflow_dispatch, push, pull_request]

env:
  CARGO_TERM_COLOR: always

jobs:
  build:

    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [macos-latest, ubuntu-latest, windows-latest]

    steps:
      - name: Linux build dependencies
        if: matrix.os == 'ubuntu-latest'
        run: |
          sudo apt update -y
          sudo apt install -y build-essential gnome-keyring

      - name: Fetch head
        uses: actions/checkout@v2

      - name: Install Rust Toolchain (stable)
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
          components: rustfmt, clippy

      - name: Build (debug)
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: --verbose --all-targets

      - name: Linux test dependencies
        if: matrix.os == 'ubuntu-latest'
        run: |
          rm -f $HOME/.local/share/keyrings/*
          echo -n "test" | gnome-keyring-daemon --replace --unlock

      - name: Test
        uses: actions-rs/cargo@v1
        with:
          command: test
          args: --verbose

      - name: Format check
        uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --all -- --check

      - name: Clippy check
        uses: actions-rs/cargo@v1
        with:
          command: clippy
          args: -- -D warnings

Fix test workflow on Linux.
Fix test workflow on Linux.
