Skip to content

Merge pull request #55 from duyet/renovate/env_logger-0.x #182

Merge pull request #55 from duyet/renovate/env_logger-0.x

Merge pull request #55 from duyet/renovate/env_logger-0.x #182

Workflow file for this run

name: Build & Test
on:
push:
branches: [master]
pull_request:
branches: [master]
env:
CARGO_TERM_COLOR: always
jobs:
cov:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_PORT: 5432
POSTGRES_USER: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Rust Toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Code Coverage
env:
GITHUB_PULL_REQUEST: ${{ github.event.pull_request.number }}
run: |
export GITHUB_PULL_REQUEST=${{ env.GITHUB_PULL_REQUEST }}
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
export PROJECT_TITLE="${{ matrix.os }}"
bash <(curl -s https://raw.githubusercontent.com/duyet/cov-rs/master/cov.sh)
fmt:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: rustfmt
override: true
- name: Run fmt check
run: cargo fmt --all -- --check
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_PORT: 5432
POSTGRES_USER: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Rust Toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
# publish rustdoc to a gh-pages branch on pushes to main
# this can be helpful to those depending on the mainline branch
publish-docs:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Rust Toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Generate Docs
run: |
cargo doc --no-deps
echo "<meta http-equiv=refresh content=0;url=grant/index.html>" > target/doc/index.html
- name: Publish
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./target/doc
# automate publishing to crates.io on pushes to tags
publish-crates:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: [build, fmt]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Rust Toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Publish
if: env.CRATES_TOKEN
run: |
pushd crate-attributes
cargo publish --token ${{ secrets.CRATES_TOKEN }}
popd
# eventual consistency in crates.io dictates we wait a bit before publishing
# so that crate-attributes is available for resolution
sleep 20
pushd crate
cargo publish --token ${{ secrets.CRATES_TOKEN }}
popd
# eventual consistency in crates.io dictates we wait a bit before publishing
# so that crate is available for resolution
sleep 20
pushd crate-http
cargo publish --token ${{ secrets.CRATES_TOKEN }}
popd
env:
CRATES_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}